# Immobile spiders

I have a big ol’ set of indented instructions as to how spiders should move about at the climax of my story:

Spider AI
``````Every turn:
if the plotonium of the player is 18:
if any spider (called the actor) is in a room (called the current space):
if vitality of the actor is healthy:
if the actor is in Hubspin Pipes:
if the heat valve is switched on:
now the vitality of the actor is dead;
if the actor is in Room A:
if the Hotel Horror of the player is less than 35:
increase the Hotel Horror of the player by 1;
say "You can hear sounds of struggle coming from Room A.";
if the actor is in Room B:
if the Hotel Horror of the player is less than 20:
increase the Hotel Horror of the player by 1;
say "You can hear sounds of struggle coming from Room B.";
otherwise:
if the player is unengaged:
if success of the player is 1:
now the success of the player is 0;
if the actor is visible:
say "You flip the spider back over on its back and crush it.";
now the vitality of the actor is dead;
wait for any key;
let next space be a random room which is adjacent to the current space;
if success of the player is 0:
if vitality of the actor is healthy:
if the location is the current space:
now the player is engaged;
increase the difficulty of the player by eight;
now the active skill of the player is combat;
if next space is in Hubspin Cellar:
if the actor is visible, say "The spider crawls out to [the next space].";
move the actor to next space;
if the actor is visible, say "The spider crawls in from [the current space].";
if the location is the next space:
now the difficulty of the player is the difficulty of the player plus eight;
now the player is engaged;
now the active skill of the player is combat;
if next space is in Hubspin Pipes:
if the actor is visible, say "The spider crawls out to [the next space].";
move the actor to next space;
if the actor is visible, say "The spider crawls in from [the current space].";
if the location is the next space:
now the difficulty of the player is the difficulty of the player plus eight;
now the player is engaged;
now the active skill of the player is combat.
``````

Unfortunately, only one spider seems to actually follow it. The others just hang out where they’re spawned and never engage the player, since all the rules for engaging them are in this script. How do I get these instructions to apply to spiders 2-8?

I think you need a loop such as: `repeat with X running through spiders:`, where X can be replaced with any variable name you choose (“the actor” is not really that great as it shadows a variable of the same name used by the Standard Rules.) Then you will need a separate line like `let current space be the location of X;` to get the location of the spider.