mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add rigidbody:get_material, set_material
This commit is contained in:
parent
8c06048b7e
commit
c0a89cd93a
2 changed files with 18 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<l_is_enabled>},
|
||||
{"set_enabled", lua::wrap<l_set_enabled>},
|
||||
|
|
@ -169,5 +183,7 @@ const luaL_Reg rigidbodylib[] = {
|
|||
{"set_crouching", lua::wrap<l_set_crouching>},
|
||||
{"get_body_type", lua::wrap<l_get_body_type>},
|
||||
{"set_body_type", lua::wrap<l_set_body_type>},
|
||||
{"set_material", lua::wrap<l_set_material>},
|
||||
{"get_material", lua::wrap<l_get_material>},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue