Kill Dragged Items

  • #1, by wischnikSaturday, 11. November, 10:23 A week 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

    18 Posts


  • #2, by ke4Saturday, 11. November, 11:04 A week 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})
    1
    2
    3
    4
    5
    6
    7

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

    startAction("Scenes[scene_name].SceneActions[action_name]")
    1

    Key Killer

    802 Posts

  • #3, by wischnikSaturday, 11. November, 12:09 A week 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

    18 Posts

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

    Newbie

    18 Posts

  • #5, by ke4Saturday, 11. November, 12:21 A week 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

    802 Posts

  • #6, by wischnikSaturday, 11. November, 13:06 A week 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

    18 Posts

  • #7, by ke4Saturday, 11. November, 13:29 A week ago
    Sure try this:

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

    This checks if any item is currently being dragged. If yes then change your command if no then do nothing.

    Key Killer

    802 Posts

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

    Newbie

    18 Posts

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

    Newbie

    18 Posts

Write post