I am creating a game to create math problems. I pass the number of digits for each operand plus the operator (+,-,x,/). The script generates two random operands and the adds them (for now).
Here is the calling sequence:
The header for the JS:
function genproblem(n1digits, n2digits, operator)
It does what it is supposed to and returns the sum of the two numbers. I also need the two operands stored in C3 global variables in order to display the entire problem.
I read this:
An object with a property for each global variable on an event sheet in the project. For example if the project has a global variable on an event sheet named Score, then runtime.globalVars.Score provides access to the global variable from script.
I added the following:
runtime.globalVars.n1 = n1;
Then I get a runtime error:
action.js:31 Unhandled exception running script Event sheet 1, event 1, action 2: ReferenceError: runtime is not defined
at genproblem (Script.js:17)
at EventSheet1_Event1_Act2 (scriptsInEvents.js:8)
at Action.RunUserScript (action.js:31)
at EventBlock._RunActions_ReturnValue (eventBlock.js:26)
at EventBlock._RunAndBlock (eventBlock.js:23)
at EventBlock.Run (eventBlock.js:20)
at EventSheet._ExecuteTrigger (eventSheet.js:18)
at EventSheet._TriggerForClass (eventSheet.js:12)
at EventSheet._Trigger (eventSheet.js:11)
at EventSheetManager._Trigger (eventSheetManager.js:13)
async function (async)
action.js:32 Tip: run this to highlight in Construct the last script that had an error: goToLastErrorScript()
So the question is how do I update global variables from a script file?
Here is the file: drive.google.com/file/d/1yeHVnM6CVoJ23DN-1P0_K_WyxsKDse2K/view