mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
Merge pull request #473 from MihailRis/new-inventory-funcs
Add new inventory funcs
This commit is contained in:
commit
721286c2ba
2 changed files with 20 additions and 1 deletions
|
|
@ -71,6 +71,15 @@ static int l_set(lua::State* L, ItemStack& item) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_count(lua::State* L, ItemStack& item) {
|
||||
auto count = lua::tointeger(L, 3);
|
||||
if (item.getItemId() == ITEM_EMPTY) {
|
||||
return 0;
|
||||
}
|
||||
item.setCount(count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_size(lua::State* L) {
|
||||
auto invid = lua::tointeger(L, 1);
|
||||
const auto& inv = get_inventory(invid);
|
||||
|
|
@ -226,6 +235,7 @@ static int l_set_data(lua::State* L, ItemStack& stack) {
|
|||
const luaL_Reg inventorylib[] = {
|
||||
{"get", wrap_slot<l_get>},
|
||||
{"set", wrap_slot<l_set>},
|
||||
{"set_count", wrap_slot<l_set_count>},
|
||||
{"size", lua::wrap<l_size>},
|
||||
{"add", lua::wrap<l_add>},
|
||||
{"move", lua::wrap<l_move>},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue