More trouble with stand up.

resoundingKnow
08 Dec 2016, 17:35

The player can now stand up, but only if the user enters exactly "stand", "stand up" or "get up". If the user enters "stand up so I can get some lunch" or "Please stand up", for example, it doesn't work. In cases like this, how can I get the stand up script to run?

Thank you.


OurJud
08 Dec 2016, 18:44
  1. When someone provides an answer the courteous thing to do is thank them. Even if the answer doesn't solve your problem at least acknowledge it.

  2. Why have you started a new thread for the same question.

  3. I've already told you the answer in the other thread.

And have you ever played text adventures before?? No one is going to type Stand up so I can get some lunch. That's not how text adventures work.

I'm already wondering if you're a bit of a troll.


hegemonkhan
08 Dec 2016, 20:34

there's the string/text manipulation Functions:

http://docs.textadventures.co.uk/quest/functions/ (scroll down to the very bottom, to the 'String Functions' section)

for instance:

http://docs.textadventures.co.uk/quest/functions/string/startswith.html
http://docs.textadventures.co.uk/quest/functions/string/mid.html
http://docs.textadventures.co.uk/quest/functions/string/endswith.html
http://docs.textadventures.co.uk/quest/functions/string/instr.html


example using 'get input', but you can use this for Commands too, with slight changes, as Commands use 'textXXX' or 'objectXXX' instead of 'result' for their Parameter Variables.

get input {
  if (InStr (result, "stand up") = 0 or InStr (result, "get up") = 0) {
    // script/s for: you do/did NOT have 'stand/get up' within your input
  } else {
    // script/s for: you DO/DID have 'stand/get up' within your input
  }
}

However, you may just want to use a 'regex' (regular expression) for your input type, which I don't know/understand that well. Pixie can better help with the 'regex' stuff.


OurJud
08 Dec 2016, 20:37

What am I missing? Why does he have to do all this rather than just cater for the commands in the Command Pattern field?


hegemonkhan
08 Dec 2016, 21:00

he/she doesn't. It's just a matter of if you want to handle infinite inputs vs not.

if you're only handling 5 specific combinations of inputs, then it's not a big deal to type them into the pattern

if you're handling 100 or (far far far worse, lol, infinite) combinations of inputs, then it is a big deal to type them into the pattern... do you really want to type in 100 combinations of inputs (or far far far worse, an infinite amount of input combinations, lol) ??? NO!, and thus you do dynamic scripting to handle them instead. Make the computer do the work for you! That's why we created machines/computers/programming, as slave labor, to do work for us, so we don't have too! hehe :D (I laugh until computers get rights... as computers, man-machine or just machine, will be indistinguishable from pure humans, and thus have our same rights)


OurJud
08 Dec 2016, 21:56

But I don't understand how your method caters for 100s of inputs? I don't even understand what it does.

From what I can gather from that script only stand up and get up are going to work, so how is your method any different to including them in the command pattern??


hegemonkhan
08 Dec 2016, 21:59

true/false, except I have it coded in reverse (as I think this is slightly more efficient - could be wrong of ourse), the 'false/else' is your 'true:standing up', and the 'true/if' is your 'false:sitting down'

the 'InStr' Function scans the string, looking for whatever you specify:

for example:

InStr ("ABC", "B")
// true: "B" is found within "ABC", and it returns the position (an integer/number) of "B" in "ABC"

vs

InStr ("123", "B")
// false: "B" is NOT found within "123", and it returns the integer: 0


OurJud
08 Dec 2016, 22:02

I think I get it now. Does this script allow for absolutely any command, so long as it starts with either stand up or get up?

Meaning the player could type stand up and go into the kitchen to make a cup of coffee and a full English breakfast, and it would still work?

If that's the case, though, you'd somehow have to handle the commands that follow stand up.


hegemonkhan
08 Dec 2016, 22:06

for my example, using the 'InStr', if 'stand up' or 'get up' is anywhere within the string, it returns false (does the else) --- I have it reversed. Normally, you'd have the 'if' check for if the condition is true.

the 'StartsWith' checks for your specified string/whatever at the start of the string

the 'EndsWith' checks for your specific string/whatever at the end of the string

the 'Mid' checks for your specified string from the middle, outwards, towards the left-start and towards the right-end, of the string


hegemonkhan
08 Dec 2016, 22:09

"If that's the case, though, you'd somehow have to handle the commands that follow stand up (OurJud)"


yes, you're right... this would indeed have an issue with additional commands/inputs/parameters within the Command's pattern...

maybe it could be handled my way...

but otherwise/if-not, then you got to use the 'regex' (regular expression), which Pixie understands... I still get confused by the symbols it uses (they're heiroglyphics, for me, at least for now)


The Pixie
08 Dec 2016, 22:23

Regex pattern matching is described here, and yes, it is complicated...
https://github.com/ThePix/quest/wiki/Pattern-Matching-with-Regular-Expressions

But I am kind of wondering who might type PLEASE STAND UP.


OurJud
08 Dec 2016, 23:26
The Pixie
But I am kind of wondering who might type PLEASE STAND UP.

Not to mention stand up so I can get some lunch

It seems to me the OP has never played these games before.


Abigail Storm
09 Dec 2016, 00:15

Usually you just type "Stand up" when playing these games...