]> git.lizzy.rs Git - xdecor.git/commitdiff
Crafting guide : simplify group to node determination
authorkilbith <jeanpatrick.guerrero@gmail.com>
Sun, 3 Jan 2016 14:07:12 +0000 (15:07 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Sun, 3 Jan 2016 14:13:53 +0000 (15:13 +0100)
hive.lua
worktable.lua

index 5ff11398e019a488b10259bf7729b8a0ce8b8b3a..c942c18b38c02cff247040b65d44a1d299e2a6ed 100644 (file)
--- a/hive.lua
+++ b/hive.lua
@@ -39,7 +39,7 @@ xdecor.register("hive", {
 
 minetest.register_abm({
        nodenames = {"xdecor:hive"},
-       interval = 20, chance = 10,
+       interval = 30, chance = 10,
        action = function(pos, _, _, _)
                local inv = minetest.get_meta(pos):get_inventory()
                local honeystack = inv:get_stack("honey", 1)
index c5a01432e386b178398ee2eeba0c7a84b09162a8..c67b5d74e2ad5377b595886f115870598d3b6c53 100644 (file)
@@ -122,39 +122,20 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
                for k, def in pairs(stack_items) do
                        craft[#craft+1] = def
                        if def and def:find("^group:") then
-                               if def:find("wool") then
+                               if def:find("wool$") then
                                        def = "wool:white"
-                               elseif def:find("dye") then
-                                       local dye_color = def:match(".*_([%w_]+)")
-                                       def = "dye:"..dye_color
-                               elseif def:find("flower") then
-                                       local flower_color = def:match(".*_([%w_]+)")
-                                       if flower_color == "red" then
-                                               def = "flowers:rose"
-                                       elseif flower_color == "yellow" then
-                                               def = "flowers:dandelion_yellow"
-                                       elseif flower_color == "white" then
-                                               def = "flowers:dandelion_white"
-                                       elseif flower_color == "blue" then
-                                               def = "flowers:geranium"
-                                       elseif flower_color == "orange" then
-                                               def = "flowers:tulip"
-                                       elseif flower_color == "violet" then
-                                               def = "flowers:viola"
-                                       elseif def:find("^group:flower$") then
-                                               def = "flowers:rose"
-                                       end
+                               elseif def:find("dye$") then
+                                       def = "dye:white"
                                else
-                                       if minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
+                                       if minetest.registered_items["default:"..def:match("^group:([%w_]+)$")] then
                                                def = def:gsub("group", "default")
                                        else
                                                for node, definition in pairs(minetest.registered_items) do
                                                for group in pairs(definition.groups) do
-                                                       if def:match("^group:"..group) then
-                                                               if inv:get_stack("craft_output_recipe", k):is_empty() or
-                                                                               node:find("^default:") then
-                                                                       inv:set_stack("craft_output_recipe", k, node)
-                                                               end
+                                                       if def:match("^group:"..group.."$") or
+                                                                       ((def:find("dye") or def:find("flower")) and
+                                                                       group == def:match("^group:.*,("..group..")")) then
+                                                               def = node
                                                        end
                                                end
                                                end
@@ -162,9 +143,7 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
                                end
                        end
 
-                       if not def:find("^group:") then
-                               inv:set_stack("craft_output_recipe", k, def)
-                       end
+                       inv:set_stack("craft_output_recipe", k, def)
                end
 
                formspec = formspec..[[ image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]