From e070f1e5250b6853788cb827bb2f46ecdbe300a8 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Sat, 11 Feb 2012 18:10:13 +0100 Subject: Allow replacements in cooking and fuel recipes --- src/scriptapi.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/scriptapi.cpp') diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index f53355f64..3766496a0 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -4129,8 +4129,17 @@ static int l_register_craft(lua_State *L) float cooktime = getfloatfield_default(L, table, "cooktime", 3.0); + CraftReplacements replacements; + lua_getfield(L, table, "replacements"); + if(!lua_isnil(L, -1)) + { + if(!read_craft_replacements(L, -1, replacements)) + throw LuaError(L, "Invalid replacements" + " (cooking output=\"" + output + "\")"); + } + CraftDefinition *def = new CraftDefinitionCooking( - output, recipe, cooktime); + output, recipe, cooktime, replacements); craftdef->registerCraft(def); } /* @@ -4144,8 +4153,17 @@ static int l_register_craft(lua_State *L) float burntime = getfloatfield_default(L, table, "burntime", 1.0); + CraftReplacements replacements; + lua_getfield(L, table, "replacements"); + if(!lua_isnil(L, -1)) + { + if(!read_craft_replacements(L, -1, replacements)) + throw LuaError(L, "Invalid replacements" + " (fuel recipe=\"" + recipe + "\")"); + } + CraftDefinition *def = new CraftDefinitionFuel( - recipe, burntime); + recipe, burntime, replacements); craftdef->registerCraft(def); } else -- cgit v1.2.3