Login
Remember
IF Answers
Ask a Question

# Online version of Quest: How do I change the value of Status Attributes?

0 votes
233 views
asked Sep 3 in Authoring by brains (3 points)

First of all, I know that someone already asked a question about changing status attributes here, but the answers seemed to be specifically for the Windows desktop version of Quest, which I cannot access.

Initially, I was having difficulty with setting up a Status Attribute for "cash," but hegemonkhan's answer to this question helped me with that. Many thanks to him.

But now that I've set up my status attribute for cash, I'm not sure how to change the value of the variable. I want my player to start the game with $20, so I set the variable "player.cash" to 20, created a new string dictionary for "player.statusattributes," and then added "cash" to that string dictionary. Like so:

That worked. On the right sidebar of my game, in the "status" panel, it says "Cash: $20." Then, in an attempt to figure out how to increase the "player.cash" value during gameplay, I tried to create the command "increase cash" which I wanted to simply add $20 to the player's "cash" value. But I didn't really know how to do that, as you can see:

My attempt probably looks extremely laughable to those who actually know what they're doing. Can anyone help me figure out how to increase the "player.cash" variable in a way that is compatible with the online version of Quest?

- quest
- status-attribute
- status-attributes
- set-variables
- setting-variables

## 1 Answer

0 votes
answered Sep 5 by hegemonkhan (161 points)
selected Sep 5 by brains
Best answer

I don't know if Commands work in Gamebook version (I've not really used Gamebook yet), but otherwise, your Command should work (note that Commands require the person playing the game to type in something that follows the syntax rules of your Command's 'pattern' text box's contents ~ see below for example)

and more importantly, your actual Scripts within your Command, are correct, that's how you adjust your Attributes, you got it correct, already, hehe:

'set a variable or attribute' Script -> [expression] or choose the correct drop down boxes for what you want (I don't know them that well, thus I cheat using the [expression] to type in the code, hehe) -> (see below)

    Addition:

    set variable Object_name.Attribute_name = [expression] Object_name.Attribute_name + Value_or_Expression

    example1: set variable player.strength = [expression] player.strength + 5
    example2: set variable player.damage = [expression] player.strength + player.endurance

    Subtraction:

    set variable Object_name.Attribute_name = [expression] Object_name.Attribute_name - Value_or_Expression

    example1: set variable player.strength = [expression] player.strength - 5
    example2: set variable player.strength = [expression] player.damage - player.endurance
    example3: set variable player.endurance = [expression] player.damage - player.strength

    Multiplication:

    set variable Object_name.Attribute_name = [expression] Object_name.Attribute_name * Value_or_Expression

    examples: you get the idea...

    Division:

    set variable Object_name.Attribute_name = [expression] Object_name.Attribute_name / Value_or_Expression

    examples: you get the idea...

    Example of a complex Expression (no different than a math expression~equation~formula):

    player.physical_damage = (player.weapon.physical_damage + player.weapon.physical_damage * (player.strength / 100)) - (orc.armor.physical_defense + orc.armor.physical_defense * (orc.endurance / 100))

http://docs.textadventures.co.uk/quest/elements/command.html

Command Pattern (Type A): activator_text~string~word
example Command Pattern: info
// person types in: info

    <command name="info_command">
      <pattern>info</pattern>
      <script>
        ClearScreen
        msg ("Character Information:")
        msg ("")
        msg ("Name: " + player.alias)
        msg ("Sex: " + player.sex)
        msg ("Age Integer: " + player.age_integer)
        msg ("Age String: " + player.age_string)
        msg ("Height: " + player.height)
        msg ("Weight: " + player.weight)
        msg ("Strength: " + player.strength)
        // etc Character (player) Attributes displayment
        wait {
          ClearScreen
        }
      </script>
    </command>

Command Pattern (Type B): activator parameter
example Command Pattern: info #object#
~OR~
example Command Pattern: info #text#
// person types in: info player
// or, person types in: info HK
// or, person types in: info orc
// or, person types in: info brains
// I'm not going to get into Command Parameters here though...

Command Pattern (Type C): activator parameter1 grammer parameter2
example Command Pattern: mix #object1# and #object2#

and infinite other combinations types...

the 'get input' Script and Commands, are the two ways to get~use inputs from the person playing the game. Also, there's the 'show menu' (pop up window) or 'showmenu' (in-line~text), which gets the selection made by the person playing the game, which is a type of input by the person playing the game too, just not an input that they type in like with 'get input' Script and Commands.

But, Commands, aren't the only means of Scripting... (Verbs, Page Type: [script] or [text+script], Commands, Functions, an Object's Script Attributes, Turnscripts, Timers, Object Types, and etc)

