Inventory Item Drop

  • #1, by darren-beckettWednesday, 08. July 2015, 14:21 5 years ago
    I have setup my inventory so that i can manually click(Hold) & drag items onto scene objects.
    The problem i'm having is that I cannot see how to activate the drop item action on the scene object which is below the cursor, when I release the mouse button (Left button released).

    Great Poster

    351 Posts


  • #2, by afrlmeWednesday, 08. July 2015, 15:48 5 years ago
    You have to create item dropped actions inside of the scene objects you want to be able to drop the items on.

    Or if you aren't using dragged items, but are instead using the method where you manually declare a command & item, then you need to create command + item executed actions for the scene objects / characters you want to allow dropping them on.

    Imperator

    6842 Posts

  • #3, by darren-beckettWednesday, 08. July 2015, 17:22 5 years ago
    I'm not using dragged items, I'm using the manual method.

    Within each item:
    1) Set Item 'myItem'
    2) Set Cursor 'myItem'
    3) Set condition 'ItemHeld' to true

    Now I now need to somehow drop the current item onto the object below my cursor (When i release the mouse button)?

    Great Poster

    351 Posts

  • #4, by darren-beckettWednesday, 08. July 2015, 17:36 5 years ago
    I've done that, but how do i invoke the 'item dropped' method from within the 'Mouse Properties\Left Mouse Button (Button Released)' action?

    Great Poster

    351 Posts

  • #5, by afrlmeWednesday, 08. July 2015, 17:51 5 years ago
    You just said you weren't using the item dragged method. You need to create execute action + item inside of your scene objects.

    Inside of the left button released actions add an execute command on saved object action part. I'm guessing you'll have to create mouse enter / leave actions for your scene objects containing save object action parts & clear object action parts. Alternatively you could create a small lua function to automatically save / clear the current object below the cursor on mouse move.
    --[[
    This function should automatically set & clear the currently saved object whenever the mouse moves. I've also added some safety queries to stop
    it from executing the function each time mouse moves if the saved object
    is already the same object as what is below the cursor. The same
    goes for clearing the saved object.
    --]]

    function onMouseEvent(eventType, mousePosition)
    if eventType == eEvtMouseMove then
    if not game.CurrentObject:isEmpty() and game.SavedObject ~= game.CurrentObject then
    game.SavedObject = game.CurrentObject
    elseif game.CurrentObject:isEmpty() and not game.SavedObject:isEmpty() then
    game:clearLink(VGameSavedObject)
    end
    end
    end

    registerEventHandler("mouseEvent", "onMouseEvent", {eEvtMouseMove})
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

    Imperator

    6842 Posts

  • #6, by darren-beckettThursday, 09. July 2015, 10:30 5 years ago
    I've got it sorted now by creating a separate command for each item:

    Item1 = CanOfCoke, Command = UseCanOfCoke
    Item2 = AppleJuice, Command = UseAppleJuice

    I was then able to set the correct command when picking up each item from the Inventory and can execute the saved command on the object below the cursor from within the Mouse Release button action.

    Note: If no object is below the cursor then the command is reset back to walk.

    Active/Inactive cursors work perfectly (They are active when over an object).

    Great Poster

    351 Posts

  • #7, by sebastianThursday, 09. July 2015, 11:51 5 years ago
    you used a very weird way to make d&d working. The only difference you have is that you really drag via leftclick & hold instead of click an item and its sticked automatically.

    Thread Captain

    2337 Posts

  • #8, by afrlmeThursday, 09. July 2015, 13:39 5 years ago
    I'm not really sure why it's called dragging (vs method) when no actual dragging is involved. The first time I tried the drag item method I thought it was broken as I was literally trying to hold mouse cursor down & drag the item from the inventory - little did I realize that you just had to left click to set as dragged! D'oh! grin

    Imperator

    6842 Posts

  • #9, by sebastianThursday, 09. July 2015, 16:35 5 years ago
    its more like pick and drop

    Thread Captain

    2337 Posts

  • #10, by darren-beckettThursday, 09. July 2015, 17:13 5 years ago
    The difference is it'll now work on Android and IOS
    grin

    Great Poster

    351 Posts

Write post