here's an example:
orc.life = orc.life - player.damage
conceptually of how it works:
initial values (for this example):
orc.life = 100
player.damage = 20
the expression (formula~equation):
orc.life - player.damage
--
old value: orc.life = 100
orc.life (new) = orc.life (old: 100) - player.damage (20)
orc.life (new) = (100) - (20)
orc.life (new) = 80
new value: orc.life = 80
---
old value: orc.life = 80
orc.life (new) = orc.life (old:80) - player.damage (20)
orc.life (new ) = (80) - (20)
orc.life (new) = 60
new value: orc.life = 60
--
etc etc etc
---------------------------
the confusion, is that programming is doing ASSIGNMENT, not math's equals.
you're literally plugging~assigning~setting the result of the expression ( on the right side of the ASSIGNMENT operator: = ) to the VARIABLE (on the left side of the ASSIGNMENT operator: = )
you know algebra, right? algebraic substitution:
x = 10
y = x + 5
y = (x:10) + (5)
y = 15
that's the same as programming's VARIABLES:
x = 10
msg (x)
// outputs: 10
msg("The number is " + x + ".")
// outputs: The number is 10.
except, instead of using 'x' (though you can), we are more descriptive:
orc.life = 10
instead of 'x' we're using 'orc.life'
msg("The number is " + orc.life + ".")
outputs: The number is 10.
-------
the other difference is that we're doing ASSIGNMENT:
literally setting the result of the expression on the right side of the ASSIGNMENT Operator (=) to the VARIABLE on the left side of the ASSIGNMENT Operator (=):
x = 10
'10' is being plugged into (set~assigned~etc) 'x'
x = "Hi, my name is HK."
the 'Hi, my name is HK.' string is assigned into~to the variable 'x'
so, now do you understand the:
orc.life = orc.life - player.damage
the result of the expression 'orc.life - player.damage' is ASSIGNED into~to the VARIABLE 'orc.life'
------------
see this link for more info:
viewtopic.php?f=18&t=5559ask if confused by anything or if need help with anything
-------
oh, in the GUI~Editor, you use the:
run as script -> add new script -> variables -> 'set a variable or attribute' Script
to do what I shown in code above.
-----------------
my own template of general syntax:
Object_name.Attribute_name = Value_or_Expression
examples:
1) player.strength = player.strength + 5
2) player.strength = player.endurance + player.endurance
3) player.damage = (player.weapon.damage + player.weapon.damage * player.strength / 100) - (orc.armor.resistance + orc.armor.resistance * orc.endurance / 100)
Addition (simple):
Object_name.Attribute_name = Object_name.Attribute_name + Value
player.strength = player.strength + 5
Subtraction (simple):
Object_name.Attribute_name = Object_name.Attribute_name - Value
player.strength = player.strength - 5
Multiplication (simple):
Object_name.Attribute_name = Object_name.Attribute_name * Value
player.strength = player.strength * 5
Division (getting the quotient) (simple):
Object_name.Attribute_name = Object_name.Attribute_name / Value
player.strength = player.strength / 5
Modulus (Division, but getting the remainder) (simple):
Object_name.Attribute_name = Object_name.Attribute_name % Value
player.strength = player.strength % 5
---------
for a complex expression, see above my example number: '3)' --- it's above the 'Addition (simple)' title
--------
see my link, to see how to do transactions ("buying" and "selling")