Remove item from inventory

  • #1, by dror-ben-hurThursday, 14. June 2018, 14:28 6 years ago
    Hi all,
    I like to remove/hide item from inventory when I start drag him.
    There is no "Left Click" execution type to, how can I achieve it?

    Thank you.

    Newbie

    27 Posts


  • #2, by afrlmeThursday, 14. June 2018, 15:33 6 years ago
    There should be an executed immediate or left click action, but first things first... what do you mean by dragging? Are you using the built in drag system where it sets your cursor automatically to the item when you click on it or are you using a custom cursor & manually setting the item as held?

    I need more details as there are multiple methods available for picking up & using items.

    P.S: please could you edit & delete the other duplicate topic please? Cheers.

    Imperator

    7278 Posts

  • #3, by dror-ben-hurThursday, 14. June 2018, 16:13 6 years ago
    Thank you AFRLme.
    Sorry, didn't seen it post twice smile

    I am trying to use the built in drag system, it's not easy to understand how it's works.

    My game needs:
    Drag an item from inventory (while dragging, the item in the inventory shold be removed). And dropped on specific scene object, elese the item goes back to the inventory.

    How can I achieve it?  

    Newbie

    27 Posts

  • #4, by afrlmeThursday, 14. June 2018, 16:30 6 years ago
    I would have suggested creating items as animations with 2 frames, 1 being the image & the second frame being transparent then forcing it to loop a specific animation frame, but the issue with this is that because you are using the dragged item system it uses the exact same animation as the inventory so whatever the image in the inventory is doing it will do the same in that.

    If you are up for changing to non-dragged item system then you can achieve this much easier as you can assign a custom mouse cursor when setting the item to hand, which means that inside of the animation frames you can query if the item is being held then force frame 2, else force frame 2.

    Another alternative would be on drag to remove the item from your characters inventory & then put it back afterwards. This would also require Lua script & a loop to listen out for when it should put the item back. This system could cause issues though because maybe after using the item you want to remove it entirely from the inventory.

    Actually, wait... maybe it would be possible to temporarily store the item in the inventory of another character.

    Too many bloody solutions to choose from. I think the best one would be not using the horrible built in dragged item system & manually setting the item to hand instead along with custom cursor icons.

    Imperator

    7278 Posts

  • #5, by stothewThursday, 14. June 2018, 16:48 6 years ago
    if you want to build the "custom drag & drop" AFRLme sugesstest you can try follow this tutorial. From there you could add the "blank frame animation loop" thing.


    cheers!

    Forum Fan

    127 Posts

  • #6, by afrlmeThursday, 14. June 2018, 17:10 6 years ago
    Aye, though the tutorial is using an old method for setting custom cursors. It's now possible set cursors directly with Lua script.
    system.cursor = Cursors["use"]

    Imperator

    7278 Posts

  • #7, by stothewThursday, 14. June 2018, 17:16 6 years ago
    Did not know that! pretty cool.
    So, is it possible to change the cursor with this while using default drag & drop system?

    Forum Fan

    127 Posts

  • #8, by dror-ben-hurThursday, 14. June 2018, 17:20 6 years ago
    Thank you AFRLme & stothew.
    I will take your advice and not using the built in dragged item system.

    Is there a point to start from/tutorial in english? 

    Newbie

    27 Posts

  • #9, by afrlmeThursday, 14. June 2018, 19:41 6 years ago
    Hmm...

    1. Untick "allow dragging of items from inventory" option in the main game settings.

    2. I assume you have an interface with at least 1 command button, so make sure you go to the "command properties" tab for your default command & set the command can be used on option to objects & characters"

    3. Now you need to create some custom cursors that you want to show when an item is being held, so do that.

    4. now create an item. In the animation section add a single frame & add the item image to it it. Create a new frame, but leave it empty or link an image file with a transparent background that is the same size as your item images.

    5. click on the first frame & click on the edit button. Open up the actions section in the window that pops up & then create an execute a script action part & add something like this inside of it...

    if game.UsedItem:getName() == "itm_rock" then
     ActiveAnimations["itm_rock"].FirstFrame = 2
     ActiveAnimations["itm_rock"].LastFrame = 2
    else
     ActiveAnimations["itm_rock"].FirstFrame = 1
     ActiveAnimations["itm_rock"].LastFrame = 1
    end

    You need to copy the same code into the second frame as well.

    6. Go to the actions section for the item & create an executed "command name" (immediate) type command & inside of the action block for that you want to set the item & the cursor that you want to be displayed.

    Rinse & repeat for the rest of the items.

    I have to be honest though that I much prefer using my command based method for items as it's much cleaner. Quick note: if you are displaying action text, then the text will still be displayed on mouse over of the item even if it's hidden, so you need to kill action text on mouse over if it's set to that state & undo on mouse leave - bit of Lua or if query business would be needed to sort that out.

    Imperator

    7278 Posts

  • #10, by dror-ben-hurFriday, 15. June 2018, 08:08 6 years ago
    Thank you very mush AFRLme, 
    As usually your explanation is clearly and very professional...! 

    Newbie

    27 Posts