1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add InventoryList width property & allow custom crafting grids.

This commit is contained in:
Ilya Zhuravlev 2012-08-20 01:29:56 +04:00 committed by Perttu Ahola
parent 43ebec2be1
commit 6a16075912
7 changed files with 69 additions and 8 deletions

View file

@ -1847,6 +1847,20 @@ private:
return 1;
}
// get_width(self, listname)
static int l_get_width(lua_State *L)
{
InvRef *ref = checkobject(L, 1);
const char *listname = luaL_checkstring(L, 2);
InventoryList *list = getlist(L, ref, listname);
if(list){
lua_pushinteger(L, list->getWidth());
} else {
lua_pushinteger(L, 0);
}
return 1;
}
// set_size(self, listname, size)
static int l_set_size(lua_State *L)
{
@ -1869,6 +1883,23 @@ private:
return 0;
}
// set_width(self, listname, size)
static int l_set_width(lua_State *L)
{
InvRef *ref = checkobject(L, 1);
const char *listname = luaL_checkstring(L, 2);
int newwidth = luaL_checknumber(L, 3);
Inventory *inv = getinv(L, ref);
InventoryList *list = inv->getList(listname);
if(list){
list->setWidth(newwidth);
} else {
return 0;
}
reportInventoryChange(L, ref);
return 0;
}
// get_stack(self, listname, i) -> itemstack
static int l_get_stack(lua_State *L)
{
@ -2062,6 +2093,8 @@ const luaL_reg InvRef::methods[] = {
method(InvRef, is_empty),
method(InvRef, get_size),
method(InvRef, set_size),
method(InvRef, get_width),
method(InvRef, set_width),
method(InvRef, get_stack),
method(InvRef, set_stack),
method(InvRef, get_list),