Login / Registrieren
DE EN FR ES IT CZ
Zurück Nach oben

Kill Dragged Items

  • #1, by wischnik 9 years ago Zitieren
    hej there,

    i have run into another small problem, but can't find a fix:
    when i drag an item out of the inventory and kill the item with a right-click (that's a default i believe) i also want to set another specific command without making an additional click.

    is that somehow possible? at the moment i can't add any other actions to the default right-click that kills dragged items.

  • #2, by ke4 9 years ago Zitieren
    It doesn't work with the mouse actions in the mouse properties but it does work with mouse event handler.

    function onMouseEvent(eventType)
        if eventType == eEvtMouseRightButtonUp then
            --your code here
        end
    end
    
    registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseRightButtonUp})

    You can call an action in Lua if you like. For example.

    startAction("Scenes[scene_name].SceneActions[action_name]")
  • #3, by wischnik 9 years ago Zitieren
    thank you!
    i'm going to try that.

    i have a feeling 'though —correct me if i'm wrong— that your script-example doesn't take account for my intented goal, that a specific command is only set, if your cursor is holding an item at that particular moment. i already have an action set for right-clicks in any other situation and don't want to mess with that either.
  • #4, by wischnik 9 years ago Zitieren
    is it weird that i subconsciously think david duchovny himself is helping me out with visionaire studio?
  • #5, by ke4 9 years ago Zitieren
    thank you!
    i'm going to try that.

    i have a feeling 'though —correct me if i'm wrong— that your script-example doesn't take account for my intented goal, that a specific command is only set, if your cursor is holding an item at that particular moment. i already have an action set for right-clicks in any other situation and don't want to mess with that either.

    Not sure what you mean here. Can you please provide more information about what are you trying to do?
  • #6, by wischnik 9 years ago Zitieren
    jeah, sure.

    i am in the process of setting up a really straight single-click interface.

    there are two main commands: LOOK AT and MAKE USE OF — one for examination, one for interaction. you can switch between these commands with a simple right click anytime anywhere.  whereas LOOK AT is a really simple command, MAKE USE OF has some situational "subcommands". when i hover over a person with the MAKE USE command for example it changes automatically to a TALK TO command and vice versa.

    when i click on an inventory item with the MAKE USE OF command the command changes to a USE "ITEM" WITH command while simultaneously "dragging" the item. now comes the tricky part: when i am in the process of doing so and decide to kill the dragged item, i have to right-click. when i do this the command falls back to a USE command without item. this is very much unwanted because the USE "ITEM" WITH command is exclusively meant for dragged items. it is supposed to automatically fall back to the MAKE USE OF command without an additional manual step in between.

    you see what i mean?
  • #7, by ke4 9 years ago Zitieren
    Sure try this:

    if eventType == eEvtMouseRightButtonUp then
        If not game.UsedItem:isEmpty() then
            --switch your command here
        end
    end

    This checks if any item is currently being dragged. If yes then change your command if no then do nothing.
  • #8, by wischnik 9 years ago Zitieren
    wonderful. thank you …
    i'll check back on this thread if it worked out.
  • #9, by wischnik 9 years ago Zitieren
    thank you soo much.
    with the help of an additional "item dragged?"-condition it worked out fine!