Work Table : better ordering of functions
This commit is contained in:
parent
0bef7b1e4a
commit
cd0c434e00
@ -143,6 +143,21 @@ function worktable.craftguide_items(meta, filter)
|
|||||||
return items_list
|
return items_list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function worktable.get_output(inv, input, name)
|
||||||
|
if inv:is_empty("input") then
|
||||||
|
inv:set_list("forms", {}) return
|
||||||
|
end
|
||||||
|
|
||||||
|
local output = {}
|
||||||
|
for _, n in pairs(worktable.defs) do
|
||||||
|
local count = math.min(n[2] * input:get_count(), input:get_stack_max())
|
||||||
|
local item = name.."_"..n[1]
|
||||||
|
if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
|
||||||
|
output[#output+1] = item.." "..count
|
||||||
|
end
|
||||||
|
inv:set_list("forms", output)
|
||||||
|
end
|
||||||
|
|
||||||
worktable.formspecs = {
|
worktable.formspecs = {
|
||||||
crafting = function(meta)
|
crafting = function(meta)
|
||||||
meta:set_string("formspec", [[ size[8,7;]
|
meta:set_string("formspec", [[ size[8,7;]
|
||||||
@ -268,31 +283,12 @@ function worktable.take(_, listname, _, stack, player)
|
|||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
function worktable.on_move(pos, _, _, to_list, _, count)
|
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
|
||||||
if to_list == "trash" then inv:set_list("trash", {}) end
|
|
||||||
end
|
|
||||||
|
|
||||||
function worktable.move(pos, _, _, to_list, _, count)
|
function worktable.move(pos, _, _, to_list, _, count)
|
||||||
if to_list == "storage" or to_list == "trash" then return count end
|
if to_list == "storage" or to_list == "trash" then return count end
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function worktable.get_output(inv, input, name)
|
|
||||||
if inv:is_empty("input") then
|
|
||||||
inv:set_list("forms", {}) return
|
|
||||||
end
|
|
||||||
|
|
||||||
local output = {}
|
|
||||||
for _, n in pairs(worktable.defs) do
|
|
||||||
local count = math.min(n[2] * input:get_count(), input:get_stack_max())
|
|
||||||
local item = name.."_"..n[1]
|
|
||||||
if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
|
|
||||||
output[#output+1] = item.." "..count
|
|
||||||
end
|
|
||||||
inv:set_list("forms", output)
|
|
||||||
end
|
|
||||||
|
|
||||||
function worktable.on_put(pos, listname, _, stack)
|
function worktable.on_put(pos, listname, _, stack)
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
if listname == "input" then
|
if listname == "input" then
|
||||||
@ -318,6 +314,11 @@ function worktable.on_take(pos, listname, index, stack)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function worktable.on_move(pos, _, _, to_list, _, count)
|
||||||
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
if to_list == "trash" then inv:set_list("trash", {}) end
|
||||||
|
end
|
||||||
|
|
||||||
xdecor.register("worktable", {
|
xdecor.register("worktable", {
|
||||||
description = "Work Table",
|
description = "Work Table",
|
||||||
groups = {cracky=2, choppy=2, oddly_breakable_by_hand=1},
|
groups = {cracky=2, choppy=2, oddly_breakable_by_hand=1},
|
||||||
|
Loading…
Reference in New Issue
Block a user