Commands with unsual scopes

The Pixie

This is for occasions when you want a command to access a different scope. A couple of examples I have come across:

A shop inventory. I want the player to be able to type BUY BREAD, and Quest will look though the shop inventory object for the bread object.

A spell book. I want the player to be able to type CAST UNLOCK, and Quest will look though the spell book object for the unlock object.

The function is called ProcessScopeCommand and takes these parameters

script: A string that gives the name of the script to call on the object
scope: An object list from which to get objects
text: The text variable from command
noobject: A string to display if no object is found
noscript: A string to display if the object is found, but it does not have the named script

Here it is in action for the second example ("castspell" is the name of a script that must be present on each spell item, and gets invoked when a spell is cast):

  <command name="Cast">
<pattern>cast #text#</pattern>
<script>
ProcessScopeCommand ("castspell", GetDirectChildren (spellbook), text, "No such spell in your book", "That's not a spell; it should not even be in your book")
</script>
</command>


Here is an example (you will also need Jay's InvPane2 library file to get it to work):


Note that this cannot handle multiple objects in one command.

Entropic Pen
Okay, that explained a lot as I attempted to perform the equivalent of a simultaneous open-heart and brain surgeries. Now just one last kink:

In-game, the list alias (what is displayed in the "Equipment" section) of each object gets constantly updated. Armor is one of the biggest as players can change what armor they wear, and displays their armor's condition on the list alias. This is not the case when I moved the "player_armor" object to the secondary inventory pane. If there is a way to update the list alias for the "Equipment" pane, then it would be complete!

Okay, I'm beginning to sense a pattern in Jay's Javascript, I just need to add a function that updates the alias of just one object without resetting the entire list...

This topic is now closed. Topics are closed after 14 days of inactivity.

Support

Forums