theRAPTLab / gsgo

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

Feature: Programmatic Editable Token Support for Add/Modify/Delete Lines - [merged] #669

Closed benloh closed 1 year ago

benloh commented 2 years ago

In GitLab by @daveseah on Jun 15, 2022, 08:52

Merges dev-sri/gui-debug-editable-toks -> dev-next-gui

This hopefully is the final fixed version of the system to allow easy modification, insertion, and deletion of Script Lines that are being edited by the GUI. This is more difficult than it sounds because our internal script encoding can have blocks of code, and these blocks can be insider of blocks. For example, this block of GEMSCRIPT text looks like 5 lines but is encoded as one statement:

every 10 [[
  if {{ energyLevel < 10 }} [[
     prop energyLevel setTo 50
  ]]
]]

encodes as "statement" (simplified for readability)

[ { every } { expr:"energyLevel < 10" } { block: [ [ { prop } { energyLevel } { setTo } { 50 } ] ] } ]

TESTING

BUILD & RUN

NOTE

CHANGE

DOUBLE-CHECK

TECHNICAL

The API for EditableTokens is generally this:

// create editable token array
const editableTokensArray = TRANSPILER.ScriptToEditableTokens(script_tokens);

const line_num = 10;
const index = CHECK.OffsetLineNum(line_num, 'sub'); // line nums start from 1, but arrays start from 0
const { lineScript } = editableTokensArray[index];
// lineScript contains script tokens you can edit or replace
// to add/remove lines, use Array.splice() on the editableTokensArray

// repackage editable token array back into script token
const new_script_tokens = TRANSPILER.EditableTokensToScript(editableTokensArray);
benloh commented 2 years ago

In GitLab by @daveseah on Jun 15, 2022, 20:26

added 2 commits

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 15, 2022, 20:35

After heavily instrumenting the line-out routines, my guesses are

mystery-extra-lines

benloh commented 2 years ago

In GitLab by @daveseah on Jun 16, 2022, 18:10

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 16, 2022, 20:50

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 04:26

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 05:02

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 06:11

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 06:21

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 06:38

added 2 commits

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 07:42

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 10:58

marked this merge request as ready

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 14:09

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 14:42

added 1 commit

Compare with previous version

benloh commented 2 years ago

In GitLab by @daveseah on Jun 17, 2022, 14:43

CRASH ISSUES caused by the renaming of program outputs from lowercase to uppercase. Should all be fixed now.

benloh commented 2 years ago

No errors in dev wizard or main.

benloh commented 2 years ago

mentioned in commit ae8f778eb960d14c5e3776ab2c411b97fe55716a