summaryrefslogtreecommitdiff
path: root/src/scriptapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r--src/scriptapi.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 95e2b5d01..81e96aec6 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -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),