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.

stackAdd / stackSub / stackMul / stackDiv

To use these stack operations:

  1. Push two values to the stack
  2. Run the stack operation. The result will be saved to the stack.
  3. 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:

  1. Push A
  2. 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.

Related Stack Keywords

  • featPropPop
  • featPropPush
  • propPop
  • propPush
⚠️ **GitHub.com Fallback** ⚠️