HandleSingleCommand - take #object#

Hi all. I need some help and guidance with the following.

In my game, I have two similarly structured routines:

The first involving a statue:

if (GetBoolean(player, "stand")) {
  statue.take = true
  HandleSingleCommand ("take statue")
}
else {
  msg ("It is too high for you to reach.")
}

The second, involving a rope:

if (GetBoolean(this, "tiedto")) {
  msg ("You can't take it.")
  msg ("The rope is  attached to the " + GetDisplayAlias(rope.attachedto) + ".")
}
else {
  HandleSingleCommand ("take rope")
}

Both routines run as scripts on the 'Take' script of the 'Inventory' tab of the objects in question.
The first, involving the statue, works every time. The second, involving the rope, causes Quest to shut down and stop working.
Any ideas on why one works and not the other would be greatly appreciated.


Could it be the "tiedto" and "rope.attachedto"???


It is because the second gets Quest into a loop. You are doing TAKE ROPE inside the script for handling TAKE ROPE.

The script runs, and does TAKE ROPE, which causes the script to run, and does TAKE ROPE, which causes the script to run, and does TAKE ROPE, which causes the script to run, and does TAKE ROPE, which causes the script to run...


You missed out the this.take = true in the second one.

Though calling HandleSingleCommand is probably a little inefficient. By the time the take script is called, it's already checked that the player has space in their inventory and everything else. So it might be easier just to move the item into the player's inventory rather than parsing the whole command again. (Or, have the tie/untie verbs (or whatever code is setting tiedto) also set this.take to be true or false, in which case a take script isn't really needed)


I thought myself that Quest was in a recurring loop, and that's why it stopped working. But, if that was the case, why does the first script involving the statue work. That follows the same pattern; 'TAKE STATUE' which causes the script to run, and does 'TAKE STATUE' which causes the script to run, and does 'TAKE STATUE' which causes the script to run, and does ...etc


The first script works because it does statue.take = true. Once take is no longer that script, the script doesn't get called again.


Yes, of course. Bangs head against fist. Thanks mrangel. I should've spotted that.
It's good to have another person check your work.


Log in to post a reply.

Support

Forums