Newbie Help - Tutorial "Saying" Command Doesn't Work

EmmaCreative
31 Aug 2016, 22:39I'm brand new to using Quest to create text adventures and have been working my way through the tutorial. I am currently on the Custom Commands section, the part at the bottom: "ADDITIONAL EXAMPLE - Quest can handle text and objects in the same command. Here the say command is extended to allow the player to specify who she is talking to."
I have added the command "saying" exactly as shown in the example and it doesn't work in the game. I've also tried entering the actual code exactly as shown in Code View and that doesn't work either.
This is what I get when I run the game:
You are in a room.
You can see a troll and a bob.
>say hi to troll
Error running script: Error compiling expression '"You say: " +text_talk / Print "The troll grunts but otherwise ignores you."': Unknown object or variable 'Print'
I don't understand why it's not working. Is this a bug? Am I doing something wrong? Please help.
Here is exactly how I am entering the data into the Quest Game Creator program:
Commands - Command pattern: say #text_talk# to #object_one# - Name: saying
Script - Switch... - Object - object_one
Cases - Add - Key: troll - Script: Print expression "You say: " +text_talk / Print "The troll grunts but otherwise ignores you."
Cases - Add - Key: bob - Script: Print expression "You say: " +text_talk / Print "Bob smiles back at you."
This is what shows up in the Code View box for what I entered above:
switch (object_one) {
case (troll) {
msg ("You say: " +text_talk / Print "The troll grunts but otherwise ignores you.")
}
case (bob) {
msg ("You say: " +text_talk / Print "Bob smiles back at you.")
}
}
After some playing around, I did finally figure out how to get it to work by changing the code in the Code View box to this (instead of adding all the code shown in the tutorial) :
switch (object_one) {
case (troll) {
msg ("You say: " +text_talk)
msg ("The troll grunts but otherwise ignores you.")
}
case (bob) {
msg ("You say: " +text_talk)
msg ("Bob smiles back at you.")
}
}
But I would still like to know why adding the original data via the point and click editor didn't work? What do I need to do differently next time? Thanks in advance...
The Pixie
01 Sept 2016, 06:34The problem is the way the switch command displays each option. It does not display the code or the usual GUI, but a kind of hybrid between the two. with each command separated by a slash, like this:
Print "You say: " +text_talk / Print "The troll grunts but otherwise ignores you."
In code, this is really:
msg ("You say: " +text_talk)
msg ("The troll grunts but otherwise ignores you.")
hegemonkhan
01 Sept 2016, 07:03I think this was our last recent thread of a new person needing help with the 'saying' part of the tutorial:
http://textadventures.co.uk/forum/quest/topic/5365/talking-to-characters
(hopefully maybe this will be of help for you)
the 'saying/bob/defibrilator/troll' has been confusing people for a long time, including myself 4 years ago, when I found quest and tried to go through the tutorial. It's not an easy thing to do, especially for people new to quest. This stuff is probably the most advanced/hard/difficult part of the tutorial.
you can see my own struggles with learning quest 4 years ago:
http://textadventures.co.uk/forum/quest/topic/3348/noobie-hks-help-me-thread
I jumped right into coding, as I wanted to learn to code, and quest has been wonderful at that, hehe. I'm taking programming classes now at college, and am shocked at how much quest has prepared me for them and with programming. As well as some really great knowledgeable people resources here too: Pixie, Jay, Pertex, and etc.

