Script API: Make the craft recipe field 'method' consistent

This commit is contained in:
SmallJoker 2016-07-30 12:50:22 +02:00 committed by paramat
parent 986d70ccec
commit 5c0e659516
1 changed files with 12 additions and 4 deletions

View File

@ -422,20 +422,28 @@ static void push_craft_recipe(lua_State *L, IGameDef *gdef,
} }
lua_setfield(L, -2, "items"); lua_setfield(L, -2, "items");
setintfield(L, -1, "width", input.width); setintfield(L, -1, "width", input.width);
std::string method_s;
switch (input.method) { switch (input.method) {
case CRAFT_METHOD_NORMAL: case CRAFT_METHOD_NORMAL:
lua_pushstring(L, "normal"); method_s = "normal";
break; break;
case CRAFT_METHOD_COOKING: case CRAFT_METHOD_COOKING:
lua_pushstring(L, "cooking"); method_s = "cooking";
break; break;
case CRAFT_METHOD_FUEL: case CRAFT_METHOD_FUEL:
lua_pushstring(L, "fuel"); method_s = "fuel";
break; break;
default: default:
lua_pushstring(L, "unknown"); method_s = "unknown";
} }
lua_pushstring(L, method_s.c_str());
lua_setfield(L, -2, "method");
// Deprecated, only for compatibility's sake
lua_pushstring(L, method_s.c_str());
lua_setfield(L, -2, "type"); lua_setfield(L, -2, "type");
lua_pushstring(L, output.item.c_str()); lua_pushstring(L, output.item.c_str());
lua_setfield(L, -2, "output"); lua_setfield(L, -2, "output");
} }