Verb and command problems

TM123
Following instructions I found here: http://docs.textadventures.co.uk/quest/ ... mands.html

Enter the following text into the command pattern box:
say #text#

If the player types "say hello", the "text" string variable will contain "hello"
Let's now add a script to print the required response. Add a "print a message" command and choose "expression".
Then enter this expression:
"You say \"" + text + "\", but nobody replies."

SO: my problem: it doesn't work. First, it doesn't recognize "+" if I get rid of the quotation marks -- "You say text, but nobody replies" - It prints out exactly that -- You say text, but nobody replies -- not the contents of the string variable "text"
If I put quotes around it -- ""You say" + text + ", but nobody replies"" I get: "You say" + text + " but nobody replies."

How is it REALLY done?

TM123
Whoops, silly me. I had it on "print message" rather than "print expression." Sorry, I got so used to reading incorrect information I figured it couldn't have been me.

HegemonKhan
ya, just to re-emphasize what you already figured out:

in the GUI~Editor:

[message] means JUST~ONLY text (static):

text: "Hi, my name is HK." // In the GUI~Editor for [message] ONLY: you don't need the double quotes, as the quest engine does it for you. Otherwise, you need to put in the double quotes yourself. This causes a lot of confusion. Textual parts MUST ALWAYS be encased within double quotes, except and only except if you're using the GUI~Editor's [message] option, then and only then, do you not need your textual part to be encased within double quotes, as the [message] tells the quest engine that it is textual, and it will put in the double quotes behind the scenes for you. In all other cases, you must put in the double quotes for any textual part.

[expression] means text, VARIABLES (dynamic), and~or text+VARIABLES (dynamic)

player.alias = "HK"

text: "Hi, my name is HK."
or
VARIABLES: player.alias // outputs: HK
or
text+VARIABLES: "Hi, my name is " + player.alias + "." // outputs: Hi, my name is HK.
or
text+VARIABLES (using text processor commands): "Hi, my name is {player.alias}." // outputs: Hi, my name is HK.

TM123
So my next question is: How do you do that with a verb?
The automatic default expression for my verb "goshdarn": "You can't goshdarn " + object.article + "."
makes me think object.article would work in a script, but it doesn't, like so:

if (object.article = "hole") {
msg ("THAT WORKED.")
}

I really hate asking questions, but I've spent over two hours trying to track down this one little bit of info.

HegemonKhan
the 'article~gender' built-in Attributes are used for outputting: him~her~it~he~she~they~them

http://docs.textadventures.co.uk/quest/ ... ender.html
http://docs.textadventures.co.uk/quest/ ... ticle.html

so, you need to change

object

in your VARIABLE (an Attribute VARIABLE):

object.article

to the name of your Object, for example:

HK.article

