From: kilbith Date: Fri, 29 Jan 2016 21:50:53 +0000 (+0100) Subject: More cleanup X-Git-Tag: 1.0~162 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=522dc7ef39feeff51057226dc184a5c04c6ecf96;hp=5726d9ba2aabcc52711828c480f4a978ed64993a;p=xdecor.git More cleanup --- diff --git a/cooking.lua b/cooking.lua index 206dd1b..41624aa 100644 --- a/cooking.lua +++ b/cooking.lua @@ -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 diff --git a/enchanting.lua b/enchanting.lua index d264b1f..73754f8 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -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 diff --git a/mailbox.lua b/mailbox.lua index 1f99e14..7d95e2f 100644 --- a/mailbox.lua +++ b/mailbox.lua @@ -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 }) diff --git a/worktable.lua b/worktable.lua index 06c0419..a277717 100644 --- a/worktable.lua +++ b/worktable.lua @@ -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