Attributes' using my-generalized syntax:
Object_name.Attribute_name = Value_or_Expression
--------------
THE TWO SUPER SCRIPTS (especially when used together, lets you do 90% of everything that you want to do in~for your game!):
1. 'set a variable or attribute' Script
run as script -> add new script -> variables -> 'set a variable or attribute' Script -> set variable ________ = [expression] _________
example (Object_name.Attribute_name = Value):
set variable player.strength = [expression] 100
example (Object_name.Attribute_name = Expression):
set variable player.damage = [expression] player.katana.damage + player.katana.damage * player.strength / 100 - (orc.full_plate_armor.resistance + orc.full_plate_armor.resistance * orc.endurance / 100)
2. 'if' Script
run as script -> add new script -> scripts -> 'if' Script -> if [expression] Object_name.Attribute_name OPERATOR Value_or_Expression
OPERATORS:
Math:
Addition: +
Subtraction: -
Multiplication: *
Division: /
Modulus (same as Division, but it gets the remainder instead): %
Greater Than: >
Lesser Than: <
Greater Than and~or Equal To: >=
Lesser Than and~or Equal To: <=
Equals: =
Not Equals 1: <>
Not Equals 2: not xxx = xxx
Strings~Text:
Assignment: =
Comparison: =
Concatenation: +
??? etc etc etc
-------
Basic Math Expressions (some examples):
Addition:
player.strength = player.strength + 20
player.damage = player.strength + player.endurance
Subtraction:
player.strength = player.strength - 15
Multiplication:
player.strength = player.strength * 7
player.damage = player.strength * player.endurance
Division:
player.strength = player.strength / 3
--------------
CONCEPTUAL example of how~why it works and~or is working (using addition):
initial~original~starting Value: player.strength = 0
Old Value: player.strength = 0
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 (new) = player.strength (old: 5) + 5
player.strength (new) = (5) + 5 = 10
New Value: player.strength = 10
Old Value: player.strength = 10
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 (new) = player.strength (old: 15) + 5
player.strength (new) = (15) + 5 = 20
New Value: player.strength = 20
etc etc etc
--------------
example of Transactions (buying~selling):
player.cash = 500
shop_owner.cash = 2000
sword.price = 100
Buying:
// sword.parent = shop_owner
if (player.cash >= sword.price) {
player.cash = player.cash - sword.price
shop_owner.cash = shop_owner.cash + sword.price
sword.parent = player
msg ("You bought the sword at 100 gold, leaving you with only 400 gold, the shop owner now has 2100 gold, and you place the sword into your inventory.")
} else {
msg ("Sorry, but you don't have enough gold to buy the sword.")
}
Selling:
(usually the selling amount in RPGs, is half the buying amount, so that's why I got the 'sword.price / 2' below)
(we're returning back to the original values for this example, we're NOT using the changed values of after buying the sword)
// sword.parent = player
if (shop_owner.cash >= sword.price / 2) {
player.cash = player.cash + sword.price / 2
shop_owner.cash = shop_owner.cash - sword.price / 2
sword.parent = shop_owner
msg ("You sell the sword at 50 gold, you now have 550 gold, the shop owner only has 1950 gold now, and you hand the sword over to the shop owner.")
} else {
msg ("Sorry, but the shop owner doesn't have enough gold to buy the sword from you.")
}