New commands help
chrisw70
14 Nov 2014, 02:16I've been going through the tutorial trying to implement a new command, looking at the defibrillator example. I'm not a programmer and haven't had much luck figuring out how to create a new command that will work correctly. For example, I'm trying to create a situation where the player can "look under" something, and then it reveals an object underneath.
I get how to create an object and print a message when the player uses this command (on a table, for example); I assigned an attribute called item_hidden to the table, so the program would understand to create a new object when the player looks under the table.
But the program creates the new object whenever I "look under" anything else in the game world. I only want it to reveal the item if it's the table!
If you "look under the coconut tree" I'd like it to reply with a default message telling the player that's not something you can look under.
THough I'm sure its simple, I can't figure out how to structure this correctly through the GUI. Any Suggestions?
I get how to create an object and print a message when the player uses this command (on a table, for example); I assigned an attribute called item_hidden to the table, so the program would understand to create a new object when the player looks under the table.
But the program creates the new object whenever I "look under" anything else in the game world. I only want it to reveal the item if it's the table!
If you "look under the coconut tree" I'd like it to reply with a default message telling the player that's not something you can look under.
THough I'm sure its simple, I can't figure out how to structure this correctly through the GUI. Any Suggestions?

george
14 Nov 2014, 03:03hey, this topic might help, viewtopic.php?f=10&t=3433 . It's about the difference between commands and verbs. It seems like you might want to create a verb instead of a command. Verbs and commands are similar, but verbs always apply to objects, whereas commands don't have to.
The Pixie
14 Nov 2014, 07:48To add to george's comment, go to the "verb" tab of the table, and add "look under". Have the verb run a script.
Rather than creating an item in the script, it is much easier to move an item. I have a room called "nowhere" in my games that the player cannot get to but stores items not yet in the game. Put the item there at the start, and move it into the room when the player looks under the table.
Then your script is simply:
Rather than creating an item in the script, it is much easier to move an item. I have a room called "nowhere" in my games that the player cannot get to but stores items not yet in the game. Put the item there at the start, and move it into the room when the player looks under the table.
Then your script is simply:
my_object.parent = table.parent
Silver
14 Nov 2014, 08:18Yeah I do that too. I have a room called Junk where I move objects from and to. Another way is to make object visible.

jaynabonne
14 Nov 2014, 09:48Another way: If you want your command to work with only that table, then just make a custom command with pattern "look under table" and put it in the room where that table is. Then it won't match any other object or any other table. Have that command do what you want. Using "look under" in any other context will give whatever message Quest would give in that situation.
Note that you can have a global "look under #object#" command as well as a room-specific "look under table" command, and the room-specific one should take precedence.
Note that you can have a global "look under #object#" command as well as a room-specific "look under table" command, and the room-specific one should take precedence.
chrisw70
14 Nov 2014, 23:13Thanks All, I think I have it working now and beginning to understand it a bit better!
HegemonKhan
14 Nov 2014, 23:36Commands are global (and use typed-in input during game play), Verbs are local (the hyperlinks or buttons during game play), thus as Jay+Pixie+George all have explained, in sum, if you want to use Commands, then you'll need 'checking' (conditions, via) 'if' scripts:
it takes awhile to train your brain to code and 'if' mindset mentality, it's alien to those who've not grown up with tinkering with computers~code, or who're not born genuises at coding (see youtube video: ~ 12 year old dreams about code, lol).
it takes awhile to train your brain to code and 'if' mindset mentality, it's alien to those who've not grown up with tinkering with computers~code, or who're not born genuises at coding (see youtube video: ~ 12 year old dreams about code, lol).
<object name="bed">
<attr name="object_type_string" type="string">look_under_able</attr>
</object>
<object name="chair">
<attr name="object_type_string" type="string">sit_on_able</attr>
</object>
<object name="orc">
</object>
<command name="look_under_command">
<pattern>look under #object#</pattern>
<script>
if (object = null) {
msg ("Wrong input, try again.")
} else {
if (HasString (object, "object_type_string") = true) {
if (object.object_type_string = "look_under_able") {
// do your 'look under' script(s)
} else {
msg ("Sorry, but you can't look under this object.")
}
} else if (HasString (object, "object_type_string") = false) {
msg ("Sorry, but you can't look under this object.")
}
}
</script>
</command>