How to add to the value an attribute

so I have an attribute that is an integer, how in code do I add +1 to the value?
I have had so much trouble with this


in code:

generic syntax:

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = NAME_OF_OBJECT.NAME_OF_ATTRIBUTE ARITHMETIC_OPERATION_SYMBOL VALUE_OR_VARIABLE

// or:

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_VARIABLE ARITHMETIC_OPERATION_SYMBOL NAME_OF_OBJECT.NAME_OF_ATTRIBUTE

for examples:

player.strength = player.strength + 9 // addition example

player.strength = player.strength - 3 // subtraction example

player.strength = player.strength * 4 // multiplication example

player.strength = player.strength / 2 // division example

player.strength = player.strength % 100 // modulus (division, but it gets/finds/returns the REMAINDER) example


example using an Integer VARIABLE instead of a literal/direct Integer Value):

player.life = 25
player.endurance = 50
player.life = player.life + player.endurance
// player.life = 75


in the GUI/EDITOR:

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

set variable player.strength = [EXPRESSION] player.strength + 5


how it is working:

initial value: player.strength = 0

old value: player.strength = 0

player.strength = player.strength + 5
player.strength (new) = player.strength (old: 0) + 5
player.strength (new) = (0) + 5 = 5

new value: player.strength = 5

old value: player.strength = 5

player.strength = player.strength + 5
player.strength (new) = player.strength (old: 5) + 5
player.strength (new) = (5) + 5 = 10

new value: player.strength = 10

old value: player.strength = 10

player.strength = player.strength + 5
player.strength (new) = player.strength (old: 10) + 5
player.strength (new) = (10) + 5 = 15

new value: player.strength = 15

old value: player.strength = 15

player.strength = player.strength + 5
player.strength (new) = player.strength (old: 15) + 5
player.strength (new) = (15) + 5 = 20

new value: player.strength = 20

etc etc etc


a more complex expression example:

create ("katana")
katana.damage = 50
player.strength = 100
player.weapon = katana
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (100) / 100 = 100

create ("katana")
katana.damage = 50
player.strength = 0
player.weapon = katana
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (0) / 100 = 50

create ("katana")
katana.damage = 50
player.strength = 75
player.weapon = katana
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (75) / 100 = ~ 85

create ("katana")
katana.damage = 50
player.strength = 25
player.weapon = katana
player.damage = player.weapon.damage + player.weapon.damage * player.strength / 100
// player.damage = (50) + (50) * (25) / 100 = ~62


object.attribute = object.attribute +1
That will add +1 to the attribute.


Log in to post a reply.

Support

Forums