Reset Counter
Gladiusgobler
13 Jan 2014, 12:22Hello there everyone. First time posting here.
I have been searching around on these forums and Google and trying to solve it myself but I can't seem to do it.
I am using the book/online version of quest.
The issue I am having is resting a counter (Edit: Or setting it to 0). Depending on choices made the player gets a + or - ... sort of a reputation. However when the player dies I have them sent back a way to before they started getting this reputation so what I need to do is to be able to reset the counter.
Any help is appreciated and sorry if this has been answered before but I could find it any where!
Thanks!
I have been searching around on these forums and Google and trying to solve it myself but I can't seem to do it.
I am using the book/online version of quest.
The issue I am having is resting a counter (Edit: Or setting it to 0). Depending on choices made the player gets a + or - ... sort of a reputation. However when the player dies I have them sent back a way to before they started getting this reputation so what I need to do is to be able to reset the counter.
Any help is appreciated and sorry if this has been answered before but I could find it any where!
Thanks!


Pertex
13 Jan 2014, 21:03If the name of your counter is example then you can set a value with
Set variable game.example = [expression] 0
Gladiusgobler
14 Jan 2014, 11:40Hey, thanks for your reply.
If i type that into the script view part this happens.

If i run the game i get:
Error running script: Error compiling expression '[expression] 0': SyntaxError: Unexpected token "["; expected one of "NOT", "-", <INTEGER>, <REAL>, <STRING_LITERAL>, "True", "False", <HEX_LITERAL>, <CHAR_LITERAL>, "null", <DATETIME>, <TIMESPAN>, "(", <IDENTIFIER>, "if", or "cast"Line: 1, Column: 1
If i remove the "[expression]" and just leave the 0 then i get an error for the "Set variable game.kingOfBeasts".
When i just put this:

It doesn't recognize it as the counter variable, it just creates a new variable separate to the counter with the same name.
Thanks for any help
If i type that into the script view part this happens.

If i run the game i get:
Error running script: Error compiling expression '[expression] 0': SyntaxError: Unexpected token "["; expected one of "NOT", "-", <INTEGER>, <REAL>, <STRING_LITERAL>, "True", "False", <HEX_LITERAL>, <CHAR_LITERAL>, "null", <DATETIME>, <TIMESPAN>, "(", <IDENTIFIER>, "if", or "cast"Line: 1, Column: 1
If i remove the "[expression]" and just leave the 0 then i get an error for the "Set variable game.kingOfBeasts".
When i just put this:

It doesn't recognize it as the counter variable, it just creates a new variable separate to the counter with the same name.
Thanks for any help

