Page 1 of 1
Someone help me with this loop?
Posted: Wed Sep 26, 2012 12:52 am
by Krispy
I suppose what I'm trying to do should be apparent in these scripts, but I'm trying to respawn a rocketbox whenever the player's rockets get below 5.
Spoiler: A while loop (Open)script 1 enter
{
while (CheckInventory("rocket") < 5)
{
spawnspot("rocketbox",5,0,0);
delay (200);
}
}
Spoiler: An if statement (Open){
if (CheckInventory("rocket") < 5)
spawnspot("rocketbox",5,0,0);
delay(200);
restart;
}
Both have the same results, that rocket boxes keep spawning no matter how much ammo I have.
RE: Someone help me with this loop?
Posted: Wed Sep 26, 2012 1:03 am
by Combinebobnt
Actor is rocketammo, not rocket.
RE: Someone help me with this loop?
Posted: Wed Sep 26, 2012 7:47 pm
by Krispy
Thanks. Only works on the 'if' statement for me, but that's enough!
RE: Someone help me with this loop?
Posted: Tue Oct 09, 2012 4:27 am
by jdagenet
.
RE: Someone help me with this loop?
Posted: Tue Oct 09, 2012 5:04 pm
by Llewellyn
jdagenet wrote:
I haven't tested this but would this work?
Code: Select all
script 1 enter
{
While (TRUE)
{
if (CheckInventory("RocketAmmo") < 5)
{
SpawnSpot ("RocketBox", 5, 0, 0);
Delay (200);
}
}
}
Besides bumping the topic after the problem was solved:
No that would not work, your Delay is inside the IF statement, the script would run-away as soon as you had more than 5 rocketammo in your inventory.
You would want this if you wanted it to check every 200 tics and spawn a box:
Code: Select all
script 1 enter
{
if (CheckInventory("RocketAmmo") < 5)
SpawnSpot ("RocketBox", 5, 6, 0);
Delay(200);
restart;
}
or this if you wanted it to only spawn one box and wait 200 tics to spawn another:
Code: Select all
script 1 enter
{
if (CheckInventory("RocketAmmo") < 5 && !ThingCount(T_NONE, 6))
{
SpawnSpot ("RocketBox", 5, 6, 0);
Delay (200);
}
else
Delay(1);
restart;
}