Kill Dragged Items

  • #1, by wischnikSaturday, 11. November 2017, 10:23 6 years ago
    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.

    Newbie

    25 Posts


  • #2, by ke4Saturday, 11. November 2017, 11:04 6 years ago
    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]")

    Key Killer

    810 Posts

  • #3, by wischnikSaturday, 11. November 2017, 12:09 6 years ago
    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.

    Newbie

    25 Posts

  • #4, by wischnikSaturday, 11. November 2017, 12:11 6 years ago
    is it weird that i subconsciously think david duchovny himself is helping me out with visionaire studio?

    Newbie

    25 Posts

  • #5, by ke4Saturday, 11. November 2017, 12:21 6 years ago
    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?

    Key Killer

    810 Posts

  • #6, by wischnikSaturday, 11. November 2017, 13:06 6 years ago
    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?

    Newbie

    25 Posts

  • #7, by ke4Saturday, 11. November 2017, 13:29 6 years ago
    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.

    Key Killer

    810 Posts

  • #8, by wischnikSaturday, 11. November 2017, 13:37 6 years ago
    wonderful. thank you …
    i'll check back on this thread if it worked out.

    Newbie

    25 Posts

  • #9, by wischnikSaturday, 11. November 2017, 16:37 6 years ago
    thank you soo much.
    with the help of an additional "item dragged?"-condition it worked out fine!

    Newbie

    25 Posts