Add script context
Some checks failed
Build Dusk / build-linux (push) Successful in 1m41s
Build Dusk / build-psp (push) Failing after 2m36s

This commit is contained in:
2025-12-04 20:57:12 -06:00
parent 8c74ee31e0
commit 4e1b404820
13 changed files with 369 additions and 90 deletions

View File

@@ -18,6 +18,8 @@
#include "script/scriptmanager.h"
#include "debug/debug.h"
#include "script/scriptcontext.h"
engine_t ENGINE;
errorret_t engineInit(const int32_t argc, const char_t **argv) {
@@ -38,10 +40,20 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
errorChain(sceneManagerInit());
errorChain(scriptManagerInit());
// scriptManagerExec(
// "print('Hello from Lua!')\n"
// "luaCallable()\n"
// );
scriptcontext_t testCtx;
errorChain(scriptContextInit(&testCtx));
errorChain(scriptContextExecFile(&testCtx, "script/test.dsf"));
errorChain(scriptContextCallFunc(&testCtx, "testFunction", NULL, 0, NULL));
scriptvalue_t args[2] = {
{ .type = SCRIPT_VALUE_TYPE_INT, .value.intValue = 5 },
{ .type = SCRIPT_VALUE_TYPE_INT, .value.intValue = 7 }
};
scriptvalue_t ret = { .type = SCRIPT_VALUE_TYPE_INT };
errorChain(scriptContextCallFunc(&testCtx, "doAdd", args, 2, &ret));
printf("doAdd returned: %d\n", ret.value.intValue);
scriptContextDispose(&testCtx);
errorOk();
}
@@ -55,7 +67,6 @@ errorret_t engineUpdate(void) {
sceneManagerUpdate();
errorChain(displayUpdate());
if(inputPressed(INPUT_ACTION_RAGEQUIT)) ENGINE.running = false;
errorOk();