diff options
author | Kahrl <kahrl@gmx.net> | 2012-02-11 18:10:13 +0100 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-06-06 00:22:34 +0300 |
commit | e070f1e5250b6853788cb827bb2f46ecdbe300a8 (patch) | |
tree | 134c70f4ea01c12db0b12b5352cec7b3f8b13300 /src/scriptapi.cpp | |
parent | 430d6e1cca2c970aa6b78194526ce3c28cca8656 (diff) | |
download | hax-minetest-server-e070f1e5250b6853788cb827bb2f46ecdbe300a8.tar.gz hax-minetest-server-e070f1e5250b6853788cb827bb2f46ecdbe300a8.zip |
Allow replacements in cooking and fuel recipes
Diffstat (limited to '')
-rw-r--r-- | src/scriptapi.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
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 |