Command problem

I don't usually attempt anything too complicated, I know no coding. I tried to get a few more options on commands.
I have created a global command where a person dips a rag in water. I used several options separated by brackets and verticals (dip | place|put) etc. It works perfectly. I created another command in the same manner to throw the object ( actually a replacement object ( wet rag)) this unfortunately causes any command ( n,s,e,w, look)put in by the player to revert to answering the first command. If the second command is deleted the problem vanishes. Are my commands in conflict?


It certainly sounds like a command conflict somewhere. Can you tell us exactly what the patterns are, and whether you have each set to "Command pattern" or "Regular expression"? My first guess is that you are mixing the two, as brackets and verticals are for regular expressions, and the chances are you have "Command pattern" selected (which uses semi-colons to separate).


The first command (which is working fine )is set to command pattern, although iam using ( | ) . I have tried both settings for the second .both had the same result, in that the game was immobilised. All further input ( directions, look, inventory, etc)was put through the awkward command (without it being even used)


What are the actual patterns?


(Dip|use|put|Wet|place)(the|)(handkerchief|)(in|into|with)(the|)(spring | holy water)
Is the first command I used ,set on command pattern. This worked. I tried several options. They all worked.
(Use|Throw|toss|hurl|)(the|)(wet handkerchief |Water| holy water )( over |at|with)( thin man| poltergeist)
This messed up game.
Both were set on command pattern.
Both commands had 'if in room (both different rooms) if carrying object( both different objects.
Perhaps the two commands are too similar or maybe I should delete use option?


I have no idea how the first one works. I just tried it, and as a command pattern, the player would have to type it exactly, brackets and verticals and everything, to have Quest recognise it.

if it was me, I would do them as Regular expressions, and grab the objects in the expression, so the player can use their synonyms:

(dip|use|put|wet|place) (the |)(?<object1>.*) (in|into|with) (the |)(?<object2>.*)

More details here:
http://docs.textadventures.co.uk/quest/complex_commands.html


