How do i change an integer on an attribute!?

Game_Cre8or
04 Dec 2018, 12:44

I'm tying to change the number I have on an attribute in a script, but I don't know how to!
Any help would be appreciated!!


K.V.
04 Dec 2018, 14:13

Hello.

Have you completed the tutorial? It is fairly short, and it teaches us how to do that and all sorts of other nifty stuff.

http://docs.textadventures.co.uk/quest/tutorial/creating_a_simple_game.html


To actually specifically help you:

http://docs.textadventures.co.uk/quest/using_attributes.html


hegemonkhan
04 Dec 2018, 17:58

(filler for getting my edited post, updated/posted)


creating an Attribute and setting its initial Value:

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

for some examples:

set variable player.alias = [EXPRESSION] "HK"
set variable game.introduction = [EXPRESSION] "Hi, welcome to my game, I hope you enjoy it!"
set variable game.state = [EXPRESSION] 0
set variable player.strength = [EXPRESSION] 100
set variable orc.dead = [EXPRESSION] false
set variable player.flying = [EXPRESSION] false


Directly Changing an Attribute's Value:

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

for some examples:

set variable player.alias = [EXPRESSION] "John Doe"
set variable game.introduction = [EXPRESSION] "In this game of mine, if you die, you die in real life, muwhahaha!"
set variable game.state = [EXPRESSION] 75
set variable player.strength = [EXPRESSION] 25
set variable orc.dead = [EXPRESSION] true
set variable player.flying = [EXPRESSION] true


Arithmetic'ally (Addition, Subtraction, Multiplication, Division, and Modulus) Changing an amount (Integer/Double) Attribute's Value:

Arithmetic Operator Symbols:

Addition: +
Subtraction: -
Multiplication: *
Division: /
Modulus (division, but it gets/finds/returns the REMAINDER): %

add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below)

set variable NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = [EXPRESSION] VALUE_OR_EXPRESSION

for some examples:

set variable player.strength = player.strength + 5

set variable player.maximum_life = [EXPRESSION] (player.strength + player.endurance) / 2

// doing it directly in code-scripting, is slightly different (shorter, lol) than doing it via the GUI/Editor's 'add new script':
// create ("katana")
// katana.damage = 50 // set variable katana.damage = [EXPRESSION] 50
// player.weapon = katana // set variable player.weapon = [EXPRESSION] katana
// player.strength = 100 // set variable player.strength = [EXPRESSION] 100
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [100] / 100 = 100

// player.strength = 0 // set variable player.strength = [EXPRESSION] 0
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [0] / 100 = 50

// player.strength = 50 // set variable player.strength = [EXPRESSION] 50
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [50] / 100 = 75

// player.strength = 75 // set variable player.strength = [EXPRESSION] 75
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [75] / 100 = ~ 87

// player.strength = 25 // set variable player.strength = [EXPRESSION] 25
set variable player.damage = [EXPRESSION] player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = [50] + [50] * [25] / 100 = ~ 63


Concatenation'ally Changing a String Attribute's Value:

Concatenation Operator symbol: +

an example:

set variable npc.greeting = [EXPRESSION] "Hi"
// msg (npc.greeting)
set variable npc.greeting = [EXPRESSION] npc.greeting + ", my name is HK."
// msg (npc.greeting)
set variable npc.greeting = [EXPRESSION] npc.greeting + " What is your name?"
// msg (npc.greeting)

// output/display/results:

Hi
Hi, my name is HK.
Hi, my name is HK. What is your name?