Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Two objects on same location, need to DeleteObject with no ID

Years of Service
User Offline
Joined: 29th Jul 2021
Posted: 29th Jul 2021 17:05
Back again after almost a day of coding without interruptions.
Now, however, Im in the middle of my Level-creating program, and once more, I get stomped by the code :/

In my EDIT mode, the grid of the floor is 24x24 wooden boxes and a spawn point for my character (the Cube).
My idea was that my player could walk around and I add things to the map from his location.
Also works well, but in this last step, I need to DeleteObject (the old floor), before inserting a new one, which has a trap.
If I just Create a new box, BOTH tiles are present, which cant be good. (see image).

HOW DO I DELETE an object, which has no "ID"?

Any ideas?


Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 29th Jul 2021 20:29
Every object has an ID. If you don't give it one yourself, AppGameKit will give it a long ass number as ID. For your particular problem, you could code a collision routine that will return the automatically assigned ID of the object and then delete it with that ID. Or you can give each of your objects an ID yourself when you create them, which I think is the simpler solution in the end. You can set up an array for that. Or a type list. Or whatever works better for you.
We all got a chicken duck woman thing waiting for us
AGK Tool Maker
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 29th Jul 2021 20:35 Edited at: 29th Jul 2021 20:39
This post has been marked by the post author as the answer.
Every object has an id, you are just not keeping track of it, which is bad practice

your grid array, turn it into a type array and store the tile id with the tile state


Also, arrays are zero based, you have empty elements in your array because you are ignoring item 0

this is better
Open Source plugins
Cl - DnD Plugin
Years of Service
User Offline
Joined: 29th Jul 2021
Posted: 30th Jul 2021 04:41
Thanks guys, that was very instructive!

Login to post a reply

Server time is: 2023-11-28 10:49:36
Your offset time is: 2023-11-28 10:49:36