or you can use the special 'this' (it gets the Object, which is the Object that you added the Verb to, it gets the Verb's Object), too:

this.article

so, your 'defaultexpression' would be something like this:

"You can't use " + HK.article + "like that."
or
"You can't use " + this.article + "like that."

-----------

I'm not sure what you're trying to do with your:

if (object.article = "hole") {
msg ("THAT WORKED.")
}

as this is incorrect usage, and I don't know what your intended usage was suppose to be.

-------

my way of displaying the general syntax~format is this:

Attribute Usage: Object_name.Attribute_name
or
Attribute Usage: Object_name.Attribute_name = Value_or_Expression
or (within an 'if' Script):
GUI~Editor: if [expression] Object_name.Attribute_name OPERATOR Value_or_Expression
in Code: if (Object_name.Attribute_name OPERATOR Value_or_Expression) { scripts }

Variable Usage: variable_string = Value_or_Expression

Command's Parameter-Variable Usage: (not covering here, too difficult to try to explain)

Function's Parameter Usage: (not covering here, too difficult to try to explain)

--------

OPERATORS:

Math Operators:

Addition: +
Subtraction: -
Multiplication: *
Division: /
Modulus (same as division, but it gets the remainder): %
Equals: =
Not Equals 1: <>
Not Equals 2: not Object_name.Attribute_name = Value_or_Expression
Assignment: =
Dis-Assignment 1: <>
Dis-Assignment 2: not Object_name.Attribute_name = Value_or_Expression
Comparison: =
Contrasting 1: <>
Contrasting 2: not Object_name.Attribute_name = Value_or_Expression

Text (string) Operators:

Concatenation (literally placing texts~strings next to each other): +
Assignment: =
Dis-Assignment 1: <>
Dis-Assignment 2: not Object_name.Attribute_name = Value_or_Expression
Comparison: =
Contrasting 1: <>
Contrasting 2: not Object_name.Attribute_name = Value_or_Expression
etc etc etc ???

-------

difference between Concatenation (of text~strings) and Addition (of numeric values~amounts):

Addition: 5 + 5 = 10
Addition: 5 + 5 + 5 + 5 = 20
Addition: 100 + 100 = 200
Addition: 100 + 50 + 25 = 175

Concatenation: "5" + "5" = "55"
Concatenation: "5" + "5" + "5" + "5" = "5555"
Concatenation: "100" + "100" = "100100"
concatenation: "100" + "50" + "25" = "1005025"

Concatenation: "birth" + "day" = "birthday"

Concatenation: "birth" + " " + "day" = "birth day"

Concatenation: "birth " + "day" = "birth day"

Concatenation: "birth" + " day" = "birth day"

--------

VARIABLES
-> Variable
-> Attribute
-> Parameter

Variable: variable_string = Value_or_Expression
example: handled = false
example: count = 0
example: greeting = "hi, my name is HK."
example: left_hand = shield
example: strength = 75
example: my_list = split ("blah1;blah2;blah3", ";")

Variables, as can be seen, are NOT attached to an Object (via Object_name.Attribute_name), and thus they can't be used outside of their own script block (they are 'local' VARIABLES). They're temporary+local VARIABLES, they're not 'saved', and thus not 'loadable' anywhere in your game code.

Attribute: Object_name.Attribute_name = Value_or_Expression
example: game.state = 0
example: game.state = "0"
example: player.state = 0
example: player.state = "0"
example: orc.dead = false
example: HK.favorite_color = "black"
example: player.left_hand = shield
example: player.right_hand = sword
example: HK.right_hand = claymore
example: HK.left_hand = claymore
example: HK.favorite_colors_list = split ("black;red", ";")
example: game.count = 0
example: player.count = 0
example: player.strength = 75
example: HK.strength = 100
example: orc.strength = 50

example: HK.physical_damage = (HK.claymore.physical_damage + HK.claymore.physical_damage * HK.strength / 100) - (orc.steel_plate_mail.physical_resistance + orc.steel_plate_mail.physical_resistance * orc.endurance / 100)

as can be seen, Attributes ARE attached to Objects (via Object_name.Attribute_name), and thus they're 'saved' (so long as the Object that holds them, aka that they're attached to, exists and~or still exists, obviously), which means that they can be used~loaded anywhere in the game ('global'). They're permanent (so long as the Object that they're attached to, exists and~or still exists) and they're global, you can use them anywhere in the game.

-------

you could do a script block like this:

'npc1' Object's 'Add Attribute':

(Object Name: npc1)
Atribute Name: favorite_color
Attribute Type: string
Attribute Value: whatever color

'npc1' Object's 'whatever' Verb:

if (npc1.favorite_color = "black") {
msg ("npc1 is awesome!")
} else {
msg ("npc1 is not awesome.")
}


'npc2' Object's 'Add Attribute':

(Object Name: npc2)
Atribute Name: favorite_color
Attribute Type: string
Attribute Value: whatever color

'npc2' Object's 'whatever' Verb:

if (npc2.favorite_color = "black") {
msg ("npc1 is awesome!")
} else {
msg ("npc2 is not awesome.")
}


or, you can do this:

'npc1' Object's 'Add Attribute':

