Setting and Adjusting Visible Attributes in Gamebooks
SpamChowder
10 Sept 2016, 20:29Heya! I'm fairly new to textadventures, but I really want to add a system in my game where certain decisions impact your personality, which is represented by a few "personal attributes". The idea is that toward the end of the game you will receive a certain message depending upon the personality, or "personal attributes", that you have developed. The problem is that I don't know how to make these attributes visible to the player, and to be perfectly honest, I'm not even sure if the attributes are actually there. I know it's not a simple thing to just add attributes, but I really want to do it for this game. Could anyone offer me some advice on how to implement this thing?
hegemonkhan
11 Sept 2016, 06:35creating your Attributes at the start of your game:
'game' Game Object -> 'Scripts' Tab -> 'start' Script -> (see below)
run as script -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below, an example, repeat as needed)
creation and setting initial value (of 3 Attributes for this example):
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] 0
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_2 = [EXPRESSION] 0
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_3 = [EXPRESSION] 0
-------------------------------------
to do scripting on your Pages:
'whatever' Page Object -> Page Type: [SCRIPT] or {TEXT+SCRIPT}
run as script -> add new script -> (set it up)
--------------------------------------
to display your Attributes, an example:
run as script -> add new script -> 'output' section/category -> 'print a message' Script -> (see below)
print [EXPRESSION] "NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1: " + player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1
print [EXPRESSION] "NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_2: " + player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_2
print [EXPRESSION] "NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_3: " + player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_3
// output:
NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1: NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1
NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_2: NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_2
NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_3: NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_3
---------------
to do arithmetic:
run as script -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below, an example, repeat as needed)
Addition:
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 + 1
// (0) + 1 = 1
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 + 5
// (if this script was after/below the script above): (1) + 5 = 6
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 + 68
// (if this script was after/below the script above): (6) + 68 = 74
Subtraction:
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 - 1
// (since I started at 0): (0) - 1 = -1
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 - 3
// (let's say I started at '100' instead of '0'): (100) - 3 = 97
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 - 17
// (if this script was after/below the script above): (97) - 17 = 80
Multiplication:
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 * 4
// you get the idea now, hopefully
Division (normal division: finds/gets the quotient):
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 / 2
Modulus (division, but finds/gets the REMAINDER):
set variable player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 = [EXPRESSION] player.NAME_OF_YOUR_PERSONALITY_ATTRIBUTE_1 % 10
---------
you can see here for more details on using Attributes and the 'if' Script:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
--------
P.S.
the GameBook version has only TWO Objects for your Attribute usage:
'player' and 'game'
// examples in code:
player.strength = player.strength + 5
game.strength = game.strength + 5
this is the same as the GUI~Editor's:
set variable player.strength = [EXPRESSION] player.strength + 5
set variable game.strength = [EXPRESSION] game.strength + 5
----------
P.S.S.
also, there's the other data/Attribute Types (not just the int---integer, which I've used in this post's examples above):
string, double (decimal numbers: 0.0, 4.123, 9.000000001, -0.382, -100.0), boolean (true/false), object, lists, dictionaries, etc
// well, maybe not the 'object' Attribute/data Type for GameBook.... not sure if this is possible or not with/for it
-------------
P.S.S.S.
to re-set/change/alter (non-arithmetic usage) your Attributes:
run as script -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below, an example, repeat as needed)
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] 100
// = 100
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] 0
// = 0
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] 100
// = 100
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] 50
// = 50
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] 29
// = 29
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] -84
= -84
set variable player.NAME_OF_YOUR_ATTRIBUTE_1 = [EXPRESSION] 0
// = 0
a complex expression, example:
set variable player.damage = [EXPRESSION] 1
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
// 50 + 50 * 100 / 100 = 50 + 50 = 100
-----
set variable player.damage = [EXPRESSION] 1
set variable player.strength = [EXPRESSION] 50
set variable player.weapon_damage = [EXPRESSION] 50
set variable player.damage = [EXPRESSION] player.weapon_damage + player.weapon_damage * player.strength / 100
// 50 + 50 * 50 / 100 = 50 + 25 = 75
----------
a complex expression of a String Attribute:
set variable player.alias = [EXPRESSION] "HK"
set variable player.age_integer = [EXPRESSION] 18 // I wish I was still 18
set variable player.age_string = [EXPRESSION] "adult"
set variable player.sex = [EXPRESSION] "male"
set variable player.race = [EXPRESSION] "human"
set variable player.class = [EXPRESSION] "warrior"
set variable player.information_string = [EXPRESSION] player.alias + " is a " + player.age_integer + " year old " + player.age_string + " " + player.sex + " " + player.race + " " + player.class + "."
// output:
HK is a 18 year old adult male human warrior.
hegemonkhan
11 Sept 2016, 07:14@ moderators:
this post can be deleted (I made a thread in the site announcements and feedback about this issue)
testing post, to see why I got a 'you can't post that' prevention message
it occurs when I write:
pla.yer.info
without the dot/period in 'player'