HegemonKhan
14 Jan 2014, 12:09make sure that it is the same name as your created (added) counter attribute (of~within whatever Object), it shouldn't be creating a separate variable...
lower case and capitol case does matter:
HK.strength=100 is not the same as HK.Strength=100
and within the "Set a variable or attribute script, you should only be typing this (as you seemingly understand):
to the left of the equal sign: game.example
to the right of the equal sign: 0
also, you did create (add) the "counter" attribute to the "game" Object, correct?
if not, then just change:
to the left of the equal sign: Object_that_you_added_the_counter_attribute_to.example
to the right of the equal sign: 0
-------------
can you post your "counter" attribute coding (and it's object's coding block too) for me to look at?
---------------
oops... I'm blind... lol
you took off the "game."
so add it back on, and hopefully it will work now:
to the left of the equal sign: game.kingOfBeasts
to the right of the equal sign: 0
---------
In the GUI~Editor:
Run as Script -> Add a script -> Variables -> Set a variable or Attribute -> (set it up ~ type it in)
In Code, the syntax is this:
Object.Attribute = Value_or_Expression
HK.strength = 10
a "counter" (Addition Expression~Equation) Integer (int) Script:
HK.strength = HK.strength + 1
an Addition Integer Script:
HK.strength = HK.strength + 1 // new strength = 10+1 = 11
HK.strength = HK.strength + 5 // new strength = 10+5 = 15
HK.strength = HK.strength + 10 // new strength = 10+10 = 20
HK.strength = HK.strength + 100 // new strength = 10+100 = 110
a Subtraction Integer Script:
HK.strength = HK.strength - 10 // new strength = 10-10 = 0
a Multiplication Integer Script:
HK.strength = HK.strength * 10 // new strength = 10 * 10 = 100
a Division Integer Script:
HK.strength = HK.strength / 10 // new strength = 10 / 10 = 1
--------------------
In the GUI~Editor:
Run as Script -> Add a script -> Variables -> Set a variable or Attribute ->
example:
Setting the Attribute:
(Text Adventure mode)
Object: HK
Attribute Name: strength
Attribute Type: int (integer)
Attribute Value: 10
Operator: +, -, *, or /
Expression Value: 10
HK.strength = 10
(GameBook mode)
game.strength = 10
Addition:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength + 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength + 10
Subtraction:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength - 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength - 10
Multiplication:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength * 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength * 10
Division:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength / 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength / 10
Re-Setting the Attribute to Zero:
to the left of the equal sign: HK.strength
to the right of the equal sign: 0
to the left of the equal sign: game.strength
to the right of the equal sign: 0
lower case and capitol case does matter:
HK.strength=100 is not the same as HK.Strength=100
and within the "Set a variable or attribute script, you should only be typing this (as you seemingly understand):
to the left of the equal sign: game.example
to the right of the equal sign: 0
also, you did create (add) the "counter" attribute to the "game" Object, correct?
if not, then just change:
to the left of the equal sign: Object_that_you_added_the_counter_attribute_to.example
to the right of the equal sign: 0
-------------
can you post your "counter" attribute coding (and it's object's coding block too) for me to look at?
---------------
oops... I'm blind... lol
you took off the "game."
so add it back on, and hopefully it will work now:
to the left of the equal sign: game.kingOfBeasts
to the right of the equal sign: 0
---------
In the GUI~Editor:
Run as Script -> Add a script -> Variables -> Set a variable or Attribute -> (set it up ~ type it in)
In Code, the syntax is this:
Object.Attribute = Value_or_Expression
HK.strength = 10
a "counter" (Addition Expression~Equation) Integer (int) Script:
HK.strength = HK.strength + 1
an Addition Integer Script:
HK.strength = HK.strength + 1 // new strength = 10+1 = 11
HK.strength = HK.strength + 5 // new strength = 10+5 = 15
HK.strength = HK.strength + 10 // new strength = 10+10 = 20
HK.strength = HK.strength + 100 // new strength = 10+100 = 110
a Subtraction Integer Script:
HK.strength = HK.strength - 10 // new strength = 10-10 = 0
a Multiplication Integer Script:
HK.strength = HK.strength * 10 // new strength = 10 * 10 = 100
a Division Integer Script:
HK.strength = HK.strength / 10 // new strength = 10 / 10 = 1
--------------------
In the GUI~Editor:
Run as Script -> Add a script -> Variables -> Set a variable or Attribute ->
example:
Setting the Attribute:
(Text Adventure mode)
Object: HK
Attribute Name: strength
Attribute Type: int (integer)
Attribute Value: 10
Operator: +, -, *, or /
Expression Value: 10
HK.strength = 10
(GameBook mode)
game.strength = 10
Addition:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength + 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength + 10
Subtraction:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength - 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength - 10
Multiplication:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength * 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength * 10
Division:
to the left of the equal sign: HK.strength
to the right of the equal sign: HK.strength / 10
to the left of the equal sign: game.strength
to the right of the equal sign: game.strength / 10
Re-Setting the Attribute to Zero:
to the left of the equal sign: HK.strength
to the right of the equal sign: 0
to the left of the equal sign: game.strength
to the right of the equal sign: 0
Gladiusgobler
14 Jan 2014, 13:12Edit: I deleted this post as it was now irellivent.
I have created the variable the way you suggested and manually increased the counter in the code part, and this works with resets and all.
Thanks allot for your help, much appreciated
I have created the variable the way you suggested and manually increased the counter in the code part, and this works with resets and all.
Thanks allot for your help, much appreciated


Pertex
14 Jan 2014, 13:58No you have to do this:

A counter is saved in the game object so the name of the counter is example but the variable is game.example. So to print the variable you must

A counter is saved in the game object so the name of the counter is example but the variable is game.example. So to print the variable you must
msg (game.example)
Gladiusgobler
14 Jan 2014, 14:02Pertex wrote:A counter is saved in the game object so the name of the counter is example but the variable is game.example.]
Ahh i see, thankyou

