aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorTeTpaAka <TeTpaAka@users.noreply.github.com>2015-06-02 20:30:04 +0200
committerest31 <MTest31@outlook.com>2015-06-22 19:30:35 +0200
commit17ba584fe254eeaee3489cc20e03810a59f3ef9b (patch)
tree33ff4e30753c243a607ccb06b93d27c325eb1103 /src/script
parent0b76e85a717a05b608d09618bb48434510f0ae27 (diff)
downloadminetest-17ba584fe254eeaee3489cc20e03810a59f3ef9b.tar.gz
minetest-17ba584fe254eeaee3489cc20e03810a59f3ef9b.tar.bz2
minetest-17ba584fe254eeaee3489cc20e03810a59f3ef9b.zip
Fix bug when craft input isn't replaced
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_craft.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/script/lua_api/l_craft.cpp b/src/script/lua_api/l_craft.cpp
index b321fb32f..f59487727 100644
--- a/src/script/lua_api/l_craft.cpp
+++ b/src/script/lua_api/l_craft.cpp
@@ -303,18 +303,23 @@ int ModApiCraft::l_get_craft_result(lua_State *L)
ICraftDefManager *cdef = gdef->cdef();
CraftInput input(method, width, items);
CraftOutput output;
- bool got = cdef->getCraftResult(input, output, true, gdef);
+ std::vector<ItemStack> output_replacements;
+ bool got = cdef->getCraftResult(input, output, output_replacements, true, gdef);
lua_newtable(L); // output table
- if(got){
+ if (got) {
ItemStack item;
item.deSerialize(output.item, gdef->idef());
LuaItemStack::create(L, item);
lua_setfield(L, -2, "item");
setintfield(L, -1, "time", output.time);
+ push_items(L, output_replacements);
+ lua_setfield(L, -2, "replacements");
} else {
LuaItemStack::create(L, ItemStack());
lua_setfield(L, -2, "item");
setintfield(L, -1, "time", 0);
+ lua_newtable(L);
+ lua_setfield(L, -2, "replacements");
}
lua_newtable(L); // decremented input table
lua_pushstring(L, method_s.c_str());