Worktable : style cleaning

This commit is contained in:
jp 2015-11-22 12:03:08 +01:00
parent a27c91d0f9
commit 7978618ac0

View File

@ -69,8 +69,7 @@ function worktable.fields(pos, _, fields, sender)
if fields.storage then if fields.storage then
minetest.show_formspec(player, "", worktable.storage(pos)) minetest.show_formspec(player, "", worktable.storage(pos))
end elseif fields.craft then
if fields.craft then
minetest.show_formspec(player, "", worktable.crafting(pos)) minetest.show_formspec(player, "", worktable.crafting(pos))
end end
end end
@ -79,7 +78,8 @@ function worktable.dig(pos, _)
local inv = minetest.get_meta(pos):get_inventory() local inv = minetest.get_meta(pos):get_inventory()
if not inv:is_empty("input") or not inv:is_empty("hammer") or not if not inv:is_empty("input") or not inv:is_empty("hammer") or not
inv:is_empty("tool") or not inv:is_empty("storage") then inv:is_empty("tool") or not inv:is_empty("storage") then
return false end return false
end
return true return true
end end
@ -97,14 +97,12 @@ function worktable.put(_, listname, _, stack, _)
local count = stack:get_count() local count = stack:get_count()
local mod, node = stn:match("([%a_]+):([%a_]+)") local mod, node = stn:match("([%a_]+):([%a_]+)")
if listname == "forms" then return 0 end if listname == "forms" then return 0
if listname == "input" then elseif listname == "input" then
if not worktable.contains(nodes[mod], node) then return 0 end if not worktable.contains(nodes[mod], node) then return 0 end
end elseif listname == "hammer" then
if listname == "hammer" then
if stn ~= "xdecor:hammer" then return 0 end if stn ~= "xdecor:hammer" then return 0 end
end elseif listname == "tool" then
if listname == "tool" then
local tdef = minetest.registered_tools[stn] local tdef = minetest.registered_tools[stn]
local twear = stack:get_wear() local twear = stack:get_wear()
if not (tdef and twear > 0) then return 0 end if not (tdef and twear > 0) then return 0 end
@ -125,8 +123,8 @@ function worktable.take(pos, listname, _, stack, _)
end end
function worktable.move(_, from_list, _, to_list, _, count, _) function worktable.move(_, from_list, _, to_list, _, count, _)
if from_list == "storage" and to_list == "storage" then if from_list == "storage" and to_list == "storage" then return count end
return count else return 0 end return 0
end end
local function update_inventory(inv, inputstack) local function update_inventory(inv, inputstack)
@ -138,9 +136,9 @@ local function update_inventory(inv, inputstack)
local input = inv:get_stack("input", 1) local input = inv:get_stack("input", 1)
local mod, node = mat:match("([%a_]+):([%a_]+)") local mod, node = mat:match("([%a_]+):([%a_]+)")
local count = math.min(n[2] * input:get_count(), inputstack:get_stack_max()) local count = math.min(n[2] * input:get_count(), inputstack:get_stack_max())
if not worktable.contains(nodes[mod], node) then return end if not worktable.contains(nodes[mod], node) then return end
output[#output+1] = string.format("%s_%s %d", mat, n[1], count) output[#output+1] = mat.."_"..n[1].." "..count
end end
inv:set_list("forms", output) inv:set_list("forms", output)
end end