Hi there,
Having a bit of trouble with a script, but I'm assuming the issue is more related to the CreateObject function rather than the loop (or both).
The issue is that there multiple creatures spawned at each waypoint - in my actual module, it spawns four creatures, but trying with chickens spawned about 9, arranged in a neat "]" shape.
I wrote up a quick shortened copy of the script that demonstrates the issue.
void main()
{
object oObject;
oObject = GetFirstObjectInArea(OBJECT_SELF);
while(GetIsObjectValid(oObject))
{
if(GetObjectType(oObject) == OBJECT_TYPE_WAYPOINT
&& GetTag(oObject) == "spawn")
{
CreateObject(OBJECT_TYPE_CREATURE, "nw_chicken", GetLocation(oObject), FALSE);
}
oObject = GetNextObjectInArea(OBJECT_SELF);
}
}
Would it be more appropriate to use something similar to this?
void main()
{
int nNth = 1;
object oObj;
oObject = GetObjectByTag("spawn", nNth);
while (GetIsObjectValid(oObject))
{
if(GetObjectType(oObject) == OBJECT_TYPE_WAYPOINT)
{
CreateObject(OBJECT_TYPE_CREATURE, "nw_chicken", GetLocation(oObject), FALSE);
}
++nNth;
oObject = GetObjectByTag("spawn", nNth);
}
}
Modifié par Rubies, 03 septembre 2010 - 09:19 .