I want to make stats for the PC, but I can't figure out how! [SOLVED]
ThunderKid
01 May 2018, 19:48To preface: I'm extremely new to Quest (as in I'm making my first ever game right now with it) and I have absolutely no background in JavaScript (or really...any kind of programming) though my girlfriend does and she's been helping me as much as she can lol.
I'm using 'gamebook' type, since what I'm creating is an interactive novel and I'm not comfortable enough to mess around with Squiffy yet.
Anyway, what I'm looking to do is give the PC personality stats (brave, kind etcetc) by choosing different paths, and then have more paths along the story line open up based on how high a personality trait is.
As an example:
"Hello! How are you doing?"
- Fuck you. (+1 mean)
- Hi! I'm doing well, how about yourself? (+1 Nice)
[a page in the future]
"Do you want to go on a roller coaster?"
- No, I'm scared of them.
- Sure! Sounds like fun.
- (Only shows up if you have at least 1 mean point) Of course I don't! Who even invited you, anyway?!
What my girlfriend thought would work (and me, because it makes sense) would be to add a function with a script that says: "If player has seen page x Increase counter kind" with return type being "Integer". And then creating another function with a script that says: "If counter kind >= number 1 add page link from page y to page z" with no return type.
I've tried what feels like every combination of things to get this to work, but it doesn't. And I haven't found anything on the help page about it so far as I can tell, or any forums (feel free to link one if there is one I missed!). I've tried every return type for both functions, and I've tried putting the functions on the individual pages they apply to, but I can't get any of it to work.
Thank y'all so much in advance!

