Delete object is still don't working

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Delete object is still don't working

Post by enric »

I've experimented the following, when removing several objects from the map:
On the example if DeleteObject () is used, in cases where several instances of the object (smoke) are in the same tile, not all are always removed. But, if using SetObjectPosition to put them out of the map then works.

Well, in fact the smoke disappears but the line of see continues to be blocked by the smoke (as it was here yet).
If you keep the shift down over the tile you see the smoke objects are still here even without images.

for(i=0;i<999;i++)
{
id = GetObjectFromName("merr_objects", "SMOKE_ALLIED", i) ;

if(id == -1)
{
i = 999 ; // end the loop
}
else
{
SetObjectPosition(id, 0, 0) ;
//DeleteObject(id) ;
}
}
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: Delete object is still don't working

Post by pipfromslitherine »

I'll have to check, but your logic might be wrong. Once you delete the first object, then the others will move 'down' the list. So, you should only increment i when you don't find and object to delete, otherwise don't increment it.

Hope that makes sense. As I say, I could be wrong, but it's a pretty common issue when deleting from indexed lists.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Delete object is still don't working

Post by enric »

Yea, I think I understand now: the nth is absolute for all instances of the same object on the map, NO for instances of the same object in the same tile.
So if using DeleteObject I must use:
id = GetObjectFromName("merr_objects", "SMOKE_ALLIED", 0) ; //always nth = 0
so, when I find an instance nth 0 and I delete it, another one is now taking nth 0, until all are gone.
Right?
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: Delete object is still don't working

Post by pipfromslitherine »

That's right I think. As I say, that's off the top of my head. :)

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: Delete object is still don't working

Post by enric »

C'est domage, a unique id for every object in the map during all game will be very appreciated.
Maybe next BA2 will add this...
Removing and adding objets (mines, traps, wire) and keeping a state of each one with a unique id, will make code easier.
Thanks.
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Re: Delete object is still don't working

Post by pipfromslitherine »

Hmmm - it's a lot of overhead for a small subset of features. But I will take a look.

Cheers

Pip
Post Reply

Return to “Battle Academy : Modders Corner ”