problem with comands

zacman
31 Aug 2018, 00:39

i fallowed the tutorial to the letter, but i can't get my commands to work, what's going on?


mrangel
31 Aug 2018, 01:31

If you want someone to tell you what's wrong, you need to give more detail.

  1. Your code [the bit that's having the problem - if you're not sure where the problem is, it's better to show more. Maybe a link to your game if it's online]

  2. Steps to reproduce the problem. Is it just certain commands that don't work? Give an example of something the player could type that doesn't work properly.

  3. What happens? Does an error message appear? Does the command not work? Does it do the wrong thing? What does it say?


zacman
31 Aug 2018, 01:58

i fallowed what the tutorial for quest gave me in making the custom command say, but when i try and use it in game i can't get it to work, i put in the examples that they gave, i put them in the right spaces, but no matter how i try i can't get it to work


hegemonkhan
31 Aug 2018, 05:10

is this the 'bob' and 'defibrilator' Command part of the tutorial? This is much more advanced stuff than the rest of the tutorial, and stumps everyone who's new to quest and especially to coding.

Or, are you stuck on the 'weigh' Command part of the tutorial? This is also difficult, but not as much as the 'bob' and 'defibriliator' part of the tutorial.


oh... so, you're doing the 'say' Command in the tutorial... (helps to read your post, lol)

let's see if I can help with Commands...


A Command does an action, when you type in a specific syntax pattern, which you selected/determined/specified/crafted/wrote for that Command. The Command can just do an action or it can be given data inputs to be used within/for the action its doing

let's give some examples, as that's probably confusing...


Command Name: hi_command

Command Pattern: greet

Command Scripting: msg ("Hi!")

during game play, you type in:

greet

and the 'hi_command' is activated, doing its actions (scripting: script/s), outputing/resulting/displaying:

Hi!


or, we can have it take in data inputs and use them in its actions, like so:

Command Name: hi_command

Command Pattern: greet #text#

Command Scripting: msg ("Hi, " + text + "!")

and you type in during game play:

greet HK

and the 'hi_command' is activated, doing its actions (scripting: script/s), outputing/resulting/displaying:

Hi, HK!

and you type in during game play:

greet Zacman

and the 'hi_command' is activated, doing its actions (scripting: script/s), outputing/resulting/displaying:

Hi, Zacman!


let's get into some more detail/explanation now in what is going on, okay?

Command Pattern: greet #text#

the first word of the Command's 'pattern' Attribute, is what I like to call the 'activator', as it best determines what Command to use/do/activate/execute/run, and so, to avoid any issues, every Command should have an unique 'activator' word (the first word of the pattern), like so:

Command Name: talk_command
Command Pattern: talk

Command Name: kick_command
Command Pattern: kick

as look at the issues that happen when its not unique:

Command Name: greet_command
Command Pattern: greet
Command Scripting: msg ("Hi!")

Command Name: dynamic_greet_command
Command Pattern: greet #text#
Command Scripting: msg ("Hi, " + text + "!")

and you type in:

greet HK

which Command does quest do?

quest can/will see the 'greet' and go: "ah, you want to do the 'greet_command', and thus outputs: Hi!

and thus, it'll never do the 'dynamic_greet_command' ... as just the 'greet' is a Command right there... so it's never able to see the 'greet HK', and thus will never display: 'Hi, HK!', which would be from telling it to do the 'dynamic_hi_command'...

does that make sense?

but what if you do want both of these Commands? how do you get them to work?

you have to have quest check for the most complex (the longest) pattern first and then check for less complex (shorter) patterns, until the last (least complex: shortest) pattern, like so, as a single Command:

Command Name: super_dynamic_greet_command
Command Pattern: greet #text#;greet

the semicolon separates patterns (and the order is by which is typed in first, aka: left to right)

so, it'll first check for if you typed in 'greet XXX', but if all you typed in was 'greet', then it fails the 'greet XXX' pattern check, and goes to the next pattern 'greet' to check, which is a match, and then it goes to the scripting/action

hopefully, you can see that this has a problem in that if you don't just type in 'greet', it'll always do the 'greet XXX' pattern, as you typed in something after the 'greet + [SPACE]'...

the other issue is that you got to do scripting that acts upon which pattern is used... which is a bit advanced stuff for people who don't know coding...

if you want to get into it...

you'd have to check whether the 'text' VARIABLE has a Value a stored in it (text = XXX) or not (text = null)

<command name="super_dynamic_greet_command">

  <pattern>greet #text#;greet</pattern>

  <script>

    if (text = null) {
      msg ("Hi!")
    } else {
      msg ("Hi, " + text + "!")
    }

  </script>

</command>

