diff --git a/src/console.c b/src/console.c index ac4dce6..2df3be9 100644 --- a/src/console.c +++ b/src/console.c @@ -2239,7 +2239,17 @@ static void onConsoleEvalCommand(Console* console, const char* param) printLine(console); const tic_script_config* script_config = console->tic->api.get_script_config(console->tic); - script_config->eval(console->tic, param); + + if (script_config->eval) + { + if(param) + script_config->eval(console->tic, param); + else printError(console, "nothing to eval"); + } + else + { + printError(console, "'eval' not implemented for the script"); + } commandDone(console); } diff --git a/src/luaapi.c b/src/luaapi.c index 0a49020..8327cfd 100644 --- a/src/luaapi.c +++ b/src/luaapi.c @@ -1414,10 +1414,12 @@ static const tic_outline_item* getLuaOutline(const char* code, s32* size) return items; } -void evalLua(tic_mem* tic, const char* code) { +static void evalLua(tic_mem* tic, const char* code) { tic_machine* machine = (tic_machine*)tic; lua_State* lua = machine->lua; + if (!lua) return; + lua_settop(lua, 0); if(luaL_loadstring(lua, code) != LUA_OK || lua_pcall(lua, 0, LUA_MULTRET, 0) != LUA_OK) @@ -1426,10 +1428,6 @@ void evalLua(tic_mem* tic, const char* code) { } } -void evalPlaceholder(tic_mem* tic, const char* code) { - printf("TODO: not yet implemented\n."); -} - static const tic_script_config LuaSyntaxConfig = { .init = initLua, @@ -1609,7 +1607,7 @@ static const tic_script_config MoonSyntaxConfig = .getOutline = getMoonOutline, .parse = parseCode, - .eval = evalPlaceholder, + .eval = NULL, .blockCommentStart = NULL, .blockCommentEnd = NULL, @@ -1750,7 +1748,7 @@ static const tic_outline_item* getFennelOutline(const char* code, s32* size) return items; } -void evalFennel(tic_mem* tic, const char* code) { +static void evalFennel(tic_mem* tic, const char* code) { tic_machine* machine = (tic_machine*)tic; lua_State* fennel = machine->lua; diff --git a/src/wrenapi.c b/src/wrenapi.c index 99c9757..c6094b7 100644 --- a/src/wrenapi.c +++ b/src/wrenapi.c @@ -1372,7 +1372,7 @@ static const tic_outline_item* getWrenOutline(const char* code, s32* size) return items; } -void evalWren(tic_mem* memory, const char* code) +static void evalWren(tic_mem* memory, const char* code) { tic_machine* machine = (tic_machine*)memory; wrenInterpret(machine->wren, code);