HegemonKhan
14 Jan 2014, 20:49just to add to Pertex' explanation:
I haven't used the GameBook mode, but it seems that it only has the "game" (Game) Object for a single Object to work with.
so, you'll likely always have to be using:
To Create, Set, and Apply:
game.Attribute = Value_or_Expression
(Object.Attribute = Value_or_Expression)
To Display:
(for example, let's set it as: game.strength = 10)
In the GUI~Editor:
Run as script -> Add a script -> Output -> Print a Message [EXPRESSION] -> game.Attribute
// it displays during game play: 10
~OR~
Run as script -> Add a script -> Output -> Print a Message [EXPRESSION] -> "You have " + game.Attribute + "strength."
// it displays during game play: You have 10 strength.
In Code:
msg (game.Attribute)
// it displays during game play: 10
msg ("You have " + game.Attribute + "strength.")
// it displays during game play: You have 10 strength.
--------------
there's two reasons for this:
Object.Attribute
1. by "attaching" the Attribute to the Object, you "save" this property, and thus you can "load" (apply) it anywhere in Scripts ("Print a message [EXPRESSION]", "Set a variable or attribute", and etc) via: Object.Attribute or Object.Attribute=Value_or_Expression, SO LONG AS THE OBJECT STILL EXISTS OF COURSE (lol).
2. let's use the text adventure mode as an example for this:
Object (1): game
Attribute (1) Name: year
Attribute (1) Type: int (Integer)
Attribute (1) Value: 2014
Object (2): HK
Attribute (1) Name: year
Attribute (1) Type: int (Integer)
Attribute (1) Value: 1996 (I wish I was born in this year, being 18 again, lol)
Object (3): gladiusgobler
Attribute (1) Name: year
Attribute (1) Type: int (Integer)
Attribute (1) Value: 1000 (I have no idea your age, so let's make you over a century old, lol. You're an elder~ancient vampire or an immortal~highlander or something, lol)
if I were (if it could be done) to just use:
msg (strength)
than the poor quest game engine can't compute, as it doesn't know WHAT strength value to use:
2014, 1990, or 1000
think about it this way: okay I got this "strength" Attribute, but it is "strength"... OF WHAT ??? hence: Object.Attribute
-----------
Set a variable or attribute:
Attribute ("save" so you can then "load" ~ use it at any time or any where, via "attaching" it to an Object):
Object.Attribute=Value_or_Expression
example_1: HK.strength = 25
example_2: HK.strength = HK.strength * 4
Variable (it can ONLY be used within its own script that it was set in. Notice how it is NOT "attached" to an Object):
Variable = Value_or_Expression
example_1: result = "red"
example_2: you_go_first = true (or false)
example_3: handled = true (or false)
example_4: counter = counter + 1
example_5: x = x + 5
Displaying a variable or attribute:
Attribute:
msg (Object.Attribute)
example_1: msg (player.strength)
example_2: msg (player.alias + " has " + player.strength + "strength.") // displays for an example: HK has 100 strength.
Variable:
msg (Variable)
example_1: msg (passcode) // displays for an example: 1234
example_2: msg ("The passcode is " + passcode + ".") // displays for an example: The passcode is 1234.
I haven't used the GameBook mode, but it seems that it only has the "game" (Game) Object for a single Object to work with.
so, you'll likely always have to be using:
To Create, Set, and Apply:
game.Attribute = Value_or_Expression
(Object.Attribute = Value_or_Expression)
To Display:
(for example, let's set it as: game.strength = 10)
In the GUI~Editor:
Run as script -> Add a script -> Output -> Print a Message [EXPRESSION] -> game.Attribute
// it displays during game play: 10
~OR~
Run as script -> Add a script -> Output -> Print a Message [EXPRESSION] -> "You have " + game.Attribute + "strength."
// it displays during game play: You have 10 strength.
In Code:
msg (game.Attribute)
// it displays during game play: 10
msg ("You have " + game.Attribute + "strength.")
// it displays during game play: You have 10 strength.
--------------
there's two reasons for this:
Object.Attribute
1. by "attaching" the Attribute to the Object, you "save" this property, and thus you can "load" (apply) it anywhere in Scripts ("Print a message [EXPRESSION]", "Set a variable or attribute", and etc) via: Object.Attribute or Object.Attribute=Value_or_Expression, SO LONG AS THE OBJECT STILL EXISTS OF COURSE (lol).
2. let's use the text adventure mode as an example for this:
Object (1): game
Attribute (1) Name: year
Attribute (1) Type: int (Integer)
Attribute (1) Value: 2014
Object (2): HK
Attribute (1) Name: year
Attribute (1) Type: int (Integer)
Attribute (1) Value: 1996 (I wish I was born in this year, being 18 again, lol)
Object (3): gladiusgobler
Attribute (1) Name: year
Attribute (1) Type: int (Integer)
Attribute (1) Value: 1000 (I have no idea your age, so let's make you over a century old, lol. You're an elder~ancient vampire or an immortal~highlander or something, lol)
if I were (if it could be done) to just use:
msg (strength)
than the poor quest game engine can't compute, as it doesn't know WHAT strength value to use:
2014, 1990, or 1000
think about it this way: okay I got this "strength" Attribute, but it is "strength"... OF WHAT ??? hence: Object.Attribute
-----------
Set a variable or attribute:
Attribute ("save" so you can then "load" ~ use it at any time or any where, via "attaching" it to an Object):
Object.Attribute=Value_or_Expression
example_1: HK.strength = 25
example_2: HK.strength = HK.strength * 4
Variable (it can ONLY be used within its own script that it was set in. Notice how it is NOT "attached" to an Object):
Variable = Value_or_Expression
example_1: result = "red"
example_2: you_go_first = true (or false)
example_3: handled = true (or false)
example_4: counter = counter + 1
example_5: x = x + 5
Displaying a variable or attribute:
Attribute:
msg (Object.Attribute)
example_1: msg (player.strength)
example_2: msg (player.alias + " has " + player.strength + "strength.") // displays for an example: HK has 100 strength.
Variable:
msg (Variable)
example_1: msg (passcode) // displays for an example: 1234
example_2: msg ("The passcode is " + passcode + ".") // displays for an example: The passcode is 1234.