so, let's now get into understanding the use of the 'text' VARIABLE, as we need to understand it, which we've not done yet, lol:

Commands have two types of VARIABLES for storing in the typed in inputs to be used by the Command's scripting (its action/s):

'text' and 'object'

let's first explain the 'text' VARIABLE, as that's what I've been using/showing in this post so far:

Command Pattern: greet #text#

in the pattern, the hash/pound symbols '#XXX#' is telling quest/the-Command that, that part/segment of what is typed in during game play is to be stored into the 'XXX' VARIABLE, AS A STRING VALUE, for examples:

you type in: greet HK

the 'HK' gets stored into the 'text' VARIABLE: text = "HK"

as what I typed in, matched up with the pattern, as can be seen:

pattern: greet[SPACE]XXX
typed in: greet[SPACE]HK

the VARIABLE must either:

  1. be 'text'
  2. start with 'text'

for examples:

Command Pattern: greet #text# <---> VARIABLE: text
Command Pattern: greet #text1# <---> VARIABLE: text1
Command Pattern: greet #text_1# <---> VARIABLE: text_1
Command Pattern: greet #text_variable# <---> VARIABLE: text_variable
Command Pattern: greet #text_HK# <---> VARIABLE: text_HK
Command Pattern: greet #text_Zacman# <---> VARIABLE: text_Zacman

Command Pattern: greet #HK# ---> ERROR! Unrecognized VARIABLE!
Command Pattern: greet #HKtext# ---> ERROR! Unrecognized VARIABLE!
Command Pattern: greet #textHK# <---> VARIABLE: textHK

and its the same with the use of the 'object' VARIABLE:

Command Pattern: greet #object# <---> VARIABLE: object
Command Pattern: greet #object# <---> VARIABLE: object1
Command Pattern: greet #object_1# <---> VARIABLE: object_1
Command Pattern: greet #object_variable# <---> VARIABLE: object_variable
Command Pattern: greet #object_HK# <---> VARIABLE: object_HK
Command Pattern: greet #object_Zacman# <---> VARIABLE: object_Zacman

Command Pattern: greet #HK# ---> ERROR! Unrecognized VARIABLE!
Command Pattern: greet #HKobject# ---> ERROR! Unrecognized VARIABLE!
Command Pattern: greet #objectHK# <---> VARIABLE: objectHK

now, the difference between the 'text' and 'object' VARIABLES is:

the 'text' VARIABLE takes that input as a STRING Value (stored within the 'text' VARIABLE), which you can then do whatever with/upon within the Command's scripting

however, the 'object' VARIABLE, is different, as it tells quest to check if such an Object, of what you typed in for that designated part/segment, exists, and not just exists anywhere within the game, but only if it exists within the room you're currently within (it might also check if the Object exists in the inventory: aka, on the Player Object you're currently controlling - I tried searching but couldn't find anything on whether it checks within the inventory or just the room you're currently within, meh).

so, the use of the 'text' VARIABLE is all powerful, whereas the use of the 'object' VARIABLE is more limited, though with the Command's scripting, you can bypass the limitation of using the 'object' VARIABLE, anyways, lol. Both (text vs object) VARIABLES have their pros and cons, and whichever you use, the Command's scripting can bypass whichever one you choose to use anyways (for examples, even though you use the 'text' VARIABLE, in the Command's scripting, you can use the 'GetObject (TEXT_VARIABLE)' to check/convert the String Value stored into the 'text' VARIABLE, into an Object. And with using the 'object' VARIABLE, if the Object doesn't exist within the room you're currently within, you can just do scripting that checks all of the objects of the entire game, and see if it exists or not, and if it does, than you can get/use it within the Command's scripting anyways)


oh, I almost forgot, you can have/use multiple VARIABLES (as well as both types) within your Command pattern, for a quick example:

Command Pattern: craft #object_1#, #object_2#, #text_1#, and #text_2#
typed in: craft steel, oxygen, forge, and katana

// 'steel' and 'ogygen' would need to existing Objects, and have scripting that handles all of the inputs, and for example, it'd return a 'stainless_steel_katana' Object to you (your inventory)

P.S.

you don't need the commas and the 'and' in the pattern, as you can just do this:

Command Pattern: craft #object_1# #object_2# #text_1# #text_2#
typed in: craft steel oxygen forge katana

just as my own personal taste only, I like having/using this grammar stuff (the commas and the 'and') within my pattern, but it's not required as shown above.


so, let's see if this post helps you with using Commands... hopefully the only issues you'll have is with the scripting itself...

which we can/will help you with... take a try again at the tutorial's 'say' (and etc) Command practice problems and see if you can understand them and do them correctly now... and if you still need help, either with the Command itself, or with the scripting needed with the Command, let us know, and we'll help you with it.


