More cleanup

This commit is contained in:
kilbith 2016-01-29 22:50:53 +01:00
parent 5726d9ba2a
commit 522dc7ef39
4 changed files with 16 additions and 19 deletions

View 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 = { local cauldron_cbox = {
{0, 0, 0, 16, 16, 0}, {0, 0, 0, 16, 16, 0},
{0, 0, 16, 16, 16, 0}, {0, 0, 16, 16, 16, 0},
@ -112,11 +118,6 @@ minetest.register_abm({
if not objs then return end if not objs then return end
local ingredients = {} 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 for _, obj in pairs(objs) do
if obj and obj:get_luaentity() then if obj and obj:get_luaentity() then
local itemstring = obj:get_luaentity().itemstring:match(":([%w_]+)") local itemstring = obj:get_luaentity().itemstring:match(":([%w_]+)")
@ -127,7 +128,7 @@ minetest.register_abm({
end end
for _, ing in pairs(ingredients_list) do 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 ingredients[#ingredients+1] = itemstring
end end
end end

View File

@ -69,7 +69,7 @@ function enchanting.on_put(pos, listname, _, stack)
for k, v in pairs({"axe, pick, shovel", for k, v in pairs({"axe, pick, shovel",
"chestplate, leggings, helmet", "chestplate, leggings, helmet",
"sword", "boots"}) do "sword", "boots"}) do
if v:match(stack:get_name():match(":(.-)%_")) then if v:find(stack:get_name():match(":(%w+)")) then
enchanting.formspec(pos, k) enchanting.formspec(pos, k)
end end
end end
@ -101,7 +101,7 @@ end
local function allowed(tool) local function allowed(tool)
for item in pairs(minetest.registered_tools) do 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 end
return false return false
end end

View File

@ -41,10 +41,8 @@ xdecor.register("mailbox", {
return inv:is_empty("mailbox") and player and player_name == owner return inv:is_empty("mailbox") and player and player_name == owner
end, end,
on_metadata_inventory_put = function(pos, listname, _, stack, player) 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 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 if listname == "drop" and inv:room_for_item("mailbox", stack) then
inv:remove_item("drop", stack) 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("giver"..i, meta:get_string("giver"..(i-1)))
meta:set_string("stack"..i, meta:get_string("stack"..(i-1))) meta:set_string("stack"..i, meta:get_string("stack"..(i-1)))
end 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
end, end,
allow_metadata_inventory_put = function(pos, listname, _, stack, player) allow_metadata_inventory_put = function(pos, listname, _, stack, player)
local player_name = player:get_player_name()
if listname == "drop" then if listname == "drop" then
local meta = minetest.get_meta(pos) local inv = minetest.get_meta(pos):get_inventory()
local inv = meta:get_inventory()
if inv:room_for_item("mailbox", stack) then if inv:room_for_item("mailbox", stack) then
return -1 return -1
else 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
end end
return 0 return 0
end end
}) })

View File

@ -270,7 +270,7 @@ function worktable.fields(pos, _, fields)
worktable.craftguide_formspec(meta, pagenum, nil, 1, filter, tab_id) worktable.craftguide_formspec(meta, pagenum, nil, 1, filter, tab_id)
else else
for item in pairs(fields) do 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) worktable.craftguide_formspec(meta, pagenum, item, 1, filter, tab_id)
end end
end end