Stack Operations - theRAPTLab/gsgo GitHub Wiki
GEMSCRIPT does not allow you to assign properties to an GVar property.
In general, use stack operations when expressions are needed.
To use these stack operations:
- Push two values to the stack
- Run the stack operation. The result will be saved to the stack.
- Pop the stack to retrieve the result.
The stack operations will pop off the values in the stack and operate on them in the stack order. e.g. if we:
- Push A
- Push B
Then
- stackAdd = B + A
- stackSub = B - A
- stackMul = B * A
- stackDiv = B / A
Here's an example of how this might be used in context:
// global.totalEnergyLevel = global.totalEnergyLevel - agent.energyLevel
propPush agent.energyLevel
propPush global.totalEnergyLevel
stackSub
propPop global.totalEnergyLevel
This will subtract agent.energyLevel from global.totalEnergyLevel and place the new value in global.totalEnergyLevel.
featPropPop
featPropPush
propPop
propPush