Added some node functionality to scripts

This commit is contained in:
2022-10-07 10:25:09 +01:00
parent ecaf554b9a
commit 6b5cd7f580
5 changed files with 306 additions and 19 deletions

11
assets/scripts/child.toy Normal file
View File

@@ -0,0 +1,11 @@
fn onInit(node: opaque) {
print "child.toy:onInit() called";
}
fn onStep(node: opaque) {
print "child.toy:onStep()";
}
fn onFree(node: opaque) {
print "child.toy:onFree() called";
}

View File

@@ -1,14 +1,34 @@
import standard;
import engine;
//root node can load the whole scene, and essentially act as the scene object
fn onInit() {
print "root.toy:onInit() called";
fn makeChild(parent: opaque, fname: string, init: bool) {
var child: opaque = loadNode(fname);
if (init) {
initNode(child);
}
pushNode(parent, child);
}
fn onStep() {
//root node can load the whole scene, and essentially act as the scene object
fn onInit(node: opaque) {
print "root.toy:onInit() called";
//make a child
makeChild(node, "assets/scripts/child.toy", true); //indicate whether to call "init" on the new node or not
makeChild(node, "assets/scripts/child.toy", false);
makeChild(node, "assets/scripts/child.toy", false);
//actually, grab that first node and free it
var o: opaque = getNode(node, 0);
freeNode(o);
}
fn onStep(node: opaque) {
print clock();
}
fn onFree() {
fn onFree(node: opaque) {
print "root.toy:onFree() called";
}