Script API: Make the craft recipe field 'method' consistent
authorSmallJoker <mk939@ymail.com>
Sat, 30 Jul 2016 10:50:22 +0000 (12:50 +0200)
committerparamat <mat.gregory@virginmedia.com>
Thu, 18 Aug 2016 19:43:49 +0000 (20:43 +0100)
src/script/lua_api/l_craft.cpp

index d135c689f86a8f0ffdd759e29d8fd7c8effa5452..2236566de1caabac46fb0886a2ae6976a9ab6bed 100644 (file)
@@ -422,20 +422,28 @@ static void push_craft_recipe(lua_State *L, IGameDef *gdef,
        }
        lua_setfield(L, -2, "items");
        setintfield(L, -1, "width", input.width);
+
+       std::string method_s;
        switch (input.method) {
        case CRAFT_METHOD_NORMAL:
-               lua_pushstring(L, "normal");
+               method_s = "normal";
                break;
        case CRAFT_METHOD_COOKING:
-               lua_pushstring(L, "cooking");
+               method_s = "cooking";
                break;
        case CRAFT_METHOD_FUEL:
-               lua_pushstring(L, "fuel");
+               method_s = "fuel";
                break;
        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_pushstring(L, output.item.c_str());
        lua_setfield(L, -2, "output");
 }