Working With GemScript - theRAPTLab/gsgo GitHub Wiki
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.
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:
# PROGRAM DEFINE
# PROGRAM INIT
- Instance Editor Properties / aka instance spec
initScript
Note that # PROGRAM UPDATE
is NOT run yet. So any scripts in there will not fire.
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
- 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
- setProp x -200
- setProp y 100
- featureCall Movement setDirection 90
- addProp energyLevel Number 50
- propCall energyLevel sub 1
- featureCall Movement setMovementType 'wander' 1