But I think this is one of those things MMF can surprisingly handle automatically if you create a bunch of them and have a single 'set position' event. I wouldn't really trust it though.
* Always
- Tank: Spread value 0 in alterable value A
- Cannon: Spread value 0 in alterable value A
Then, you make sure there are never too many or too few cannons:
* NObjects("Tank") <> NObjects("Cannon")
- Start loop "foo" NObjects("Tank") times
* On loop "foo"
* NObjects("Tank") > NObjects("Cannon")
- Create Cannon at (0,0)
* On loop "foo"
* NObjects("Tank") < NObjects("Cannon")
* Pick one of Cannon
- Cannon: Destroy
And then you do something like this, to position the cannons over their respective tanks:
* Always
- Start loop "bar" NObjects("Cannon") times
* On loop "bar"
* Tank: Alterable value A == LoopIndex("bar")
* Cannon: Alterable value A == LoopIndex("bar")
- Cannon: Set position to (0,0) from Tank
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
26th March, 2007 at 02:04:02 -
If you have 10 cannons and 10 tanks then if you use the event:
Always set cannon to tank, it will work and it will put each cannon on each tank seperately. However if you don't have even numbers then odd things happen, which is why it is reccommended that you assign ID values to each cannon and tank object and then run a loop saying if their IDs are equal then set that cannon to its corresponding tank body.
In simple words, make each tank and cannon unique by giving them values that don't belong to the rest of them. The lazy way would be writing random(100000), but I guess you could do it differently.. As long as they stay unique.
Well you've got the idea Willx2 but spreading value is a better way of doing it. It basically increments upward 1 from the number you choose to start with, with each object.
Thus giving each object something unique.
Yeh but they were talking bout giving an object the value from the total amount of objects, but when alot of objects are deleted there are gonna be duplicates?
I use a global value in my queue engine however that works like that.. It's a kind of engine that stores every recieved message and their parameters from clients in a MooGame network and executes them one by one with a String Parser.
Well once they're set, what will happen if some objects are destroyed! or new ones are created! well I guess you could just re-spread them when something like that happens instead of always spreading. but meh.. it seems safer to having them always spreading.