diff --git a/res/modules/internal/stdcomp.lua b/res/modules/internal/stdcomp.lua index 7cedd1887..d85c11963 100644 --- a/res/modules/internal/stdcomp.lua +++ b/res/modules/internal/stdcomp.lua @@ -32,6 +32,8 @@ local Rigidbody = {__index={ set_crouching=function(self, b) return __rigidbody.set_crouching(self.eid, b) end, get_body_type=function(self) return __rigidbody.get_body_type(self.eid) end, set_body_type=function(self, s) return __rigidbody.set_body_type(self.eid, s) end, + get_material=function(self) return __rigidbody.get_material(self.eid) end, + set_material=function(self, s) return __rigidbody.set_material(self.eid, s) end, }} local function new_Rigidbody(eid) diff --git a/src/logic/scripting/lua/libs/lib__rigidbody.cpp b/src/logic/scripting/lua/libs/lib__rigidbody.cpp index f32e9d986..1e04e3b3c 100644 --- a/src/logic/scripting/lua/libs/lib__rigidbody.cpp +++ b/src/logic/scripting/lua/libs/lib__rigidbody.cpp @@ -150,6 +150,20 @@ static int l_set_linear_damping(lua::State* L) { return 0; } +static int l_set_material(lua::State* L) { + if (auto entity = get_entity(L, 1)) { + entity->getRigidbody().hitbox.material = lua::require_string(L, 2); + } + return 0; +} + +static int l_get_material(lua::State* L) { + if (auto entity = get_entity(L, 1)) { + return lua::pushstring(L, entity->getRigidbody().hitbox.material); + } + return 0; +} + const luaL_Reg rigidbodylib[] = { {"is_enabled", lua::wrap}, {"set_enabled", lua::wrap}, @@ -169,5 +183,7 @@ const luaL_Reg rigidbodylib[] = { {"set_crouching", lua::wrap}, {"get_body_type", lua::wrap}, {"set_body_type", lua::wrap}, + {"set_material", lua::wrap}, + {"get_material", lua::wrap}, {nullptr, nullptr} };