theRAPTLab / gsgo

GEM-STEP Foundation repo migrated from GitLab June 2023
1 stars 1 forks source link

It would be nice if we could allow kids to make simple edits via setup and then see the results immediately #424

Open benloh opened 2 years ago

benloh commented 2 years ago

In GitLab by @jdanish on Jul 18, 2022, 12:21

The ideal model is:

  1. Someone with more coding expertise makes a complex model that allows users to make some choices via setup. For example, they might make a flower character that can be a rose or a daisy.
  2. A user adds a flower to the map via setup. It appears as a rose (as defined in PROGRAM DEFINE).
  3. They can change it via the setup panel (e.g., change the type property from rose to daisy).
  4. When they blur or hit save, the flower updates its display to now be visible as a daisy. Maybe it also changes its name from Rose 2 to Daisy 2.
  5. The user then saves the setup and hits start. Any code in the system that needs to know if the flower or a daisy can check the flowerType property as before.
benloh commented 2 years ago

Multiple underlying issues/implications:

  1. Currently initScript runs after # PROGRAM INIT. So any settings made in initScript cannot be acted up on by the regular blueprint code until the sim is run. While we can do some method calls in initScript, from a novice user perspective, ideally we would keep the user instance intiScripts to simple property settings. Perhaps changing the run order to DEFINE -> initScript -> INIT would address this.

  2. Some properties are only activated when Features start running. e.g. you can set a feature property, but that property isn't used until the feature runs in a regular run loop. These would have to be modified to either run before the run loop or we'd have to run the sim one frame or perhaps use some kind of phase hook.

benloh commented 2 years ago

Tossing ideas, around, here is one possible approach

  1. Run DEFINE
  2. Run INIT
  3. Copy POSTINIT into instance initScript
  4. Run initScript
# PROGRAM DEFINE
addProp agentType string 'aggressive' // student face
addProp aggro number 0 // private

# PROGRAM INIT
prop agentType string setTo 'aggressive'
featCall agent.Costume setCostume 'BlueFlower.json'

# PROGRAM POSTINIT
// copied after instance initScript and run when instance is created
if {{ agent.prop.agentType === 'aggressive'}} [[
  prop aggro setTo 100
  featCall agent.Costume setCostume 'RedFlower.json'
]]
if {{ agent.prop.agentType === 'passive'}} [[
  prop aggro setTo 0
  featCall agent.Costume setCostume 'BlueFlower.json'
]]

# PROGRAM UPDATE
if {{ agent.prop.agentType === 'aggressive'}} [[
  prop aggro setTo 100
  featCall agent.Costume setCostume 'RedFlower.json'
]]
if {{ agent.prop.agentType === 'passive'}} [[
  prop aggro setTo 0
  featCall agent.Costume setCostume 'BlueFlower.json'
]]

MAIN SETUP

// INSTANCE initScript prop agentType string setTo 'passive'


Can we implement this simply?

How to author complex behavior strictly in gemscript without writing javascript code and extending these cases (e.g. don't have to create Features)

In this case, how to use constants to drive how a set of releated properties are configured and how to run conditional code based on what these properties are set to:

This does not cover all the use cases.

Five user cases:


Takeaway: This is 2.0 feature.

benloh commented 2 years ago

In GitLab by @jdanish on Jul 18, 2022, 16:03

ok