changing counts on object

mblann
I'm using the windows version of Quest.
I have an object: "book of matches" that can be used to light torches, cigarettes, etc.

I'm wanting the matches to decrease in number as they are used. So I created the following when you "look at matches"
"There are " + book of matches.count + " matches left."
Where "book of matches.count" = 3 (or 4 or whatever)
How do I add the code or expression or whatever it's called to when a match is used, it reduces the count by one?
I know it should be something like "book of matches.count = book of matches.count -1" but I don't know the exact syntax and where to put it.
Do I HAVE to put it in the code itself or is there an easier way using Quest interface?

Thanks in advance for your help!!!

Mark

Avantar
I would create an attribute on the matches object and call it something like: match_count and set it as an integer. Make the value to whatever matches is in the box. If the matches object name is matches:

For matches left you will say: msg ("You have "+matches.match_count+" matches left.")
The script where you use your matches you will just add:
matches.match_count = matches.match_count - 1

HegemonKhan
the two super scripts, which let you do 90% of everything that you want in your game:

1. Attribute Usage:

in the GUI~Editor:

non-scripting (Attribute creation):

'whatever' (object) -> Attributes (Tab) -> Attributes -> Add ->

(Object Name: whatever )
Attribute Name: (whatever)
Attribute Type: (String, Boolean, Integer, Double, Object, List, Dictionary, etc)
Attribute Value: (whatever, but based upon your Attribute Type)

examples:

Object Name: game
Attribute Name: radiation
Attribute Type: int (integer)
Attribute Value: 50

Object Name: player
Attribute Name: life
Attribute Type: int (integer)
Attribute Value: 999

or, in scripting:

Object_name.Attribute_name = Value_or_Expression

examples:

game.radiation = 50
player.life = 999

in the GUI~Editor:

run as script -> add a script or add new script -> variables -> 'set a variable or attribute' -> [EXPRESSION] ~ (see above) or [whatever] ~ set it up

Basic Math Computation Expressions, examples:

Addition:

player.strength = player.strength + 50
player.strength = player.strength + player.sword.bonus_strength

Subtraction:

player.strength = player.strength - 30
player.strength = player.strength - orc.armor.bonus_endurance

Multiplication:

player.strength = player.strength * 3
player.strength = player.strength * player.sword.bonus_strength

Division:

player.strength = player.strength / 2
player.strength = player.strength / orc.armor.bonus_endurance

a complex math expression:

player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100 - orc.armor.defense - orc.armor.defense * orc.endurance / 100

2. the 'if' Script:

in the GUI~Editor:

run as script -> add a script or add new script -> scripts -> 'if' Script -> [EXPRESSION] ~ see below or [whatever] ~ set it up

Object_name.Attribute_name (=, not =, >, <, >=, <=) Value_or_Expression

-------

putting the 'if' Script and 'set a variable or attribute' Script together, example in code:

testable 'full game' code (if I didn't make any typos and not forgotten some code lines~stuff, hehe):

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="testing game stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<author>HegemonKhan</author>
<attr name="radiation_integer" type="int">50</attr>
<attr name="turn_integer" type="int">0</attr>
<statusattributes type="simplestringdictionary">turn_integer = Turn: !;radiation_integer = Radiation: !</statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="life_integer" type="int">999</attr>
<statusattributes type="simplestringdictionary">life_integer = Life: !</statusattributes>
</object>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
player.life_integer = player.life_integer - game.radiation_integer
if (player.life_integer <= 0) {
msg ("You've been explosed to too much radiation, the radiation sickness has killed you.")
msg ("GAME OVER"
finish
}
game.turn_integer = game.turn_integer + 1
</script>
</turnscript>
</asl>

The Pixie
mblann wrote:I'm using the windows version of Quest.
I have an object: "book of matches" that can be used to light torches, cigarettes, etc.

I'm wanting the matches to decrease in number as they are used. So I created the following when you "look at matches"
"There are " + book of matches.count + " matches left."
Where "book of matches.count" = 3 (or 4 or whatever)
How do I add the code or expression or whatever it's called to when a match is used, it reduces the count by one?
I know it should be something like "book of matches.count = book of matches.count -1" but I don't know the exact syntax and where to put it.
Do I HAVE to put it in the code itself or is there an easier way using Quest interface?

Thanks in advance for your help!!!

Mark

Looks to me like you are almost there, and you do have the syntax right. As to where to put it that depends on how the matches will be used. I think what I would do is create a "strike;light" verb for the box, and put the code in there. Add "match" as an alternative name for the object. Should then accept STRIKE MATCH.

You could also call the strike script from USE section ( do(box of matches, "strike") ), to cover USE MATCHES.

If you want any more details, just ask.

mblann
Thanks for the great suggestions! Look forward to trying it out.

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

Support

Forums