Working With GemScript - theRAPTLab/gsgo GitHub Wiki

Call Order

When scripting character types, pay attention to when particular pragmas and conditionals are called and how often they are called. This has a profound effect on character behaviors.

Agent Initialization

Agents are initialized (or re-initialized) each time:

  • STAGE: "SETUP" is clicked
  • STAGE: "SAVE" is clicked
  • "RESET STAGE" is clicked.
  • Script is submitted from Script Editor (and Main is not in SETUP)

When an agent is initialized it runs the following scripts:

  1. # PROGRAM DEFINE
  2. # PROGRAM INIT
  3. Instance Editor Properties / aka instance spec initScript

Note that # PROGRAM UPDATE is NOT run yet. So any scripts in there will not fire.

Simulation Start

When "START ROUND" is pressed, the following scripts will fire.

(Depending on the EVENT, # PROGRAM EVENT may or may not fire before # PROGRAM UPDATE.)

  • # PROGRAM EVENT onEvent Start [[..]] -- Called once on "GO"
  • # PROGRAM EVENT onEvent Tick [[..]] -- Called every second
  • # PROGRAM UPDATE -- Called each loop (30 times a second)
  • # PROGRAM UPDATE when xxx touches yyy [[ .. ]] -- Called each loop (30 times a second) whenever xxx touches yyy
  • # PROGRAM UPDATE when xxx touches yyy [[ every 1 [[...]] -- Called every second whenever xxx touches yyy

Sprites: gs_packages/gem-srv/src/app/static/sprites

  • bunny.json
  • Bee.json (fly = 0-3, walk = 4-5)
  • hive.json
  • Flower.json (yellow = 0, orange = 1, blue = 2)
  • Fish.json (sated = 0, hungry = 1, dead = 2)
  • algae.json
  • lightbeam.json

Example Commands

  • setProp x -200
  • setProp y 100
  • featureCall Movement setDirection 90
  • addProp energyLevel Number 50
  • propCall energyLevel sub 1
  • featureCall Movement setMovementType 'wander' 1
⚠️ **GitHub.com Fallback** ⚠️