]> git.lizzy.rs Git - xdecor.git/commitdiff
Cooking ingredients : change variable of itemstring
authorkilbith <jeanpatrick.guerrero@gmail.com>
Thu, 28 Jan 2016 11:51:10 +0000 (12:51 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Thu, 28 Jan 2016 12:33:39 +0000 (13:33 +0100)
cooking.lua

index 1344f2a239d4791fea6fb44fe788c472cf9bc42f..206dd1b95c2e86f93e1bd22287330933d1cf1d34 100644 (file)
@@ -114,12 +114,12 @@ minetest.register_abm({
                local ingredients = {}
                local ingredients_list = {  -- Add more ingredients here that make a soup.
                        "apple", "mushroom", "honey", "pumpkin", "egg", "bread",
-                       "meat", "chicken"
+                       "meat", "chicken", "carrot", "potato"
                }
 
                for _, obj in pairs(objs) do
                        if obj and obj:get_luaentity() then
-                               local itemstring = obj:get_luaentity().itemstring:match("[^:]+$")
+                               local itemstring = obj:get_luaentity().itemstring:match(":([%w_]+)")
                                if not next(ingredients) then
                                        for _, rep in pairs(ingredients) do
                                                if itemstring == rep then return end
@@ -136,15 +136,13 @@ minetest.register_abm({
 
                if #ingredients >= 2 then
                        for _, obj in pairs(objs) do
-                               if obj and obj:get_luaentity() then
-                                       obj:remove()
-                               end
+                               if obj and obj:get_luaentity() then obj:remove() end
                        end
                        minetest.set_node(pos, {name="xdecor:cauldron_soup", param2=node.param2})
                end
 
-               local below_node = {x=pos.x, y=pos.y-1, z=pos.z}
-               if not minetest.get_node(below_node).name:find("fire") then
+               local node_under = {x=pos.x, y=pos.y-1, z=pos.z}
+               if not minetest.get_node(node_under).name:find("fire") then
                        minetest.set_node(pos, {name="xdecor:cauldron_idle", param2=node.param2})
                end
        end