Small simplifications
This commit is contained in:
parent
d8f4b8f578
commit
63949950bd
@ -528,10 +528,10 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, count, pl
|
||||
|
||||
if meta:get_string("lastMove") == "black" then
|
||||
minetest.chat_send_player(playerWhite, "["..os.date("%H:%M:%S").."] "..
|
||||
playerName.." has moved a "..pieceFrom:match("%a+:(%a+)")..", it's now your turn.")
|
||||
playerName.." has moved a "..pieceFrom:match(":(.-)%_")..", it's now your turn.")
|
||||
elseif meta:get_string("lastMove") == "white" then
|
||||
minetest.chat_send_player(playerBlack, "["..os.date("%H:%M:%S").."] "..
|
||||
playerName.." has moved a "..pieceFrom:match("%a+:(%a+)")..", it's now your turn.")
|
||||
playerName.." has moved a "..pieceFrom:match(":(.-)%_")..", it's now your turn.")
|
||||
end
|
||||
|
||||
if pieceTo:find("king") then
|
||||
|
@ -56,7 +56,7 @@ function enchanting.fields(pos, _, fields)
|
||||
local tool = inv:get_stack("tool", 1)
|
||||
local mese = inv:get_stack("mese", 1)
|
||||
local orig_wear = tool:get_wear()
|
||||
local mod, name = tool:get_name():match("([%w_]+):([%w_]+)")
|
||||
local mod, name = tool:get_name():match("(.*):(.*)")
|
||||
local enchanted_tool = mod..":enchanted_"..name.."_"..next(fields)
|
||||
|
||||
if mese:get_count() > 0 and minetest.registered_tools[enchanted_tool] then
|
||||
|
@ -77,9 +77,9 @@ xdecor.register("mailbox", {
|
||||
local function img_col(stack)
|
||||
if not stack then return "" end
|
||||
if stack.inventory_image ~= "" then
|
||||
return stack.inventory_image:match("([%w_]+)%.png")..".png"
|
||||
return stack.inventory_image:match("(.*)%.png")..".png"
|
||||
else
|
||||
return stack.tiles[1]:match("([%w_]+)%.png")..".png"
|
||||
return stack.tiles[1]:match("(.*)%.png")..".png"
|
||||
end
|
||||
end
|
||||
|
||||
@ -95,7 +95,7 @@ function mailbox.formspec(pos, owner, num)
|
||||
","..i..",#FFFFFF,x "..meta:get_string("stack"..i):match("%s(%d+)")..","
|
||||
|
||||
img = img..i.."="..img_col(minetest.registered_items[
|
||||
meta:get_string("stack"..i):match("([%w_:]+)")])..","
|
||||
meta:get_string("stack"..i):match("(.*)%s")])..","
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,8 +34,8 @@ local def = { -- Nodebox name, yield, definition.
|
||||
function worktable.get_recipe(item)
|
||||
if item:find("^group:") then
|
||||
if item:find("wool$") or item:find("dye$") then
|
||||
item = item:match("[^,:]+$")..":white"
|
||||
elseif minetest.registered_items["default:"..item:match("[^,:]+$")] then
|
||||
item = item:sub(7)..":white"
|
||||
elseif minetest.registered_items["default:"..item:sub(7)] then
|
||||
item = item:gsub("group:", "default:")
|
||||
else
|
||||
for node, definition in pairs(minetest.registered_items) do
|
||||
@ -217,7 +217,7 @@ function worktable.fields(pos, _, fields)
|
||||
local formspec = meta:to_table().fields.formspec
|
||||
local filter = formspec:match("filter;;([%w_:]+)") or ""
|
||||
local pagenum = tonumber(formspec:match("#FFFF00,(%d+)")) or 1
|
||||
local tab_id = tonumber(formspec:match("tabheader%[.*;(%d+)%;.*]")) or 1
|
||||
local tab_id = tonumber(formspec:match("tabheader%[.*;(%d+)%;.*%]")) or 1
|
||||
|
||||
if fields.back then
|
||||
worktable.formspecs.main(meta)
|
||||
@ -248,8 +248,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("[%w_]+:[%w_]+") and
|
||||
minetest.get_craft_recipe(item).items then
|
||||
if item:match(".-:") and minetest.get_craft_recipe(item).items then
|
||||
worktable.craftguide_formspec(meta, pagenum, item, 1, filter, tab_id)
|
||||
end
|
||||
end
|
||||
@ -262,7 +261,7 @@ function worktable.dig(pos)
|
||||
inv:is_empty("tool") and inv:is_empty("storage")
|
||||
end
|
||||
|
||||
function worktable.contains(table, element)
|
||||
function worktable.allowed(table, element)
|
||||
if table then
|
||||
for _, value in pairs(table) do
|
||||
if value == element then
|
||||
@ -282,10 +281,10 @@ end
|
||||
|
||||
function worktable.put(pos, listname, _, stack)
|
||||
local stackname = stack:get_name()
|
||||
local mod, node = stackname:match("([%w_]+):([%w_]+)")
|
||||
local mod, node = stackname:match("(.*):(.*)")
|
||||
|
||||
if (listname == "tool" and stack:get_wear() > 0 and stackname ~= "xdecor:hammer") or
|
||||
(listname == "input" and worktable.contains(nodes[mod], node)) or
|
||||
(listname == "input" and worktable.allowed(nodes[mod], node)) or
|
||||
(listname == "hammer" and stackname == "xdecor:hammer") or
|
||||
listname == "storage" or listname == "trash" then
|
||||
if listname == "trash" then trash_delete(pos) end
|
||||
@ -306,9 +305,11 @@ function worktable.take(pos, listname, _, stack, player)
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
function worktable.move(pos, from_list, _, to_list, _, count)
|
||||
if (from_list == "storage" and to_list == "storage") or to_list == "trash" then
|
||||
if to_list == "trash" then trash_delete(pos) end
|
||||
function worktable.move(pos, _, _, to_list, _, count)
|
||||
if to_list == "storage" then
|
||||
return count
|
||||
elseif to_list == "trash" then
|
||||
trash_delete(pos)
|
||||
return count
|
||||
end
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user