EmmaCreative
01 Sept 2016, 07:40Thank you both. So I guess with a Switch Command, that always has to be put in as code rather than using the P&C editor?
hegemonkhan, thanks for the links - the info there is still over my head at the moment. And it looks like the Tutorial has since been updated with Pixie's suggestions in your noobie thread.
hegemonkhan
01 Sept 2016, 13:36everything that can be done in code, can be done with the (desktop/offline quest) GUI~Editor. That's what the GUI~Editor is there for, so you don't have to know any coding to use quest (but it helps tremendously if you can at least learn a little of coding - but again, it's not required - people have made amazing games without any coding ability when using quest and its GUI~Editor).
unfortunately, you DO have to learn the coding/game-making concepts and the logic involved, regardless of whether you code or not, as even if you don't use/do any coding, to make a game you got to use and understand these concepts and logic involved. such as the 'if' logic/concepts, for example (in code, but I think you can understand/follow it, I hope, lol):
(it's kinda like: "should I do this or should I do that", except it's "if I do this, then this happens, or if I do that, then that happens")
(it takes quite a while to train your brain to think in this way, as it's not natural --- There's a reason why text/interactive-fiction games are called: IF)
if (animal.type = "lion") {
msg ("You run away fast as you can, hoping you're faster than the other person with you, and also hoping the other person will fill up the lion's belly, so it's not still hungry after gobbling the hopefully slower/other person up, and coming after you, to eat you too")
}
else if (animal.type ="deer") {
msg ("Ahh!, look at the cute (and harmless: let's assume it's harmless for this example, lol) deer! You softly squeel excitedly as you admire/watch the cute deer eating some leaves from a bush.")
}
you may also want to look into playing XanMag's 'tutorial and templates' (tutorial 2) lesson game, as it acts as a bridge from the tutorial to actually trying to do stuff on your own as you try to make your game:
http://textadventures.co.uk/forum/games/topic/5940/quest-tutorials-and-templates-published (XanMag doesn't know much coding either, so this game of his is a lot of help to people, as he shows people how to do stuff with/through the GUI~Editor, within his game)
and there's also onimike's youtube tutorial videos on quest... I'm too lazy to find his link to them at the moment, lol.
no, the 'switch' Script/Function IS a script option/choice in the GUI~Editor (Graphical User Interface/Editor: the windows with all the buttons, tabs, drop downs, etc: what you're using to make your game):
'whatever' Element* -> run as script -> add new script -> (I don't have quest open, so I'm not sure under what section/category 'switch' is under... either maybe 'output' or 'scripts', I think...) -> the 'switch' Script -> (set it up)
.* the Elements that hold/contain/use scripting (run as script -> add new script): Verbs, an Object's Script Attribute, Functions, Commands, Turnscripts, Timers)
.* Elements: http://docs.textadventures.co.uk/quest/elements/ (Elements: Objects, Exits, Verbs, Commands, Functions, Turnscripts, Timers, etc: the actual "physical-touchable-existing" things in quest as conceptual analogy. The main things in quest: Elements)
the 'switch' Script/Function:
http://docs.textadventures.co.uk/quest/guides/hs_case.html (this is probably the best link on how 'switch' works and is used. Though again, part of it uses a Command, which again is a bit more advanced, and probably will be a bit confusing for you right now - or maybe not)
http://docs.textadventures.co.uk/quest/guides/hs_multiple.html (not the best link, due to the missing pictures of when the site got changed over some time ago, and it uses a Command, which is pretty complicated in trying to learn it right now for you - or maybe not)
http://docs.textadventures.co.uk/quest/scripts/switch.html (ignore this link, as it's the coding usage of it, but I'm just posting it anyways, in-case you just want to take a look at it, and/or just for completeness)
if I didn't already post this, here's the guide section, which will be of help to you, after you've gone through the tutorial (and/or it may help you with the tutorial too):
http://docs.textadventures.co.uk/quest/guides/
ya, that was a long time ago (it was even more confusing back then), yet it still remains confusing, even after it got cleaned up a bit, from way back then.
Don't fret and don't worry about asking us for help. This stuff is really hard/advanced for new people. It's definately the hardest part(s) of the tutorial, and arguably due to how advanced/hard it is, really shouldn't be in the tutorial, as the tutorial is suppose to be mostly just the basics of using the quest GUI~Editor and concepts/logics of game-making/coding, whereas this stuff is pretty advanced/difficult/hard.
ya, my thread goes quickly into the coding aspect, so unless you're interested in learning to code, it's going to be confusing, so just ignore all the coding stuff (which is most of that thread of mine and also most of my posts, lol).
Ignore most of my posts: as I'll try to help you (and others), but I'll do so through/with code (lol), which will confuse/scare you (and have many others too who've I've tried to help), so just ignore any/all of my posts, laughs. Unfortunately, coding is fast, and thus I can help someone quickly through coding (though it doesn't do any good as that person hasn't learned coding yet), whereas guiding someone step by step through using the GUI~Editor, is a lot more work and takes a lot more time, which I usually don't have, and/or I'm just being lazy... which is most of the time, laughs.
The Pixie
01 Sept 2016, 20:02Thank you both. So I guess with a Switch Command, that always has to be put in as code rather than using the P&C editor?
It is just the way it gets displayed that is odd, which is not a problem normally, but makes it tricky when you are trying to copy an image of it. As HK says, everything you can do in code you can do in the GUI and vice versa.

EmmaCreative
03 Sept 2016, 00:20How would I enter the Switch into the GUI without it getting messed up? After I add a new key and give it a name, another box pops up for entering another Script. I used Print Expression and typed "You say: " +text_talk / Print "The troll grunts but otherwise ignores you." into that box. Am I supposed to have two separate scripts? Like I add one Script expression for "You say: " +text_talk and then add a second Script Print Message "The troll grunts but otherwise ignores you." Is that what I was doing wrong in the GUI?
hegemonkhan
03 Sept 2016, 03:08this is a bit more advanced... (and I'm not sure if it works... might have some errors/bugs in it...), but hopefully it gives you an idea on what you need to do and how to do it... (which is bsaed upon hoping that you can understand the code below, lol)...
(oops... you needed help with using the 'switch'... my bad... I just used an 'if' Script block... ignore the code directly below, lol)
<command name="saying_command">
<pattern>say #text_parameter# to #object_parameter#</pattern>
<script>
saying_function (text_parameter, object_parameter)
</script>
</command>
<function name="saying_function" parameters="text_parameter, object_parameter>
// note to Pixie or Jay:
//
// I can't remember if a Command's '#object#' Parameter will check all Objects for if the input is an 'alias' of an Object (if/when it doesn't find any Objects with their 'name' as the inputted #object# input) , or not.
// if not, then I do need to add (back, lol) in the 'foreach(object_variable, AllObjects())' checking for the 'alias' matching or not.
//
// (so much less confusing, due to my bad memory lol, if I just use #text# instead of #object#, and put in the needed checking myself, lol)
// (and I just remembered now... doesn't the #object# only check the 'player.parent' and not the entire game, anyways, right?)
if (object_parameter = null) {
msg ("Error: Your inputted object doesn't exist in the game.")
} else if (GetBoolean (object_parameter, "dead")) {
msg ("You say " + text_parameter + " to " + object_parameter.name + ", but it is dead.")
} else if (LCase (object_parameter.name) = "bob" or LCase (object_parameter.alias) = "bob") {
msg ("You say " + text_parameter + " to " + object_parameter.name + ", and " + object_parameter.name + " responds, \" {if text_parameter=hi:hi}{if text_parameter=hello:hello} " + player.name + ". {if text_parameter=hi:How are you doing?}{if text_parameter=hello:How are you doing?}\"")
} else if (LCase (object_parameter.name) = "troll" or LCase (object_parameter.alias) = "troll") {
msg ("You say " + text_parameter + " to " + object_parameter.name + ", but " + object_parameter.name + " just grunts, ignoring you.")
} else {
msg ("You say " + text_parameter + " to " + object_parameter.name + " and it responds, echoing back what you said to it, to you: " + text_parameter)
}
</function>
okay, let me try again... using the 'switch' this time around... lol
(much simplified too)
<command name="saying_command">
<pattern>say #text_parameter# to #object_parameter#</pattern>
<script>
saying_function (text_parameter, object_parameter)
</script>
</command>
<function name="saying_function" parameters="text_parameter, object_parameter">
object_variable = LCase (object_parameter.name)
switch (object_variable) {
case ("bob") {
msg ("You say \"" + text_parameter + "\" to " + object_parameter.name + ", and " + object_parameter.name + " says \"" + text_parameter + "\" back to you, in response.")
}
case ("troll") {
msg ("You say \"" + text_parameter + "\" to " + object_parameter.name + ", and it just grunts back at you, ignoring you.")
}
default {
msg ("You say \"" + text_parameter + "\" to " + object_parameter.name + ", and it responds, echoing back to you: " + text_parameter)
}
} // end of 'switch' Script/Function block
</function>
The Pixie
03 Sept 2016, 07:37How would I enter the Switch into the GUI without it getting messed up? After I add a new key and give it a name, another box pops up for entering another Script. I used Print Expression and typed "You say: " +text_talk / Print "The troll grunts but otherwise ignores you." into that box. Am I supposed to have two separate scripts? Like I add one Script expression for "You say: " +text_talk and then add a second Script Print Message "The troll grunts but otherwise ignores you." Is that what I was doing wrong in the GUI?
There are two print expressions. The problem is that the GUI view, and therefore the image you are copying, makes it look like there is one. Putting them into the switch is easy, and you can do it in the GUI, but what you need to put in is this (the square brackets just indicate a widge, don't type them!):
Print [Expression] ["You say: " +text_talk]
Print [Message] [The troll grunts but otherwise ignores you. ]
If you then close the script editor box, you will see those two lines have been condensed into one, which is what the image in the tutorial shows.
hegemonkhan
03 Sept 2016, 07:57ah, didn't realize Emma was asking about the '[MESSAGE]' vs '[EXPRESSION]' script options.
to just explain them (as addition to Pixie's post):
[MESSAGE] means that you just type in the text/string that you want, for example:
print [MESSAGE] Hi, my name is HK, what is your name?
// the above will always output this (as it's "static"):
// Hi, my name is HK, what is your name?
however, if you want to do a VARIABLE, VARIABLE+TEXT, and/or ( just TEXT/string: practically the same as doing the [MESSAGE] ), you choose the '[EXPRESSION]' script option, examples of a VARIABLE+TEXT:
// player.alias = "HK"
print [EXPRESSION] "Hi, my name is " + player.alias + ", what is your name?"
// output:
// Hi, my name is HK, what is your name?
// player.alias = "Emma"
print [EXPRESSION] "Hi, my name is " + player.alias + ", what is your name?"
// output:
// Hi, my name is Emma, what is your name?
// player.alias = "HK"
// player.age_integer = 18 // I wish I was still 18
// player.age_string = "adult"
// player.sex = "male"
// player.race = "human"
// player.class = "warrior"
print [EXPRESSION] player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + "."
// output:
// HK is a 18 year old adult male human warrior.
see, this link for the trick of writing complex (TEXT+VARIABLE) messages:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk#39951
and here's a quick example of just using a VARIABLE:
// player.alias = "HK"
print [EXPRESSION] player.alias
// output:
// HK
and here's an example of using the [EXPRESSION] to just use TEXT/string (almost same as using the [MESSAGE] script choice):
print [EXPRESSION] "Hi, my name is HK, what is your name?"
// ----------------------------------------------------------------------------------
~ VS / for comparison ~
print [MESSAGE] Hi, my name is HK, what is your name?
~ VS / for comparison ~
// in code, using just TEXT/string:
msg ("Hi, my name is HK, what is your name?")
// in code, using just a VARIABLE:
player.alias = "HK"
msg (player.alias)
// in code, using VARIABLE+TEXT:
player.alias = "HK"
player.age_integer = 18 // I wish I was still 18
player.age_string = "adult"
player.sex = "male"
player.race = "human"
player.class = "warrior"
msg (player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + ".")
// another example:
player.alias = "HK"
player.age_integer = 18 // I wish I was still 18
player.age_string = "adult"
player.sex = "male"
player.race = "human"
player.class = "warrior"
player.print_info_string_attribute = player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + "."
msg (player.print_info_string_attribute)