Custom Commands question

karinchan999
22 Sept 2016, 11:15

I have a question regarding Custom Commands. While I read it and test it out in the Quest desktop software, there's this certain part that I didn't get. The "additional example" part that involves this;

command name="saying">
pattern>say #text_talk# to #object_one#
script>
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.")
}
default {
msg ("You say: " + text_talk + " but the " + object_one.name + " says nothing, possible because, you know, it cannot speak.")
}
}
/script>
unresolved>Say that to who?
/command>

I got it right in the software but when I run the game it doesn't work, it says "Error running script: Error compiling expression 'troll': Unknown object or variable 'troll'". How do I deal with this?


Jay Nabonne
22 Sept 2016, 11:22

Do you have an object in your game named "troll"? (Notice the letter case.)


karinchan999
22 Sept 2016, 13:58

No I didn't add it. I was copying what the tutorial wrote.
But even if I removed that 'troll" part, it still doesn't work.


Jay Nabonne
22 Sept 2016, 16:10

If you could say how it doesn't work, then it would help to help you.


hegemonkhan
22 Sept 2016, 19:20

@ karinchan999:

this section of the tutorial constantly comes up with poeple confused, as it's probably the most advanced/complex/hardest/most-difficult/confusing part of the tutorial, and thus arguably maybe shouldn't be in it, as it constantly stumps people (myself included when I found quest 4 years ago). So, you're in a very large group, we've just had a thread by another new person on this very topic (it constantly comes up), not too long ago.

here's the recent thread, see if this helps you:

http://textadventures.co.uk/forum/quest/topic/rbwbbe8h30wpfqxbxoxcjw/newbie-help-tutorial-saying-command-doesnt-work

if not, let us know, and we'll get you help in understanding it and getting it fixed up and working correctly.


(maybe we should have a stickied FAQ thread for repeated questions people have with understanding certain things, such as this 'saying/bob/troll/defibulator' Command part of the tutorial)


the 'saying' Command is referencing (looking/searching for) two Objects, 'troll' and 'Bob', so if you don't have (haven't created/added these two Objects: an Object named 'Bob' and another Object named 'troll' --- lower and upper case matters) them, you get an error as quest is looking for such Objects, but those Objects don't exist.

assuming you've got the code correct and correctly placed in your game code, too. If not, then this can cause it to not work too.

you need to create (add) an Object into the same 'whatever' Room Object as your 'player' Player Object is in (or add it to a Room Object that the 'player' Player Object can get to --- I'm not remembering what exists in your tutorial game at this point in the tutorial guide... you should have a 'room' Room Object, and maybe a connected/Exit-connected 'kitchen' Room Object, too),

and name that added Object: Bob

and do the same thing again, but name this second Object as: troll

and then, it should be working for you (you'll have to move your 'player' Player object into the same room as your 'Bob' / 'troll' Object, and then type in your input correctly to activate the 'saying' Command, for it to work at this point I think) ... if your code is right and in the right place


karinchan999
23 Sept 2016, 09:55

Jay Nabonne, something like this show up after I run the game

"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'"

And then I just try to work out the code and how I did it, maybe I just made a mistake or something but I end up having the same result.

Hi hegemoonkhan, yeah that's the same problem I had (the link). And yeah I believe that part of the tutorial suddenly got complicated. I've read the first few tutorials before that and I got it but that part... just got me all O.o

I'll try that. I hope it works. Thank you!


Alex Warren
23 Sept 2016, 10:28

Oh, this again. That bit of the tutorial has a confusing screenshot. The 'Print "The troll grunts"' bit is a new script line, not part of the same expression.

[I need to go through the docs because some bits of them have become out-of-date and/or confusing over the years - there are some parts that were contributed by people back when it was a wiki and they never really got reviewed properly.]


karinchan999
24 Sept 2016, 05:47

Oh I see. Well I hope you guys get to fix it soon. Thank you for all your help! :D