diff options
author | Ilya Zhuravlev <zhuravlevilya@ya.ru> | 2012-08-20 01:29:56 +0400 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-09-01 10:01:41 +0300 |
commit | 6a16075912d016926ee0361fb85f9979c119be52 (patch) | |
tree | 9f0b589efac5266eb51db71643e174187f83cf3e /src/scriptapi.cpp | |
parent | 43ebec2be1949aa5eac127df7cb902d37e4e461b (diff) | |
download | minetest-6a16075912d016926ee0361fb85f9979c119be52.tar.gz minetest-6a16075912d016926ee0361fb85f9979c119be52.tar.bz2 minetest-6a16075912d016926ee0361fb85f9979c119be52.zip |
Add InventoryList width property & allow custom crafting grids.
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 33 |
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), |