(Object Name: npc1)
Atribute Name: favorite_color
Attribute Type: string
Attribute Value: whatever color

'npc1' Object's 'whatever' Verb:

if (this.favorite_color = "black") {
msg (this.name + " is awesome!")
} else {
msg (this.name + " is not awesome.")
}


'npc2' Object's 'Add Attribute':

(Object Name: npc2)
Atribute Name: favorite_color
Attribute Type: string
Attribute Value: whatever color

'npc2' Object's 'whatever' Verb:

if (this.favorite_color = "black") {
msg (this.name + " is awesome!")
} else {
msg (this.name + " is not awesome.")
}

The Pixie
TM123 wrote:So my next question is: How do you do that with a verb?
The automatic default expression for my verb "goshdarn": "You can't goshdarn " + object.article + "."
makes me think object.article would work in a script, but it doesn't, like so:

if (object.article = "hole") {
msg ("THAT WORKED.")
}

I really hate asking questions, but I've spent over two hours trying to track down this one little bit of info.

There are two parts to setting up a verb. For the verb object, you just have the default expression and that is pretty much it.

For something that can use the verb, go to the verb tab of the specific object (i.e., hole), not the verb object. Click on add, type in goshdarn, then under that put in this script:
  msg ("THAT WORKED.")

The good thing about verbs is you already know what this object is, so no need to check.

See also:
viewtopic.php?f=18&t=4953

jaynabonne
I don't know if anyone has answered your question - largely because I'm not sure what you're asking - but "article" is misnamed in Quest. "article" is actually a pronoun. So in the expression "You can't goshdarn " + object.article + ".", you would see something like:

You can't goshdarn it."

or

You can't goshdarn her."

or whatever, depending on what your article is. Unless you actually set the article to "hole", it would never be that. (I was wondering if you were confusing "article" with something else, like the actual object name or alias.)

(And The Pixie nailed the other part, which is you don't need to check anyway.)

TM123
I think I get it now. Is this correct?
A verb only handles ONE input.
If I have an item "knob" and add a verb "turn" to it, then it can run a script when the player inputs "turn knob"
but if the player inputs "turn knob clockwise" then the script would be bypassed, ONLY "turn knob" would, I don't know what to call it, trigger, the verb.
If I want to require the player to "turn knob clockwise" then I have to use a command, not a verb. Or is there some way to do that with a verb?

XanMag
You could add to the script a question like "which way do you want to turn the knob?" Followed by a get input and switch command. In the switch box, type 'result' and add counterclockwise and clockwise as cases, then run a script for each response. Be sure to add a default script too for unrecognized inputs.

I'm not sitting a my computer right now, but I think that is how it goes.

Forgewright
I use command a lot lately. Here's an example to deal with the player wanting to touch things in a room with a ceiling, walls, stone, roots, etc. I misspelled touch in the second string but you get an idea. I added all the items a player might touch and thought of every way they might say it.
touch.JPG


now I created an attribute for the command that listed several responses that the script will randomly choose.
touch attributes.JPG


It is a very simple way to cover a few bases. This command it under game in the tree on the left but it can also go directly into the room you want. since my player is in a cave all the rooms have the same objects. I don't even really have ceiling and walls as objects I just have commands that will describe them if looked at or touched. I even have one for licking them just in case the player get wound up. The responses can bring a bit of surprise and humor.
So anything I describe in a room description I try to write a command to cover a nosy player trying to dig into the game and I don't have to make it exist as an object unless it is something I want them to be able to take. Even then I just put those items in a holding room the player will never see and write a command to move the object to their inventory if they try to pick it up.
There are a few tweaks to get out all the bugs sometimes but I am comfortable doing this and the command can work in all rooms that share these items.

TM123
Forgewright wrote: I don't even really have ceiling and walls as objects I just have commands that will describe them if looked at or touched


Very cool!

Thanks for all the help, everyone. I'm starting to get the hang of it.

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

Support

Forums