help with a script command

I was studying some script command examples for the 'cloak of darkness' adventure.

What does this mean?
set variable object parent = expression player

(It's part of the Wear command)


I assume that's how it appears in the GUI.

In code view, that would be:

object.parent = player

It takes the object object (which can be either an object named "object", or an object which the variable "object" refers to), and sets its parent attribute to be a reference to the result of the expression player.

In this case, player is probably the name of an object.
So, that line sets an object's parent attribute to be the object named player.

parent is a special attribute; it controls where an object is in the world. parent will always be the object that another object is inside. So an object's parent could be a room, or a container.

In this case, setting parent to the player object puts it in your inventory.


This is the script command of my example. (I removed the "<" character so it would print).

command name="Wear">
pattern>put #object# on; wear #object#; put on #object#; don #object#; wear #object#
unresolved>You want to wear what?
scope>inventory
script>
if (not HasBoolean(object, "worn")) {
msg ("That's not something you can wear.")
}
else if (object.worn) {
msg ("You're already wearing " + object.article + ".")
}
else {
msg ("You put " + object.article + " on.")
object.parent = player
object.worn = true
}
/script>
/command>

In this case from what I understand if I was to type "wear hat" then object.article becomes hat and object.parent becomes hat


In this case from what I understand if I was to type "wear hat" then object.article becomes hat and object.parent becomes hat

No.
If the player types "wear hat" then object is the hat.
Assuming that the hat can be worn, it does 3 things:

msg ("You put " + object.article + " on.")

This line generates a message, using the attribute object.article (which would be "it" or "them" depending if the object is plural). So "wear hat" would display the response "You put it on." but "wear shoes" would result in "You put them on".

object.article is used in the message, but it isn't changed.

object.parent = player

This sets hat.parent to player (putting the hat in the inventory if it isn't already).

object.worn = true

This sets the hat's worn flag to true.


Thanks mrangel.
That helps to clear up a few things.

Out of interest as you know Quest very well have you been using Quest for a long time or do you work closely with Quest's creator on Quest?

Brian


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

Support

Forums