Bugfix to get_all_craft_recipes.
authorRealBadAngel <mk@realbadangel.pl>
Sat, 21 Dec 2013 22:03:51 +0000 (23:03 +0100)
committerRealBadAngel <mk@realbadangel.pl>
Sat, 21 Dec 2013 22:03:51 +0000 (23:03 +0100)
Indexes for empty slots shall not be skipped.

src/script/lua_api/l_craft.cpp

index ef13aa82ce69f1d2aab81b8dab3e4c09f3d39cb7..aaca84c5601291977ed9194ac0db5c6b6109c832 100644 (file)
@@ -410,11 +410,11 @@ int ModApiCraft::l_get_all_craft_recipes(lua_State *L)
                        lua_newtable(L);
                        lua_newtable(L); // items
                        std::vector<ItemStack>::const_iterator iter = input.items.begin();
-                       for (u16 j = 0; iter != input.items.end(); iter++) {
+                       for (u16 j = 1; iter != input.items.end(); iter++, j++) {
                                if (iter->empty())
                                        continue;
                                lua_pushstring(L, iter->name.c_str());
-                               lua_rawseti(L, -2, ++j);
+                               lua_rawseti(L, -2, j);
                        }
                        lua_setfield(L, -2, "items");
                        setintfield(L, -1, "width", input.width);