mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
add data argument to inventory.add
This commit is contained in:
parent
d25180406b
commit
a118016c8f
1 changed files with 6 additions and 1 deletions
|
|
@ -81,10 +81,15 @@ static int l_add(lua::State* L) {
|
|||
auto invid = lua::tointeger(L, 1);
|
||||
auto itemid = lua::tointeger(L, 2);
|
||||
auto count = lua::tointeger(L, 3);
|
||||
auto data = lua::tovalue(L, 4);
|
||||
|
||||
validate_itemid(itemid);
|
||||
if (!data.isObject() && data != nullptr) {
|
||||
throw std::runtime_error("invalid data argument type (table expected)");
|
||||
}
|
||||
|
||||
auto& inv = get_inventory(invid);
|
||||
ItemStack item(itemid, count);
|
||||
ItemStack item(itemid, count, std::move(data));
|
||||
inv.move(item, *indices);
|
||||
return lua::pushinteger(L, item.getCount());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue