diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 2d62cb3..0794482 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | apt-get update - apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv + apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 - name: Configure CMake run: cmake -S . -B build -DDUSK_TARGET_SYSTEM=linux - name: Build @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | apt-get update - apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv + apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 - name: Configure CMake run: cmake -S . -B build -DDUSK_TARGET_SYSTEM=psp - name: Build diff --git a/.gitignore b/.gitignore index 0a9fa0a..6db54e3 100644 --- a/.gitignore +++ b/.gitignore @@ -100,4 +100,5 @@ package-lock.json yarn-error.log yarn.lock -.editor \ No newline at end of file +.editor +.venv \ No newline at end of file diff --git a/src/script/scriptmanager.c b/src/script/scriptmanager.c index 595ab47..faad38c 100644 --- a/src/script/scriptmanager.c +++ b/src/script/scriptmanager.c @@ -28,7 +28,7 @@ errorret_t scriptManagerInit() { luaL_openlibs(SCRIPT_MANAGER.luaState); lua_register(SCRIPT_MANAGER.luaState, "luaCallable", luaCallable); - // SCript test + // Script test. assetscript_t script; assetLoad("script/test.dsf", &script); @@ -46,11 +46,10 @@ errorret_t scriptManagerInit() { assetScriptDispose(&script); - errorOk(); } -errorret_t scriptManagerExec(const char_t *script) { +errorret_t scriptManagerExecString(const char_t *script) { if(SCRIPT_MANAGER.luaState == NULL) { errorThrow("Lua state is not initialized"); } @@ -64,6 +63,20 @@ errorret_t scriptManagerExec(const char_t *script) { errorOk(); } +errorret_t scriptManagerExecFile(const char_t *filename) { + if(SCRIPT_MANAGER.luaState == NULL) { + errorThrow("Lua state is not initialized"); + } + + if(luaL_dofile(SCRIPT_MANAGER.luaState, filename) != LUA_OK) { + const char_t *strErr = lua_tostring(SCRIPT_MANAGER.luaState, -1); + lua_pop(SCRIPT_MANAGER.luaState, 1); + errorThrow("Failed to execute Lua file: %s", strErr); + } + + errorOk(); +} + errorret_t scriptManagerDispose() { if(SCRIPT_MANAGER.luaState != NULL) { lua_close(SCRIPT_MANAGER.luaState);