hegemonkhan
31 Aug 2018, 05:18

here's the tutorial's first 'say' Command example:

<command name="say_command">

  <pattern>say #text#</pattern>

  <script>

    msg ("You say \"" + text + "\", but nobody replies.")

  </script>

</command>

// -------------------------------------------------

you type in: say hi
output: You say "hi", but nobody replies.

you type in: say hello
output: You say "hello", but nobody replies.

you type in: say ABC
output: You say "ABC", but nobody replies.

// --------

the use of the backslashes '\', are known as 'escape characters' in programming, which acts as a Command, which reads/uses the very next character following it for doing whatever (so you can NOT have a space between the backward slash and the next character), be it displaying a character or doing some action:

\" ---- this is telling the programming software (ie quest for us, lol) to display the double quote

\' --- this is telling the programming software (ie quest for us, lol) to display the single quote (though in quest, you actually don't need the escape character at all, the single quote will always be displayed anyways)

etc etc etc

examples of escape character commands and their actions of some programming languages:

https://msdn.microsoft.com/en-us/library/h21280bw.aspx
https://docs.python.org/2.0/ref/strings.html
https://www.w3schools.com/js/js_strings.asp (have to scroll down a bit)

zacman
31 Aug 2018, 13:52

it's not the fact i'm not fallowing it, it's the fact even when i follow it';s instructions, the command doesn't seem to work, it keep's saying "does not understand command"


mrangel
31 Aug 2018, 14:18

If it isn't working, there must be something wrong with the command.

Can you share what you've got, so that we can try to help you?

Either

  1. Take a screenshot of the command in the editor and put it somewhere like imgur so that we can see it

or

  1. Upload your .aslx file somewhere we can see it. Like dropbox, google drive, or upload it to this site and publish it unlisted.

zacman
31 Aug 2018, 14:30

how do i get a picture onto a reply?


mrangel
31 Aug 2018, 15:03

You'd need to upload them to another site (I usually use imgur.com because it's fast and reliable), then either provide a link or embed the image link in the post (something like <img src="http://i.imgur.com/WRGpWfz.jpg" />)

(the image is irrelevant, it's just the last picture someone sent me a link to)


zacman
31 Aug 2018, 17:34

https://imgur.com/gallery/UvFkb5a


mrangel
31 Aug 2018, 18:05

When I copy the script you've got into my own game, it gives me exactly the error I'd expect:

Error running script: Error compiling expression '"""You say \"" + text + "\" but nobody replies."': SyntaxError: Unexpected token ""You say \""" <STRING_LITERAL>; expected one of <EOF>Line: 1, Column: 3

This error is caused by too many " at the start of the expression.

But you said it was responding "does not understand command". I assume you mean the default "I don't understand your command." message?

In that case, I'd check that the command pattern is correct (which it looks like it is), or check the command's location. Is this command in the room, or in the main commands list for the game?


zacman
31 Aug 2018, 20:10

it's in the main commands list for the game, and yes the defuilt one


mrangel
31 Aug 2018, 21:16

What command are you typing?


zacman
31 Aug 2018, 21:45

i'm trying to make it work by typing "say hello" but can never get it to work.


zacman
31 Aug 2018, 21:45

i'm trying to make it work by typing "say hello" but can never get it to work.


zacman
31 Aug 2018, 22:40

sorry, sent the same message twice


mrangel
31 Aug 2018, 22:43

I'm really confused by this one. I can't see where a problem might be creeping in.

I assume this is a small game, while you're still looking at the tutorials.
Could you open the .aslx file in Notepad or vim, copy the whole code, and paste it here? Put it between lines of backticks so the forum doesn't mangle it.

Like this:

```
code goes here
```

zacman
31 Aug 2018, 22:47

it's the tutorial game example, you know the oen the tutorial makes? it's literally that


Selsynn
01 Sept 2018, 03:40

@zacman : if it's only the tutorial, your game will not have this weird bug. If you don't know how to download the .aslx because you'd be in the web version, it is just the download button and after you'll need to unzip to found the .aslx


zacman
01 Sept 2018, 04:19

no, this isn't a bug on my part, even the web version now doesn't work for me in this comand stuff, and i[m just fallowing the totuial, now it's showing a error message


J_J
01 Sept 2018, 06:58

Zacman, copy and paste your work here. Otherwise no one can fix it.

If you're concerned about your story showing up, just delete out the text in the msg sections.


zacman
01 Sept 2018, 07:33

... you have got to be KIDDING ME..... well, i nolonger have a problem, it FIXED ITSELF