Raist
01 May 2018, 20:48Hello ThunderKid,
Your girlfriend's logic is sound. You would be adding an attribute to the Player object in Quest. Here's how it can work:
On the Player object, go to the Attribute tab and add all the attribute(s) you wish to track.
At the top of the Attribute tab, you will also see Status Attributes. This is where you take the attribute(s) you just added to the player and assign the formatting (how the value is displayed).
Go to the Game object and select the Player tab. At the bottom you will see: Player object status attributes (these are a repeat of the Status Attributes from the Attribute tab on the player).
After that it is just increasing/decreasing the object counter on the player for whatever you are tracking.
Kindness
Player object -> Attribute tab:
- (At the bottom) Add Attribute kindness, with an Integer value (this becomes the "counter" you will increase/decrease).
- (At the top) Add Status Attribute kindness with value of "Kindness: !" (the ! represents the variable for the value).
Game object - Player tab:
- (At the bottom) Add Player object status attribute kindness with value of "Kindness: !" (again the ! represents the variable for the value).
All of that above sets up and displays the values for the player that you (the author) set up to track.
hegemonkhan
02 May 2018, 00:05@ Raist:
the 'Game Book' version of quest doesn't have the Attribute (and etc) Tabs that are within the 'Text Adventure' version of quest
(lazy, putting the whole post in a code box, so the backspaces show up and/or for whatever other possible issues, lol)
so, you got to create and manipulate/adjust/change your 'Attribute' VARIABLES via scripting
------------
in quest, there's generally 3 type of VARIABLES (keeping this simple):
VARIABLES:
1. a 'Variable' VARIABLE: these are local VARIABLES, they are destroyed upon its container's (an 'Element' in quest, quest's OBJECTS: Objects, Exits, Functions, Commands, Turnscripts, Timers, and etc) scripting finishing and its scope (usage) is limited to only its container's scripting, so it doesn't exist (can't be used) outside of its container's scripting
2. an 'Attribute' VARIABLE: these are global VARIABLES, they can be used anywhere, as they're "permanent" (so long as the Object containing them, exists or still exists)
3. an/a 'Argument/Parameter' VARIABLE: these deal with Functions, Commands, and Delegates+Script_Attributes+Objects
---------
also, unlike the 'Text Adventure', the 'Game Book' only has two Objects (aside from its: Pages / Page Objects) that you can use for Attributes:
1. the special 'game' Object
2. the default-named 'player' Player Object (if you change its name, then you got to use that new name within the scripting, instead of using 'player' as seen/used within my scripting examples)
-------
to do scripting:
'WHATEVER PAGE' -> 'Page' Tab -> Page Type: [SCRIPT] or [SCRIPT+TEXT]
--------
Attribute Scripting:
creation/setting and/or manipulating/changing/adjusting/re-setting/over-riding/etc an 'Attribute' VARIABLE:
Script: add new script -> 'variables' category/section -> 'add a variable or attribute' Script -> (see below)
GENERIC SYNTAX via GUI/Editor:
set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION
**********
I'm using the '[EXPRESSION]' script option, as I'm not familar with the GUI/Editor's specific options, so I'm cheating by using the '[EXPRESSION]' option, as it lets me code in directly what I want to do, lol
but you can use the specific script options instead
**********
for examples:
set variable game.state = [EXPRESSION] 0 // an Integer Attribute due to having an Integer Value (quest parses the type of the Value to determine its type of Attribute)
set variable player.strength = [EXPRESSION] 0 // an Integer Attribute due to having an Integer Value (quest parses the type of the Value to determine its type of Attribute)
set variable player.strength = [EXPRESSION] 100 // it's Value is now '100', it changed from its previous Value of '0' to '100'
set variable Page1.visited = [EXPRESSION] true // a Boolean Attribute
// or:
set variable Page1.visited = [EXPRESSION] false // a Boolean Attribute
set variable player.alias = [EXPRESSION] "HK" // a String Attribute
set variable game.introduction = [EXPRESSION] "Hi, welcome to my game, I hope you enjoy it, muwhaha!" // a String Attribute
set variable player.damage = [EXPRESSION] 40.3298 // a Double (Float / Floating Point / Decimal / Fractional) Attribute
set variable player.strength = [EXPRESSION] 100
set variable player.weapon_damage = [EXPRESSION] 50
set variable player.damage = [EXPRESSION] player.weapon_damage + player.weapon_damage * player.strength / 100
// player.damage = (50) + [ (50) * (100) / 100 ] = 100
set variable player.strength = [EXPRESSION] 0
set variable player.weapon_damage = [EXPRESSION] 50
set variable player.damage = [EXPRESSION] player.weapon_damage + player.weapon_damage * player.strength / 100
// player.damage = (50) + [ (50) * (0) / 100 ] = 50
---------
'if' Scripting:
Script: add new script -> 'scripts' category/section -> 'if' Script -> (see below)
FORMAT:
if [EXPRESSION] EXPRESSION
-> then -> add new script -> (WHATEVER Script)
example:
Script: add new script -> 'scripts' category/section -> 'if' Script -> (see below)
if [EXPRESSION] player.current_life_integer_attribute < 1
-> then -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)
// the '[MESSSAGE]' option is for TEXT only:
Print [MESSAGE] You're dead and/or were killed
// output:
// You're dead and/or were killed
// vs:
// Print [MESSAGE] "You're dead and/or were killed"
// output:
// "You're dead and/or were killed"
// or:
// the '[EXPRESSION]' can do: TEXT only, VARIABLE only, or TEXT+VARIABLE: (the example below is doing TEXT+VARIABLE):
Print [EXPRESSION] "You're dead and/or were killed, as can be seen by your 0 or negative current life stat: " + player.current_life_integer_attribute
// output (using for example: player.current_life_attribute = -89):
You're dead and/or were killed as can be seen by your 0 or negative current life stat: -89
// vs:
Print [EXPRESSION] "\"You're dead and/or were killed, as can be seen by your 0 or negative current life stat: " + player.current_life_integer_attribute + "\""
// output:
"You're dead and/or were killed, as can be seen by your 0 or negative current life stat: -89"
-------
if [EXPRESSION] Page.visited // quest understands this shortened form of 'Page1.visited' as being 'Page1.visited = true'
// vs (if FALSE):
// if [EXPRESSION] not Page.visited
// or:
// if [EXPRESSION] Page.visited = false
-> then -> add new script -> (WHATEVER script)
here's a link to guides on coding with quest:
http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c
(the 'attributes and if script' and the 'lists and dictionary attributes' guides are for a Text Adventure, but the scripting and Attributes-via-scripting, is the same for the Game Book, so it can still be helpful)
hegemonkhan
02 May 2018, 00:31(filler for getting my edited post, updated/posted)
forgot, the arithmetic scripting examples (sorry about that), so here they are:
(the 'add/decrease object counter' Script can only do addition/subtraction using only a value of '1', operations, so no different values, nor different arithmetic operations, but you can use the 'EXPRESSION' with the 'set a variable or attribute' Script to do whatever arithmetic operation and value you want)
Addition:
set variable player.strength [EXPRESSION] player.strength + 5
// or (a bit more complex expression using sum of two Attributes shown below, instead of just adding a simple value to it, as done in the scripting line above):
set variable player.maximum_life [EXPRESSION] player.strength + player.endurance
set variable player.minimum_life [EXPRESSION] player.maximum_life
Subtraction:
set variable player.strength [EXPRESSION] player.strength - 8
Multiplication:
set variable player.strength [EXPRESSION] player.strength * 3
Division:
set variable player.strength [EXPRESSION] player.strength / 2
Modulus (division, but it gets/finds the REMAINDER):
(for: cyclic, even/odd numbers, or factors/divisibility of any number)
set variable game.military_hours [EXPRESSION] game.hour_count % 24
set variable game.civilian_hours [EXPRESSION] game.hour_count % 12
set variable game.clock_minutes [EXPRESSION] game.minute_count % 60
// odd/even of numbers:
// (in code, lazy):
if (game.number % 2 = 0) {
msg ("The number: " + game.number + ", is even")
} else {
msg ("The number: " + game.number + ", is odd")
}
// or:
if (game.number % 2 = 1) {
msg ("The number: " + game.number + ", is odd")
} else {
msg ("The number: " + game.number + ", is even")
}
// factors/divisibility of a number:
// (in code, lazy):
if (game.number % 2 = 0) {
msg ("The number: " + game.number + ", is divisible by 2, or to say it differently, 2 is a factor of the number: " + game.number)
} else if (game.number % 3 = 0) {
msg ("The number: " + game.number + ", is divisible by 3, or to say it differently, 3 is a factor of the number: " + game.number)
} else if (game.number % 4 = 0) {
msg ("The number: " + game.number + ", is divisible by 4, or to say it differently, 4 is a factor of the number: " + game.number)
} else if (game.number % 5 = 0) {
msg ("The number: " + game.number + ", is divisible by 5, or to say it differently, 5 is a factor of the number: " + game.number)
}
// etc etc etc
BethNicole71
02 May 2018, 09:55I used Flags for on/off objects and Counters for variable value objects
If statements work well with these.
http://benico.biz/benicoadventures/index.html
JenniferCampbell
02 May 2018, 13:50Assign the attributes to the 'player' object using a page set to page type 'script' or 'script + text'.
Format your variables like so:
player.kindness
player.meanness
But realize that 'kind' and 'mean' are really just opposite ends of the same spectrum, so only one variable is required. Then you test the level for meanness by by looking for the variable to be below some value, and test for kindness by looking for the variable to be above some value.
You can do this right in the text processor (the text window):
{if player.kindness<7:3. Of course I don't! Who even invited you, anyway?!}
There may be a text processor function that checks to see if the player object has been to a particular page, but I can't find it right now. Just set a flag on the page you need visited if it only needs to be visited once to work. If multiple visits to the page will increase or decrease the attribute, use the 'set variable' script:
player.kindness = player.kindness + 1
OR player.kindness = player.kindness - 1
Good luck!
hegemonkhan
02 May 2018, 15:06example of scripting amount ranges (using a Text Adventure coding example, but the concept is the same, just got limited Objects to work with when using the Game Book, unlike a Text Adventure):
(alternative to using the text processor commands that Jennifer Campbell explains/shows in her post)
(direct coding/scripting, not showing/doing the GUI/Editor scripting, lazy)
// max to min:
if (test.score > 89) {
test.grade = "A"
} else if (test.score > 79) {
test.grade = "B"
} else if (test.score > 69) {
test.grade = "C"
} else if (test.score > 59) {
test.grade = "D"
} else {
test.grade = "F"
}
// you can do this too (it's nearly the same thing), but it's more operations, though not as confusing and/or it's more exact/precise:
// max to min:
if (test.score >= 90) {
test.grade = "A"
} else if (test.score >= 80) {
test.grade = "B"
} else if (test.score >= 70) {
test.grade = "C"
} else if (test.score >= 60) {
test.grade = "D"
} else {
test.grade = "F"
}
// --------------------------------------------------------
// min to max:
if (test.score < 60) {
test.grade = "F"
} else if (test.score < 70) {
test.grade = "D"
} else if (test.score < 80) {
test.grade = "C"
} else if (test.score < 90) {
test.grade = "B"
} else {
test.grade = "A"
}
// or:
// min to max:
if (test.score <= 59) {
test.grade = "F"
} else if (test.score <= 69) {
test.grade = "D"
} else if (test.score <= 79) {
test.grade = "C"
} else if (test.score <= 89) {
test.grade = "B"
} else {
test.grade = "A"
}

ThunderKid
02 May 2018, 23:27I've actually figured out the problem, but oh my gosh thank you all so much! And to be honest, a lot of the code here doesn't make much sense to me but I'm learning.
Turns out, my problem was that I was putting it under the functions tab, instead of on individual pages, thus putting the code at the end of the script where it doesn't actually do anything when you play. The counters also don't work if you put them directly on the pages that would effect the counter. So I put them on the pages directly after the one that effects the counter, with the page being "text+script".
The basic code I'm using for this looks like:
if (HasSeenPage(Page1)) {
ChangeCounter ("mean", 1)
}
As for needing a "mean level 1" to go down a different path, what I've done is create the mean path link on the relevant page, and then use the following script to hide it if mean is <1 since I can't seem to get the "add page" script to work. But honestly this is perfectly fine, and does what I need it to do. This one works when you put it directly on the page it's effecting.
if (GetInt(game, "mean") = 1) {
RemovePageLink (Page1, Page2)
}
Also, with a lot of help from my girlfriend, here's a way to cap attribute levels. Instead of putting the first script I posted you'll do this:
if (HasSeenPage(Page1)) {
if (GetInt(game, "mean") = 10) {
ChangeCounter ("mean", 0)
}
else if (GetInt(game, "mean") <= 9) {
ChangeCounter ("mean", 1)
}
}
Hope this helps someone with no javascript background trying to make something with Gamebook!