Thanks very much pixie. I am not good ( in fact I only know Sinclair basic) on coding symbols. Does (?


My posting was partly cut off. I don't know why.I was asking if the brackets with <(?object1> . ) should be (Handkerchief.) that being object1. Sorry to be a pain. Maybe I am overreaching myself.


In a regular expression, (?<object1>.*) is a "capture group", the angle brackets give it a name, object1, and the bit after that is what can be matched, the dot means anything, and the start means any number of them. When the player types DIP THE HANDKERCHIEF IN THE SPRING, the HANDKERCHIEF part is captured as "object1" (and SPRING as "object2").

Then Quest will try to match those strings against the objects present. If you give the handkerchief alternative names, such as "hankie", Quest will match those too, which is why it is a good idea to do it this way. Especially if you later thing of another synonym.

Once Quest has matched the objects, it will assign them to variables for the command, giving the variables the same names, now:
object1 = handkerchief
object2 = holy water

Your command needs to check what those objects, so might start:

if (not object2 = holy water) {
  msg("You can't go dipping stuff in that!")
}
else if (not object1 = handkerchief) {
  msg("Best not to dip that in water.")
}
else {

Thank you, I understand how it works now. I appreciate you putting your explanation in language I can understand. Too often I do not know the names of symbols, therefore the explanation means nothing. This, I can comprehend. Thank you again.


@ Father:

some symbols/characters are used by the forum's post for its own coding stuff, so to get these symbols/cahracters to show up in your post, you've got to put those parts of your post with the problematic symbols/characters, into a 'code box', which is done like this:

m```
problematic symbols
m```

but without the 'm's in front, which will produce the code box, and thus looks like this:

problematic symbols

these symbols/characters: ```, are the keyboard key in the upper left of your keyboard (above the left 'TAB' key and to the left of the '1' key)


Sorry to be a pain , but having been kindly shown by pixie how to do complex commands. I am finding it difficult as a complete code novice to check if object1 and 2 are in fact the required objects. I have tried to enter checks as code in code view, and I think I followed it exactly, but got a 'Failed ' message in red. Is it possible to do it with if scripts ( if so how?


I just referenced this thread myself, as I can never remember how to do this, and here is a complete working example in code. Hopefully this is a template you can use?

Here is my command expression: ^(push|open|shove|move|roll|force) (the |)(?<object1>.*)

if (object1 = stone door) {
  if (GetBoolean(stone door, "passage")) {
    msg ("The stone door has already been opened from the other side and you can venture into the darkness... if you wish.")
  }
  else {
    msg ("No can do.  The stone door is far too heavy and there is no way to move it.")
  }
}
else if (object1 = black coffin) {
  msg ("You try and wedge your fingers under the lid of the coffin, but it is far to heavy and seamless for you to move.  Besides, it might not be the best idea.")
}
else if (object1 = black coffin1) {
  msg ("You try and wedge your fingers under the lid of the coffin, but it is far to heavy and seamless for you to move.  Besides, it might not be the best idea.")
}
else if (object1 = gray coffin) {
  msg ("As disrespectful as this may be, you wedge your finger in the small space offered by the broken lid.  The aged air trapped within smells like stale death.")
  HelperOpenObject (gray coffin)
  LockExit (crypttochurch)
  LockExit (crypttotunnel)
}

EDIT: You could use another 'If' script in the then of your "proper" working 'then' and just use the same method here. If (object2 = crowbar) then run desired scripts. Else print message "You can't open that without a crowbar.

I think it'll work? You could use the AND bit of code instead of doing another 'If' but I'm not exactly sure how to code for that.


Look on the documentation:
http://docs.textadventures.co.uk/quest/complex_commands.html


My thanks to everyone who helped , but I just can't get my mind round to coding. I thought I was getting somewhere but maybe I'm too old. All I get is errors signals. I will do the best I can with just the basic readymade quest. Thank you Pixie, Xanmag , and Hegemonkhan.


Don't let your "old age" get in the way. Stumble through it. Eventually it will stick!

If you have questions, feel free to shoot me an email. I'd be glad to try and help.

[email protected]


Note that (often) you have the coding right, except for some/few stupid mistake/typo/spelling/etc error/issue... many pople think they're not getting coding because they get errors, when they don't realize, they often got the coding right, except for a few stupid mistakes/typos/spelling/etc errors/issues.


coding involves a lot of VARIABLES (Attributes: your stored/saved data), just try to think of math algebra (algebraic substitution), and it may be easier to understand coding:

(i'm putting the terms in arrow brackets, so you can see how they match up)

<VARIABLE> = <VALUE_OR_EXPRESSION>
or
<FUNCTION> <(Arguments/Parameters: inputs/data to be used by the Function's scripting)>

math algebra:

<x> = <10>

<y> = <x + 30>
// <y> = <40>
// y's (new) stored/saved value: 40

coding:

<player.alias> = <"HK">

<msg> <("Hi, my name is " + player.alias + ".")>
// <msg> <("Hi, my name is HK.")>
// output: Hi, my name is HK.

----------

an Attribute VARIABLE:

NAME_OF_OBJECT.NAME_OF_ITS_ATTRIBUTE = VALUE_OR_EXPRESSION

a real world example:

water.color = "blue"
sun.color = "yellow"

you have some Object (a thing, such as: water/sun) and they contain Attributes (traits/characteristics/properties/etc, such as color), and those Attributes have a simple Value (or a complex Value: an Expression)

in the real world, we naturally understand the type of the Values and Attributes, but computers are stupid, so they must be told what the types are for their Values and Attributes, and also everything must match up, as the logic is true for both computers and humans: 4 + apples = HUH?! It's not possible to arithemetic/math add 4 and "apples" together! You can't arithmetic/math add an 'integer' and a 'string' together! ERROR!!!!! So, Attribute/Data Types (String, Boolean, Integer, Decimal/Double/Floating Point/Float, Object, List, Dictionary, etc) matter in coding, whereas we automatically understand and use them ourselves in the real world, totally unaware of it. People and machines operate exactly the same way, but we're unaware of this, as it's become automatic/instinctive/sub-conscious/taken-for-granted by us, whereas it's not so for machines. If I say 'sun', you automatically know that it is a 'star (object)', whereas, a machine must be told this, as it doesn't automatically know this, unlike us. If I say 'love', you automatically know this is a concept/feeling/emotion, whereas a machine does not. If I say '4', you know this is an integer number, whereas a machine does not. If I say '4.2', you automatically know this is a decimal number, a machine does not. What you're reading right now in this post, you automatically know is text (String), a machine does not. Etc Etc etc.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums