Command Order

watercold23
09 Feb 2013, 21:09
Hi! I'm relatively new to this program and I've been able to figure out most of how to make a game on my own, but there has been one obstacle that I haven't been able to get around: how do you make it so a command has a different answer depending on whether a previous command has been given by the player. For example, my player starts the game lying down. If the player tries to say "look around," I want the game to tell them that they cant -- that they need to stand up first. And after they "stand up," when they then type "look around," I want to describe their surroundings. Is there any way to have conditional commands? Where the response is dependent on whether or not the player has given other commands first? Thanks!

HegemonKhan
09 Feb 2013, 22:56
this can be done by some simple coding or also with the noob-friendly GUI mode too

just add an attribute to the player, called:

standing (or sitting, if you prefer to use ~ work with instead), make it as a boolean, set it to false (or true if you're using ' sitting ', as the true-false is reversed if you use ' sitting ' instead of ' standing ' ).

then for your various scripts, you can just add in the code line:

if (player.standing = true) {
-> then...
}
else if ...

or

if (player.sitting = true) {
-> then...
}
else if ...

or

if (player.standing = false) {
-> then...
}
else if ...

or

if (player.sitting = false) {
-> then...
}
else if ...

and you also need to make coding lines where you need, to change~set the attribute (standing or sitting) to true:

player.standing = true
(and then back to: player.standing = false, when you need)

or

player.sitting = true
(and then back to: player.sitting = false, when you need)


--------

if you need help with the coding or don't know at all of the coding, I can help you more, as this is just a very quick response.

you can do this either via coding or the noob friendly GUI, I can help you do this in either method.

HegemonKhan
09 Feb 2013, 23:19
here's a more detailed (though still brief and flimsy) response, as you probably need it (as you said you're new), lol.

GUI mode (the noob friendly editor with the buttons and drop down menus and etc):

player -> attributes (tab) -> add attribute (the box at the bottom) ->

name: standing
type: boolean
setting: false

player -> verb -> standup -> run a script ->
( or: command -> standup -> run a script -> )

if script -> set variable or attribute -> player.standing = false
-> set variable or attribute -> player.standing = true

player -> verb -> sitdown -> run a script ->
( or: command -> sitdown-> run a script -> )

if script -> set variable or attribute -> player.standing = true
-> set variable or attribute -> player.standing = false

player -> verb -> lookaround -> run a script ->
( or: command -> lookaround -> run a script -> )

if script -> set variable or attribute -> player.standing = true
-> print a message -> your lookaround description
else if script -> set variable or attribute -> player.standing = false
-> print a message -> "For some reason, due to your being sitting on the ground, you can't see anything around you!"

---------

if you want how this would look in code, let me know, as I'm lazy and don't want to do it, unless you ask for it, lol.

if you need help (if this isn't making sense), let me know, and I'll stop being lazy (lol) and help you do this step by step.

homeeman
11 Feb 2013, 17:57
Everything HK said is true, and if you plan to be working with Quest for very long, I strongly recommend you try to understand it, as it helps a lot to understand why things are happening the way they are when you get into more complicated coding.
BUT I wanted to throw my two cents in and let you know that there is a slightly simpler way to fix your problem.
In the room script, add your command "stand up" (or, you know, whatever you want to do with it.) When they player stands up print a message telling them they've stood up, and scroll down in the scripts menu to set object flag. If you set a flag on the player (standing) it does precisely what HK was telling you to do, it's just a bit faster, and you don't have to add the attribute yourself, the game does it for you (and automatically sets it to "True"). If for any reason you want to get rid of the True status of any boolean attribute, you can use unset object flag, which is just below the first one. Hope we've helped!

jaynabonne
11 Feb 2013, 18:04
Just keep in mind that if you don't initialize/create the attribute initially, then you can't directly reference it (e.g.
"if (player.standing)"
) as it will give a runtime error unless the variable actually exists. You can use GetBoolean(player, "standing") safely, but it seems easier just to have it defined on the player up front.. For that reason, I tend to pre-define my attributes, as it makes the coding simpler.