A problem with IDs... again.
The game I'm working on (or trying to work actually) is very dependant that the IDs of objects stay still. I'm not sure I actually understand the spread value function correctly. Now, I have an condition "Always" and event "Spread value ID in 1."
This obiviously gives the ID 1 to the player that is created last - not the one that is the first object that was created. This is actually how it is supposed to work, isn't it? Now, I don't want it to function this way, I want the first player to have ID 1 and the second ID 2 and so on. Shouldn't be difficult should it?
While at it, when a player dies - let's say player 5 - The ID of 5 should remain empty, it shouldn't be assigned to any other players. Then, when creating yet another player, it would get the lowest ID that's free (Say 4 and 5 are dead, it would first get 4 and then, when creating another player, that would get ID of 5).
Yes, I'd still have a third question. All of my players are assigned with 2 objects that are relative to the player and should get the same value as them. Well that wasn't difficult, not even for me. But, when a player is destroyed... It should again destroy those 2 objects with the same ID as the player, too! So, Player 7 is destroyed, destroy also PlayerObject 1 with ID of 7, and PlayerObject 2 with ID of 7. I have managed to do this in a way of checking every objects ID to be 7 and then destroying all the objects. Yes, it works, but I don't really want to write 100 lines of conditions for each ID. Seems like wasting code a lot.
I guess those were all of my problems... for now. I'd be very glad if someone could help me even if not with all the problems. Thanks :)
Re: A problem with IDs... again.
You can easily spread by yourself at the beginning, but this works only if you create the objects at runtime.
Have a fastloop at start
on loop XYZ -->
Create Tank at XY +Set ID to Fastloopindex (should be 0 first)
Create Turret at XY +Set ID to Fastloopindex (should be 0 first)
etc.
This way both tank and turret objects that are created first get the first ID 0,1,2,3 ... .
You need to track your last ID somewhere in a global value or counter. So you know what ID will be used next when you want to create more objects.
Also to Delete you just need one loop.
Have a Counter somewhere that tracks the ID of the destroyed objects. Let's say its 7.
On the loops run it for the amount of objects (e.g. like 20 tanks in total)
Now check if the fastloopindex = your counter value.
If that is true destroy both the tank and the turret object.
Above that condition add a new on loop condition and move a invisible active object to the tank postion. Always set it to XY of the turret or tank.
So the loops does two things. First it moves a object around to each single tank objects for each loopstep. So you can check for an overlap condition. After that it checks if the counter matches that ID of the tank.
Now add a simply +"my detector" is overlapping "tank object" condition to the loop and it will destroy the correct objects.