]> git.lizzy.rs Git - xdecor.git/commitdiff
More cleanup
authorkilbith <jeanpatrick.guerrero@gmail.com>
Fri, 29 Jan 2016 21:50:53 +0000 (22:50 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Fri, 29 Jan 2016 22:10:34 +0000 (23:10 +0100)
cooking.lua
enchanting.lua
mailbox.lua
worktable.lua

index 206dd1b95c2e86f93e1bd22287330933d1cf1d34..41624aa9ec0d9d3612e164bdffba56fd9a7528e2 100644 (file)
@@ -1,3 +1,9 @@
+-- Add more ingredients here that make a soup.
+local ingredients_list = {
+       "apple", "mushroom", "honey", "pumpkin", "egg", "bread", "meat",
+       "chicken", "carrot", "potato"
+}
+
 local cauldron_cbox = {
        {0,  0, 0,  16, 16, 0},
        {0,  0, 16, 16, 16, 0},
@@ -112,11 +118,6 @@ minetest.register_abm({
                if not objs then return end
 
                local ingredients = {}
-               local ingredients_list = {  -- Add more ingredients here that make a soup.
-                       "apple", "mushroom", "honey", "pumpkin", "egg", "bread",
-                       "meat", "chicken", "carrot", "potato"
-               }
-
                for _, obj in pairs(objs) do
                        if obj and obj:get_luaentity() then
                                local itemstring = obj:get_luaentity().itemstring:match(":([%w_]+)")
@@ -127,7 +128,7 @@ minetest.register_abm({
                                end
 
                                for _, ing in pairs(ingredients_list) do
-                                       if itemstring and itemstring:match(ing) then
+                                       if itemstring and itemstring:find(ing) then
                                                ingredients[#ingredients+1] = itemstring
                                        end
                                end
index d264b1f5bfdf5c437f7f07982398e39fa8e23ee6..73754f8cb8a30bfac019345156e9b3d46f629236 100644 (file)
@@ -69,7 +69,7 @@ function enchanting.on_put(pos, listname, _, stack)
                for k, v in pairs({"axe, pick, shovel",
                                "chestplate, leggings, helmet",
                                "sword", "boots"}) do
-                       if v:match(stack:get_name():match(":(.-)%_")) then
+                       if v:find(stack:get_name():match(":(%w+)")) then
                                enchanting.formspec(pos, k)
                        end
                end
@@ -101,7 +101,7 @@ end
 
 local function allowed(tool)
        for item in pairs(minetest.registered_tools) do
-               if item:match("enchanted_"..tool) then return true end
+               if item:find("enchanted_"..tool) then return true end
        end
        return false
 end
index 1f99e14b12c2003006f7629743a060c00c541c67..7d95e2fb3da8a17fbbdbfe94bfbdfbd1656fdb2d 100644 (file)
@@ -41,10 +41,8 @@ xdecor.register("mailbox", {
                return inv:is_empty("mailbox") and player and player_name == owner
        end,
        on_metadata_inventory_put = function(pos, listname, _, stack, player)
-               local inv = minetest.get_meta(pos):get_inventory()
-               local player_name = player:get_player_name()
                local meta = minetest.get_meta(pos)
-               local stack_name = stack:get_name().." "..stack:get_count()
+               local inv = meta:get_inventory()
 
                if listname == "drop" and inv:room_for_item("mailbox", stack) then
                        inv:remove_item("drop", stack)
@@ -54,22 +52,20 @@ xdecor.register("mailbox", {
                                meta:set_string("giver"..i, meta:get_string("giver"..(i-1)))
                                meta:set_string("stack"..i, meta:get_string("stack"..(i-1)))
                        end
-                       meta:set_string("giver1", player_name)
-                       meta:set_string("stack1", stack_name)
+
+                       meta:set_string("giver1", player:get_player_name())
+                       meta:set_string("stack1", stack:get_name().." "..stack:get_count())
                end
        end,
        allow_metadata_inventory_put = function(pos, listname, _, stack, player)
-               local player_name = player:get_player_name()
                if listname == "drop" then
-                       local meta = minetest.get_meta(pos)
-                       local inv = meta:get_inventory()
+                       local inv = minetest.get_meta(pos):get_inventory()
                        if inv:room_for_item("mailbox", stack) then
                                return -1
                        else
-                               minetest.chat_send_player(player_name, "The mailbox is full")
+                               minetest.chat_send_player(player:get_player_name(), "The mailbox is full")
                        end
                end
-
                return 0
        end
 })
index 06c04196a6743acf7c9db6223c3b62e5a51bf5ca..a2777177d47fb04449a216cbaf818c8019bdaf85 100644 (file)
@@ -270,7 +270,7 @@ function worktable.fields(pos, _, fields)
                worktable.craftguide_formspec(meta, pagenum, nil, 1, filter, tab_id)
        else
                for item in pairs(fields) do
-                       if item:match(".-:") and minetest.get_craft_recipe(item).items then
+                       if item:find(":") and minetest.get_craft_recipe(item).items then
                                worktable.craftguide_formspec(meta, pagenum, item, 1, filter, tab_id)
                        end
                end