Calculations can be done in ALL logical commands [set, give, take, if, not, cost]. You need to wrap all calculations in: calc().

Basic Math

Basic computations don’t require any additional commands.

[set: TEAM_MORALE calc(JUDY + BOBBY + ELENA)]

Order of Operations

The order of operations is strictly left to right so you’ll have to use parentheses if you want certain calculations to happen first:

[set: TOTAL_PRICE calc((PRICE_APPLE+PRICE_BANANA)*(1-DISCOUNT))]

Use in Conditionals

You can easily gate by more than 1 variable but keep in mind if you use more than one variable on the left slot, it will lose the icon.

What do you want to do next?
* [cost: MONEY calc(BOAT.price+HOUSE.price)] Acquire the good life
* [if: PLAYER.reputation >= calc(ENEMY.reputation+BOSS.reputation)] Appeal to the masses
* Do nothing
[join]

Functions

In the section about variables we learned how to compare one variable to one value. You can actually compare an infinite number of them together. All functions require: calc().

Min/Max/Avg

These functions are VERY helpful when computing endings.

[set: WINNER calc(max(JUDY, BOBBY, ELENA))]
[set: LOSER calc(min(JUDY, BOBBY, ELENA))]
[set: AVERAGE calc(avg(JUDY, BOBBY, ELENA))]

And/Or

This is great for checking against multiple conditions

* [if: calc((CHAOTIC >= LAWFUL) and (GOOD >= EVIL))]
	    You are chaotic good
* [if: calc((CHAOTIC >= LAWFUL) and (EVIL >= GOOD))]
	    You are chaotic evil
* [if: GOOD >= EVIL]
	    You are lawful good
* [else]
	    You are lawful evil
[join]
How do you want to proceed against the Rat King?
* [if: calc(SWORD or GUN)] You have a weapon!
* Run away!
[join]