mirror of
https://codeberg.org/minenux/minetest-mod-xdecor
synced 2023-10-20 21:43:39 -07:00
Work table : change trash deleting method
This commit is contained in:
parent
da7cec38f2
commit
0bef7b1e4a
@ -247,11 +247,6 @@ function worktable.dig(pos)
|
|||||||
inv:is_empty("tool") and inv:is_empty("storage")
|
inv:is_empty("tool") and inv:is_empty("storage")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function trash_delete(pos)
|
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
|
||||||
minetest.after(0, function() inv:set_stack("trash", 1, "") end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function worktable.put(pos, listname, _, stack)
|
function worktable.put(pos, listname, _, stack)
|
||||||
local stackname = stack:get_name()
|
local stackname = stack:get_name()
|
||||||
if (listname == "tool" and stack:get_wear() > 0 and
|
if (listname == "tool" and stack:get_wear() > 0 and
|
||||||
@ -259,7 +254,6 @@ function worktable.put(pos, listname, _, stack)
|
|||||||
(listname == "input" and worktable.nodes(minetest.registered_nodes[stackname])) or
|
(listname == "input" and worktable.nodes(minetest.registered_nodes[stackname])) or
|
||||||
(listname == "hammer" and stackname == "xdecor:hammer") or
|
(listname == "hammer" and stackname == "xdecor:hammer") or
|
||||||
listname == "storage" or listname == "trash" then
|
listname == "storage" or listname == "trash" then
|
||||||
if listname == "trash" then trash_delete(pos) end
|
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
@ -274,11 +268,13 @@ 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
|
if to_list == "storage" or to_list == "trash" then return count end
|
||||||
if to_list == "trash" then trash_delete(pos) end
|
|
||||||
return count
|
|
||||||
end
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -298,10 +294,12 @@ function worktable.get_output(inv, input, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function worktable.on_put(pos, listname, _, stack)
|
function worktable.on_put(pos, listname, _, stack)
|
||||||
if listname == "input" then
|
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
if listname == "input" then
|
||||||
local input = inv:get_stack("input", 1)
|
local input = inv:get_stack("input", 1)
|
||||||
worktable.get_output(inv, input, stack:get_name())
|
worktable.get_output(inv, input, stack:get_name())
|
||||||
|
elseif listname == "trash" then
|
||||||
|
inv:set_list("trash", {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -335,6 +333,7 @@ xdecor.register("worktable", {
|
|||||||
on_receive_fields = worktable.fields,
|
on_receive_fields = worktable.fields,
|
||||||
on_metadata_inventory_put = worktable.on_put,
|
on_metadata_inventory_put = worktable.on_put,
|
||||||
on_metadata_inventory_take = worktable.on_take,
|
on_metadata_inventory_take = worktable.on_take,
|
||||||
|
on_metadata_inventory_move = worktable.on_move,
|
||||||
allow_metadata_inventory_put = worktable.put,
|
allow_metadata_inventory_put = worktable.put,
|
||||||
allow_metadata_inventory_take = worktable.take,
|
allow_metadata_inventory_take = worktable.take,
|
||||||
allow_metadata_inventory_move = worktable.move
|
allow_metadata_inventory_move = worktable.move
|
||||||
|
Loading…
x
Reference in New Issue
Block a user