Added onLoad() lifecycle function

This commit is contained in:
2023-03-03 00:50:45 +11:00
parent 00587e91b2
commit 4965cd492d
11 changed files with 90 additions and 64 deletions

View File

@@ -63,12 +63,17 @@ void Box_initEngine() {
Toy_injectNativeHook(&engine.interpreter, "node", Box_hookNode);
Toy_injectNativeHook(&engine.interpreter, "input", Box_hookInput);
//run the init
size_t size = 0;
const unsigned char* source = Toy_readFile("./assets/scripts/init.toy", &size);
const unsigned char* tb = Toy_compileString((const char*)source, &size);
free((void*)source);
Toy_runInterpreter(&engine.interpreter, tb, size);
//init the node-tree
Box_callRecursiveEngineNode(engine.rootNode, &engine.interpreter, "onInit", NULL);
}
void Box_freeEngine() {