Destroy Multiple Objects
#1
Posté 09 novembre 2010 - 06:37
I forget; how do you script the destruction of multiple objects bearing the same tag?
#2
Posté 09 novembre 2010 - 07:34
Lightfoot8 wrote...
Uf you include nw_io_plot you can use. GetNumItems
also in nw_io_plot is TakeNumItems for when you want to remove the items from the PC.
-420
#3
Posté 09 novembre 2010 - 07:48
Where are the objects?
Are they items on a PC Or NPC?
Are they Objects in a container?
Are they objects in an area? If so are they all in the same area?
I guess you could search the entire module and destroy them all. There are just better way to do it, If we have better information avout where they objects are at.
#4
Posté 09 novembre 2010 - 07:51
If you have these objects spead all over the module then you could use something like this(though it's not very efficient):
void main()
{
object oObject = GetObjectByTag("Tag of object");
while (GetIsObjectValid(oObject))
{
DestroyObject(oObject);
oObject = GetObjectByTag("Tag of object");
}
}
If all the placeable objects are in the same area you could do something like this(and it is more efficient):
void main()
{
object oArea = GetObjectByTag("Tag of AREA");
object oObject = GetFirstObjectInArea(oArea);
while (GetIsObjectValid(oObject))
{
if (GetTag(oObject) == "Tag of OJBECT")
DestroyObject(oObject);
oObject = GetNextObjectInArea(oArea);
}
}
#5
Posté 09 novembre 2010 - 07:57
#6
Posté 09 novembre 2010 - 08:47
#7
Posté 09 novembre 2010 - 10:51
void main()
{
int i;
object oObject = GetObjectByTag("Tag of object",i);
while (GetIsObjectValid(oObject))
{
DestroyObject(oObject);
i++;
oObject = GetObjectByTag("Tag of object",i);
}
}
#8
Posté 09 novembre 2010 - 10:55
Thanks for the correction Lightfoot.
#9
Posté 09 novembre 2010 - 11:08
Objects are not destroyed untill after the script finishes running. So the object is still there and valid untill the script ends and the delay expires. Even with the defualt delay of 0.0 the script still needs to finish first.
#10
Posté 12 novembre 2010 - 02:53
Delayed calls with a delay _inferior_ to 0.1 will carry out in the exact order they are "met" in the script.
But as the delay increases, say to 0.1 and after, the order of execution shall be _inverted_. Watch out for it.
This applies to DestroyObject() as well.
DelayCommand (0.0f, SendMessageToPC (GetFirstPC (), "DBG: 1"));
DelayCommand (0.0f, SendMessageToPC (GetFirstPC (), "DBG: 2"));
DelayCommand (0.0f, SendMessageToPC (GetFirstPC (), "DBG: 3"));
DelayCommand (0.0f, SendMessageToPC (GetFirstPC (), "DBG: 4"));
DelayCommand (0.1f, SendMessageToPC (GetFirstPC (), "DBG: 11"));
DelayCommand (0.1f, SendMessageToPC (GetFirstPC (), "DBG: 22"));
DelayCommand (0.1f, SendMessageToPC (GetFirstPC (), "DBG: 33"));
DelayCommand (0.1f, SendMessageToPC (GetFirstPC (), "DBG: 44"));
The above instructions will produce the following output:
DBG: 1
DBG: 2
DBG: 3
DBG: 4
DBG: 44
DBG: 33
DBG: 22
DBG: 11
-fox
Modifié par the.gray.fox, 12 novembre 2010 - 02:55 .





Retour en haut






