How to move an object from one card to another?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
charleshallock
Posts: 1
Joined: Tue Jul 15, 2025 7:50 am

How to move an object from one card to another?

Post by charleshallock » Tue Jul 15, 2025 7:55 am

Hello,
For a game I'm developing, I've implemented an inventory system. When you interact with an image, its visibility is set to 'false,' and the name of the image is added to a spare inventory 'slot' in an SQLite database.

When you select the item in a data grid and click the 'drop' button, the corresponding database entry is removed, and the image's visibility is set back to 'visible.' I know this might make me sound like a total beginner to the experienced coders here, but that's my approach.

1. The main issue with my current method is that when you move between cards (or 'rooms' in my game), the image doesn’t transfer with you. While the database entry in the inventory travels with you, you can't drop items in different cards because they are tied to a specific card.

2. Is there a better way to handle this before it's too late? I’m working on a demo game to learn and avoid fundamental mistakes that could cause problems later on.

3. Can I make the object move to the current card if the player chooses to drop it in a different room?

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to move an object from one card to another?

Post by Klaus » Tue Jul 15, 2025 9:02 am

Hi Charles,

welcome to the forum!

Hm, I would probably use a couple of BUTTONs, one on each card where neccessary,
with the image you need as the ICON for the button.

This way, you can show/use your imge on many cards, but the image is only "physically"
present ONCE in your stack.

Know what I mean? Drop a line if not! :)

Best

Klaus

bwmilby
Posts: 462
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: How to move an object from one card to another?

Post by bwmilby » Tue Jul 15, 2025 10:27 pm

One option would be to use a shared group that is placed on all cards. When the object is hidden it could be placed into this inventory group. When you unhide the item you would also need to move it out of the group. The way the shared group works would allow the image to be available on all cards.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: How to move an object from one card to another?

Post by dunbarx » Wed Jul 16, 2025 3:41 pm

Charles (?)

Sounds like you are pretty well along for a "beginner". Some questions:

Is there a single image or are there multiple ones, depending on the card?
Whatever image there is, is that the first place the user is supposed to interact?
You said "When you interact with an image, its visibility is set to 'false". How does the user terminate that interaction, in order to hide the image?

I am trying to understand the process. Oftentimes for me, rethinking the entire methodology has made my life much simpler.

Craig

Post Reply