Drag and drop objects for make a puzzle

  • #1, by TinTinSunday, 11. March 2018, 18:30 7 years ago
    Hi

    I want make a puzzle scene with some piece of papers. But I don't know how can I make drag and drop objects. Is it possible? I couldn't find lua command in data structure.

    I appreciate for any suggestions

    Forum Fan

    196 Posts


  • #2, by afrlmeMonday, 12. March 2018, 11:53 7 years ago
    Simplest solution would be to use the inventory system with dragging enabled so that you change the mouse cursor image to the item you are currently holding.

    I actually did some freelance a little while back for someone wanting the same kind of puzzle. I don't remember the details too well of what I did (just woke up a few minutes ago), but I know I didn't use the system I mentioned above. I believe I used a bit of Lua & some custom mouse cursors & an interface overlay to create an actual drag & drop system where you literally held the mouse & the paper piece you were holding dropped wherever you let go of the mouse. If you dropped the piece of paper anywhere inside of the correct slot then it would automatically slide to the correct position else it would remain in the position that you dropped it.

    I think I did actually intend on creating a tutorial for it at some point, but I probably got sidetracked & forgot all about it.

    Imperator

    7285 Posts

  • #3, by TinTinMonday, 12. March 2018, 13:22 7 years ago
    Thanks. The inventory system is a nice idea. How can I put the pice of papers in random around the slots?
    Sorry my Lua programming is not good.

    Forum Fan

    196 Posts

  • #4, by afrlmeMonday, 12. March 2018, 15:10 7 years ago
    Just use regular scene objects. You can hide them using conditions or values.

    You could also use characters too if you wanted or drag around animations or scene objects. There's lots of different ways you could go about sorting this puzzle out.

    Quick note: you don't actually need an item in your inventory to be able to assign it as an held item.

    Imperator

    7285 Posts

  • #5, by TinTinMonday, 12. March 2018, 15:24 7 years ago
    Great!!. Got it. Thanks a lot. I'll write here if had another question.

    Forum Fan

    196 Posts

  • #6, by TinTinThursday, 12. April 2018, 15:31 7 years ago
    Sorry for old topic
    How can I make a drag and drop items  in  inventory slots?With suppose we have 32X32 slots

    Forum Fan

    196 Posts

  • #7, by stothewThursday, 12. April 2018, 17:08 7 years ago
    i don´t know if it is the best solution, but i would replace Mouse cursor if you click on it in the scene and do add Item on "leftclick" action on the slot. Then using the normal drag and drop for the other way around.

    Forum Fan

    127 Posts

  • #8, by sebastianThursday, 12. April 2018, 17:29 7 years ago
    what do you plan here? should the dragged item replace an item in the inventory and replace the old slot with the clicked item. So that they swap places? 

    Thread Captain

    2346 Posts

  • #9, by TinTinThursday, 12. April 2018, 17:39 7 years ago
    In first post said that want make a puzzle. @ AFRLme said make inventory for it.
    My question is : How can I drag drop items on empty slots? Similar to inventory in "The Dig" game

    Forum Fan

    196 Posts

  • #10, by sebastianThursday, 12. April 2018, 20:14 7 years ago
    In first post said that want make a puzzle. @ AFRLme said make inventory for it.
    My question is : How can I drag drop items on empty slots? Similar to inventory in "The Dig" game
    Never played the dig, but i guess you need to fake the empty slot but having placeholder items with no graphic. Then you can swap items out via lua. When clicking on an item, it gets dragged. therefore you can iterate through all inventory items via a lua loop and when the item in your hand is the same as on the field, set this field to another item with "nothing" as graphic.
    When having an item in hour hand and clicking on an "empty" slot, swap them out again.

    Thread Captain

    2346 Posts

  • #11, by TinTinFriday, 13. April 2018, 06:25 7 years ago
    How can write a drag item out of slots with lua? Sorry I'm not good programmer

    Forum Fan

    196 Posts