mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
lua: inventory.clone
This commit is contained in:
parent
60902e69ba
commit
cac963bd7b
5 changed files with 29 additions and 0 deletions
|
|
@ -101,3 +101,14 @@ int l_inventory_unbind_block(lua_State* L) {
|
|||
scripting::blocks->unbindInventory(x, y, z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_inventory_clone(lua_State* L) {
|
||||
lua::luaint id = lua_tointeger(L, 1);
|
||||
auto clone = scripting::level->inventories->clone(id);
|
||||
if (clone == nullptr) {
|
||||
lua_pushinteger(L, 0);
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger(L, clone->getId());
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ extern int l_inventory_add(lua_State* L);
|
|||
extern int l_inventory_get_block(lua_State* L);
|
||||
extern int l_inventory_bind_block(lua_State* L);
|
||||
extern int l_inventory_unbind_block(lua_State* L);
|
||||
extern int l_inventory_clone(lua_State* L);
|
||||
|
||||
static const luaL_Reg inventorylib [] = {
|
||||
{"get", lua_wrap_errors<l_inventory_get>},
|
||||
|
|
@ -19,6 +20,7 @@ static const luaL_Reg inventorylib [] = {
|
|||
{"get_block", lua_wrap_errors<l_inventory_get_block>},
|
||||
{"bind_block", lua_wrap_errors<l_inventory_bind_block>},
|
||||
{"unbind_block", lua_wrap_errors<l_inventory_unbind_block>},
|
||||
{"clone", lua_wrap_errors<l_inventory_clone>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue