Add script context
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user