Added ways to set/clear the active flag on gameobjects from Lua
This commit is contained in:
@@ -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
|
|
||||||
BIN
output.bin
BIN
output.bin
Binary file not shown.
48
src/lua.cpp
48
src/lua.cpp
@@ -17,6 +17,8 @@ return function(metatable)
|
|||||||
function metatable.__index(self, key)
|
function metatable.__index(self, key)
|
||||||
if key == "position" then
|
if key == "position" then
|
||||||
return get_position(self.__cpp_ptr)
|
return get_position(self.__cpp_ptr)
|
||||||
|
elseif key == "active" then
|
||||||
|
return get_active(self.__cpp_ptr)
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -25,6 +27,8 @@ return function(metatable)
|
|||||||
if key == "position" then
|
if key == "position" then
|
||||||
set_position(self.__cpp_ptr, value)
|
set_position(self.__cpp_ptr, value)
|
||||||
return
|
return
|
||||||
|
elseif key == "active" then
|
||||||
|
set_active(self.__cpp_ptr, value)
|
||||||
end
|
end
|
||||||
rawset(self, key, value)
|
rawset(self, key, value)
|
||||||
end
|
end
|
||||||
@@ -33,6 +37,23 @@ end
|
|||||||
|
|
||||||
// Lua helpers
|
// Lua helpers
|
||||||
|
|
||||||
|
|
||||||
|
static int gameobjectGetPosition(psyqo::Lua L) {
|
||||||
|
|
||||||
|
auto go = L.toUserdata<psxsplash::GameObject>(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) {
|
static int gameobjectSetPosition(psyqo::Lua L) {
|
||||||
|
|
||||||
auto go = L.toUserdata<psxsplash::GameObject>(1);
|
auto go = L.toUserdata<psxsplash::GameObject>(1);
|
||||||
@@ -55,22 +76,17 @@ static int gameobjectSetPosition(psyqo::Lua L) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int gamobjectGetActive(psyqo::Lua L) {
|
||||||
|
|
||||||
static int gameobjectGetPosition(psyqo::Lua L) {
|
|
||||||
|
|
||||||
auto go = L.toUserdata<psxsplash::GameObject>(1);
|
auto go = L.toUserdata<psxsplash::GameObject>(1);
|
||||||
|
L.push(go->isActive());
|
||||||
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;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int gamobjectSetActive(psyqo::Lua L) {
|
||||||
|
auto go = L.toUserdata<psxsplash::GameObject>(1);
|
||||||
|
bool active = L.toBoolean(2);
|
||||||
|
go->setActive(active);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void psxsplash::Lua::Init() {
|
void psxsplash::Lua::Init() {
|
||||||
@@ -87,6 +103,12 @@ void psxsplash::Lua::Init() {
|
|||||||
L.push(gameobjectSetPosition);
|
L.push(gameobjectSetPosition);
|
||||||
L.setField(-2, "set_position");
|
L.setField(-2, "set_position");
|
||||||
|
|
||||||
|
L.push(gamobjectGetActive);
|
||||||
|
L.setField(-2, "get_active");
|
||||||
|
|
||||||
|
L.push(gamobjectSetActive);
|
||||||
|
L.setField(-2, "set_active");
|
||||||
|
|
||||||
L.copy(-1);
|
L.copy(-1);
|
||||||
m_metatableReference = L.ref();
|
m_metatableReference = L.ref();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user