also, this link may be of help to you, as well:

http://ifanswers.com/1091/using-gamebook-style-game-create-game-wide-variables-track

ask if you need help with understanding any of it.

lastly, and very importantly !!!

the status pane (your statusattributes displayment), doesn't update to your new adjusted Attributes' values on its own...

to force the status pane (your statusattributes displayment) to update to the current~correct values:

(I don't know if all of these are available in Gamebook)

1. (global) Turnscript ( http://docs.textadventures.co.uk/quest/elements/turnscript.html )

2. the special 'changed' Script ( http://docs.textadventures.co.uk/quest/guides/running_a_script_when_an_attribute_changes.html )

3. UpdateStatusAttributes ( http://docs.textadventures.co.uk/quest/asl_requirements.html )

commented Sep 5 by brains (3 points)
Thank you very much! I understand everything except the last part. So, in order to make the status pane display the correct value "player.cash", I need to create a turn script that updates the status pane, correct? How do I make the turn script do that? I didn't understand links 2 and 3.
I'm sorry about my lack of knowledge. I'm very new to this.
commented Sep 5 by hegemonkhan (161 points)
edited Sep 5 by hegemonkhan
my apologies, that's not quite what I meant.
------
the game~quest engine doesn't update the status pane to your Attributes' new values, unless you force it to do so, which can be done via those 3 methods I listed above.
for example:
let's say your initial strength is, for example:
as scripting code (easy to write~show, lol):
player.strength = 0
// GUI~Editor: set variable player.strength = [expression] 0
as 'creation' tag block code:
<object name="player">
<attr name="strength" type="int">0</attr>
</object>
// GUI~Editor: 'player' -> (add attribute)
and you got your built-in 'statusattributes' Stringdictionary Attribute set up correctly, for example (in 'creation' tag block code):
<object name="player">
<attr name="strength" type="int">0</attr>
<attr name="statusattributes" type="simplestringdictionary">strength = "Strength: " !</attr>
</object>
and the status pane correctly displays:
Strength: 0
then, during game play, you drink a strength potion, increasing your strength by 5:
player.strength = player.strength + 5
// GUI~Editor: 'strength_potion' Object -> 'drink' Verb -> run as script -> add new script -> 'set a variable or attribute' Script -> set variable player.strength = [expression] player.strength + 5
so, now your strength is:
playe.strength = 5
// player.strength = player.strength + 5
// player.strength = (old value of player.strength: 0) + (Value: 5)
// player.strength = (0) + 5 = 5
// player.strength = (new value of player.strength: 5)
// player.strength = 5
however, your status pane, hasn't updated, as it's still (now incorrectly) showing:
Strength: 0
when it should be showing:
Strength: 5
thus, we need to force the status pane to update, which is done via those 3 methods:
1. (global) Turnscript
2. the special 'changed' Script Attribute
3. UpdateStatusAttributes
-----------
What is a Turnscript?
you're familiar with Verbs, which let you create an action~event (scripting: adding scripts) for your specific Object, which is activated via either on the left side's 'hyperlink' text in its big text pane or a 'button' on the the right side's panes ('Objects and Places' and~or 'Inventory' Panes).
/*
Actually, the GUI~Editor's 'Verbs' are really just Script Attributes added to your Objects (look at~in the code ~ code view mode), along with some other coding needed for it to work properly, and in having its hyperlink and button.
*/
A Function is the same thing as a Verb, in that it allows you to do scripting (add scripts, which are your actions~events), but it is not tied to a specific Object, nor creates the hyperlink text, nor creates the 'button' on the right side's panes, and it has some other useful features for scripting too.
well, finally, a Turnscript is an 'always running~executing~firing~activating' Function (depending on how you set it up, anyways).
--------
global vs local Turnscripts:
a global Turnscript is not tied to a specific room, where ever you are in your in-game playing progression (whatever~any room you're currently in), it's in-effect (if it's in effect, if it's currently set up as being in effect).
a local Turnscript:
it will only effect you if you're currently within that specific room that you placed~added the Turnscript to (and only if it's in effect too). So, if you're in any other room, the Turnscript in-effect is off (not running~firing~executing~activating), even if it is currently set as being on.
--------
so, usually for updating your status pane (for a 'normal~simple' game design), you want to create a global Turnscript, as you want your status pane to be up-to-date all the time, regardless of what room you're in, within your game play.
------------
how to do the (global) Turnscript in the GUI~Editor:
on the left side, in the 'tree of stuff', click on the upper-left-most 'Objects', so that it is highlighted (this ensures that the added Turnscript will be global, and not locally put into a specific room).
then (one way of doing it), at the top of the screen, in the menu bar, click on 'Add', and select 'Turn Script'
now click on the 'Turn Script' that has now been created on the left side's tree of stuff, so it is highlighted, and on its right side details, set it up (see below example)
Name (skinny text box): global_turnscript // or whatever you want to call~name~label it as
[ ] Enabled check box: it explains it already, if this is checked in, your Turnscript is 'on~enabled' (it is executing~running~activating~firing, and because it is a Turnscript, it is constantly, after every internal engine code turn event, doing so)
Script: you add your scripts that you want
for our updating of the status pane, using our example here:
.... wow, big oopsy... laughs
actually, you don't need to do this for updating an Integer Attribute like our 'strength' in this example...
I got confused with doing the 'Life: 999/999' status pane display, which does require the use of one of these 3 methods.
--------
so, you do NOT need to add~create a Turnscript (unless you do want to do, for example: Life: 999/999 in your status pane).
all you need for it to update your Integer Attribute (such as 'strength' in this example):
<object name="player">
<attr name="strength" type="int">0</attr>
<attr name="statusattributes" type="simplestringdictionary">strength = "Strength: " !</attr>
</object>
or via the GUI~Editor:
'player' Player Object -> 'Attributes' Tab -> Status Attributes -> Add -> (see below)
Attribute Name: strength
Format String (Value_or_Expression): "Strength: " !
~ OR (I don't know if you need the double quotes or not) ~
Format String (Value_or_Expression): Strength: !
the ' ! ' will be replaced automatically by the game engine by whatever your current strength value is
so, if our: player.strength = 100
it'll display~output~show in the status pane during game paly:
Strength: 100
commented Sep 5 by hegemonkhan (161 points)
edited Sep 5 by hegemonkhan
here's a link to help you out with using (more complex) statusattributes, like 'Life: 999/999', ask if you need any help with it or don't understanding stuff:
http://forum.textadventures.co.uk/viewtopic.php?f=10&t=5387&hilit=statusattributes
this is actually a step-by-step guide to making a sample game, where you can play-test that it works.
it uses the special 'changed' Script Attributes, as they're fast, easy, and simple to do and understand, once you've been explained how they work, which I'm doing right now for you, hehe:
conceptually, this is what it does:
when this Attribute's Value changes, run~do~execute~activate these scripts
an example:
the Attribute's Name: strength
the Attribute's Type: int (integer)
the Attribute's initial Value: 0
whenever the Attribute (strength) in 'changedAttribute' (changedstrength) changes, then the script(s) are run (the 'msg' Script is run).
'attr' is the required syntax, but it just means 'attribute' (and the same with 'int', which just means: integer), to help you with reading the 'creation' tag block code below:
<object name="player">
<attr name="strength" type="int">0</attr>
<attr name="changedstrength" type="script">
msg ("Your strength is now: " + player.strength)
// let's pretend we already changed our strength to 100 (such as from drinking a super strength potion during game play)
// displays~outputs during game play: Your strength is now: 100
</attr>
</object>
if it doesn't work... then you may need to use the alternative (old) syntax structure:
<object name="player">
<attr name="strength" type="int">0</attr>
<changedstrength type="script">
msg ("Your strength is now: " + player.strength)
// let's pretend we already changed our strength to 100 (such as from drinking a super strength potion during game play)
// displays~outputs during game play: Your strength is now: 100
</changedstrength>
</object>
commented Sep 5 by brains (3 points)
Thank you so much for showing me all this!!! The only problem is that in the web version of Quest, there is no attribute editor for objects :( It says so right here in the tutorial:
http://docs.textadventures.co.uk/quest/tutorial/custom_attributes.html
So there is no "attributes" tab when you click on "player" or any other object.
I was hoping that there would be some other way to do it in the web version... I'm sorry, I feel bad since you did all this explaining. Maybe what I'm trying to do is not possible in the web version of Quest. You've been very helpful though! If I ever get Windows, I will immediately download the desktop version.
commented Sep 6 by hegemonkhan (161 points)
edited Sep 6 by hegemonkhan
HK edit:
ach... I'm confusing myself... lol
you're using the web~online version, but I can't find whether you're using the Gamebook or Text Adventure version ??? (I've been assuming you're using the Gamebook version... I always do this for some reason when people say 'web~online' version, which can be either Text Adventure or Gamebook... I get confused between 'online~web' and 'Gamebook' laughs, no idea why I always associate them as the same thing, when they're not, lol.
I've never used the web~online version... so I don't know what's available with it, you may be truly limited, or maybe not (just needing to do stuff in a different way), I just don't know, as I've never tried the web~online version at all.
maybe you can tell me what is available to you with the web version, and I can then tell you if you can use any of that to work with ~ use Attributes (inlcuding the 'statusattributes' Stringdictionary Attribute), or not.
----------------------
you can still do all of this, but you got to do the 'Page Type: [script] or [text+script]', and then it's pretty much otherwise the same as has been posted here.
for 'non-statusattributes' Attribute creation~setting, re-setting, altering~changing, etc, you can either do:
1. the 'set a variable or attribute' Script
this has been done in the above mass of text wall posts, lol.
run as script -> add new script -> variables -> 'set a variable or attribute' Script -> (see below)
set variable Object_name.Attribute_name = [expression] Value_or_Expression
for example:
set variable player.strength = [expression] 100
~OR~
set variable game.strength = [expression] 100
--- IMPORTANT: for Attributes, in the Gamebook, you only have two Objects that you can attach~add Attributes to: 'player' and 'game'
2. the 'set' Script (see below for it)
-------
if you mean specifically for the 'statusattributes' Stringdictionary Attribute, you're going to have to do it this way (I'm not sure how to do it via the Gamebook's GUI~Editor's script choices, but hopefully you can figure it out):
dictionary add~remove
for example (I hope this works, lol):
dictionary add (game.statusattributes, "strength", "Strength: " !)
~OR~
dictionary add (player.statusattributes, "strength", "Strength: " !)
http://docs.textadventures.co.uk/quest/using_dictionaries.html
http://docs.textadventures.co.uk/quest/scripts/dictionary_add.html
http://docs.textadventures.co.uk/quest/scripts/dictionary_remove.html
and there's also:
set ( http://docs.textadventures.co.uk/quest/scripts/set.html )
for example:
set (player, "statusattributes", strength = "Strength: " !)
or for 'non-statusattributes' Attributes:
set (player, "strength", 100)
the above is the same as this below:
player.strength = 100
which is the same as this (using the GUI~EDitor):
set variable player.strength = [expression] 100
commented Sep 6 by hegemonkhan (161 points)
edited Sep 6 by hegemonkhan
I just did a quick google search and found this old blog:
http://blog.textadventures.co.uk/2012/02/16/introducing-quest-webeditor-create-text-adventures-online-in-your-browser/
from this, it looks like you should be able to do all the scripting that you want...
(if you can do~manipulate your scripting, 'add scripts', then you can do~use~manipulate your Attributes with the scripting ~ which my mass of text wall posts cover in great detail ~ hopefully they're not over-whelming you nor are too technical~code heavy ~ if they are then just ask for help with anything you don't understand, instead of using the GUI~Editor as you would be with the offline~desktop version)
just make sure that you toggle off the 'simple mode', as this removes a lot (most) of the features~functionality, letting people get their feet wet, before they're presented with all of the features~functionality available in a normal (non simple mode) quest game making project.

## Related questions

- Quest: How do I change status attributes?
- Using the Gamebook style game, how do I create game-wide variables to track?
- In a Gamebook, how do I fix that the text processor is not working properly on my version of Quest (I think)?
- Quest: if's, exits, blocking and attributes
- I need help with attributes.

...