Add reverse recipes for hoes
authorMT-Modder <thomas.waits148@gmail.com>
Sat, 14 Feb 2015 00:21:36 +0000 (19:21 -0500)
committerBlockMen <nmuelll@web.de>
Sat, 28 Feb 2015 21:05:07 +0000 (22:05 +0100)
- Adds material for crafting (keeps def.recipe compatibility)
- Fix two typos in api documentation

game_api.txt
mods/farming/API.txt
mods/farming/api.lua
mods/farming/hoes.lua

index d2394903794bf38d348c90e0c69657dd7eb7420c..99c34a78dd200f0e4cf1ba320ee22f258a48853b 100644 (file)
@@ -125,7 +125,8 @@ farming.register_plant(name, Plant definition)
        description = "",       -- Description for tooltip
        inventory_image = "unknown_item.png",   -- Image to be used as wield- and inventory image
        max_uses = 30,  -- Uses until destroyed
-       recipe = {      -- Craft recipe
+       material = "",  -- Material for recipes
+       recipe = {      -- Craft recipe, if material isn't used
                {"air", "air", "air"},
                {"", "group:stick"},
                {"", "group:stick"},
@@ -138,7 +139,7 @@ farming.register_plant(name, Plant definition)
        description = "",       -- Description of seed item
        inventory_image = "unknown_item.png",   -- Image to be used as seed's wield- and inventory image
        steps = 8,      -- How many steps the plant has to grow, until it can be harvested
-       ^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber)
+       ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
        minlight = 13, -- Minimum light to grow
        maxlight = default.LIGHT_MAX -- Maximum light to grow
 }
index 9234bc44364940fcfc73ff552303473eecdf36a7..171c3c3804f7d574cfc1abe1f67bae4d9fb57bdb 100644 (file)
@@ -9,7 +9,8 @@ Hoe Definition
        description = "",       -- Description for tooltip
        inventory_image = "unknown_item.png",   -- Image to be used as wield- and inventory image
        max_uses = 30,  -- Uses until destroyed
-       recipe = {      -- Craft recipe
+       material = "",  -- Material for recipes
+       recipe = {      -- Craft recipe, if material isn't used
                {"air", "air", "air"},
                {"", "group:stick"},
                {"", "group:stick"},
@@ -21,7 +22,7 @@ Plant definition
        description = "",       -- Description of seed item
        inventory_image = "unknown_item.png",   -- Image to be used as seed's wield- and inventory image
        steps = 8,      -- How many steps the plant has to grow, until it can be harvested
-       ^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber)
+       ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
        minlight = 13, -- Minimum light to grow
        maxlight = default.LIGHT_MAX -- Maximum light to grow
 }
\ No newline at end of file
index 6ce996d8138f86c14ee63bd1483ce413663f6248..8c27233f6ef5f5251b9863e105b3fa69a181c686 100644 (file)
@@ -83,10 +83,30 @@ farming.register_hoe = function(name, def)
                end
        })
        -- Register its recipe
-       minetest.register_craft({
-               output = name:gsub(":", "", 1),
-               recipe = def.recipe
-       })
+       if def.material == nil then
+               minetest.register_craft({
+                       output = name:sub(2),
+                       recipe = def.recipe
+               })
+       else
+               minetest.register_craft({
+                       output = name:sub(2),
+                       recipe = {
+                               {def.material, def.material, ""},
+                               {"", "group:stick", ""},
+                               {"", "group:stick", ""}
+                       }
+               })
+               -- Reverse Recipe
+               minetest.register_craft({
+                       output = name:sub(2),
+                       recipe = {
+                               {"", def.material, def.material},
+                               {"", "group:stick", ""},
+                               {"", "group:stick", ""}
+                       }
+               })
+       end
 end
 
 -- Seed placement
index 084d586f7f9740976d4747f9eae860fc1ebc80ff..31da19ff9d09a399d37364492e48da7dccab19e7 100644 (file)
@@ -2,64 +2,40 @@ farming.register_hoe(":farming:hoe_wood", {
        description = "Wooden Hoe",
        inventory_image = "farming_tool_woodhoe.png",
        max_uses = 30,
-       recipe = {
-               {"group:wood", "group:wood"},
-               {"", "group:stick"},
-               {"", "group:stick"},
-       }
+       material = "group:wood"
 })
 
 farming.register_hoe(":farming:hoe_stone", {
        description = "Stone Hoe",
        inventory_image = "farming_tool_stonehoe.png",
        max_uses = 90,
-       recipe = {
-               {"group:stone", "group:stone"},
-               {"", "group:stick"},
-               {"", "group:stick"},
-       }
+       material = "group:stone"
 })
 
 farming.register_hoe(":farming:hoe_steel", {
        description = "Steel Hoe",
        inventory_image = "farming_tool_steelhoe.png",
        max_uses = 200,
-       recipe = {
-               {"default:steel_ingot", "default:steel_ingot"},
-               {"", "group:stick"},
-               {"", "group:stick"},
-       }
+       material = "default:steel_ingot"
 })
 
 farming.register_hoe(":farming:hoe_bronze", {
        description = "Bronze Hoe",
        inventory_image = "farming_tool_bronzehoe.png",
        max_uses = 220,
-       recipe = {
-               {"default:bronze_ingot", "default:bronze_ingot"},
-               {"", "group:stick"},
-               {"", "group:stick"},
-       }
+       material = "default:bronze_ingot"
 })
 
 farming.register_hoe(":farming:hoe_mese", {
        description = "Mese Hoe",
        inventory_image = "farming_tool_mesehoe.png",
        max_uses = 350,
-       recipe = {
-               {"default:mese_crystal", "default:mese_crystal"},
-               {"", "group:stick"},
-               {"", "group:stick"},
-       }
+       material = "default:mese_crystal"
 })
 
 farming.register_hoe(":farming:hoe_diamond", {
        description = "Diamond Hoe",
        inventory_image = "farming_tool_diamondhoe.png",
        max_uses = 500,
-       recipe = {
-               {"default:diamond", "default:diamond"},
-               {"", "group:stick"},
-               {"", "group:stick"},
-       }
+       material = "default:diamond"
 })