diff --git a/compile_flags.txt b/compile_flags.txt deleted file mode 100644 index 624f052..0000000 --- a/compile_flags.txt +++ /dev/null @@ -1,22 +0,0 @@ --I third_party/nugget/psyqo-lua/../third_party/psxlua/src --D LUA_TARGET_PSX --I third_party/nugget/psyqo/../third_party/EASTL/include --I third_party/nugget/psyqo/../third_party/EABase/include/Common --I third_party/nugget/ --ffunction-sections --fdata-sections --fomit-frame-pointer --fno-builtin --fno-strict-aliasing --Wno-attributes --march=mips1 --EL --fno-pic --fno-stack-protector --nostdlib --ffreestanding --g --Os --std=c++20 --fno-exceptions --fno-rtti \ No newline at end of file diff --git a/output.bin b/output.bin index f0d2372..19705c8 100644 Binary files a/output.bin and b/output.bin differ diff --git a/src/lua.cpp b/src/lua.cpp index d501f13..5ebdd68 100644 --- a/src/lua.cpp +++ b/src/lua.cpp @@ -17,6 +17,8 @@ return function(metatable) function metatable.__index(self, key) if key == "position" then return get_position(self.__cpp_ptr) + elseif key == "active" then + return get_active(self.__cpp_ptr) end return nil end @@ -25,6 +27,8 @@ return function(metatable) if key == "position" then set_position(self.__cpp_ptr, value) return + elseif key == "active" then + set_active(self.__cpp_ptr, value) end rawset(self, key, value) end @@ -33,6 +37,23 @@ end // Lua helpers + +static int gameobjectGetPosition(psyqo::Lua L) { + + auto go = L.toUserdata(1); + + L.newTable(); + L.pushNumber(go->position.x.raw()); + L.setField(2, "x"); + L.pushNumber(go->position.y.raw()); + L.setField(2, "y"); + L.pushNumber(go->position.z.raw()); + L.setField(2, "z"); + + return 1; + +} + static int gameobjectSetPosition(psyqo::Lua L) { auto go = L.toUserdata(1); @@ -55,22 +76,17 @@ static int gameobjectSetPosition(psyqo::Lua L) { } - - -static int gameobjectGetPosition(psyqo::Lua L) { - +static int gamobjectGetActive(psyqo::Lua L) { auto go = L.toUserdata(1); - - L.newTable(); - L.pushNumber(go->position.x.raw()); - L.setField(2, "x"); - L.pushNumber(go->position.y.raw()); - L.setField(2, "y"); - L.pushNumber(go->position.z.raw()); - L.setField(2, "z"); - + L.push(go->isActive()); return 1; +} +static int gamobjectSetActive(psyqo::Lua L) { + auto go = L.toUserdata(1); + bool active = L.toBoolean(2); + go->setActive(active); + return 0; } void psxsplash::Lua::Init() { @@ -87,6 +103,12 @@ void psxsplash::Lua::Init() { L.push(gameobjectSetPosition); L.setField(-2, "set_position"); + L.push(gamobjectGetActive); + L.setField(-2, "get_active"); + + L.push(gamobjectSetActive); + L.setField(-2, "set_active"); + L.copy(-1); m_metatableReference = L.ref();