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
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
","..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
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
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)
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
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
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
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