Prevent use the worktable output when a disallowed node is switched with the original input stack
This commit is contained in:
parent
3ac5bad7c6
commit
6131066619
@ -1,7 +1,7 @@
|
|||||||
local worktable = {}
|
local worktable = {}
|
||||||
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
|
||||||
|
|
||||||
xdecor.worktable_nodes = { -- Nodes allowed to be cut. Mod name = {node name}.
|
local nodes = { -- Nodes allowed to be cut. Mod name = {node name}.
|
||||||
default = {"wood", "junglewood", "pine_wood", "acacia_wood",
|
default = {"wood", "junglewood", "pine_wood", "acacia_wood",
|
||||||
"tree", "jungletree", "pine_tree", "acacia_tree",
|
"tree", "jungletree", "pine_tree", "acacia_tree",
|
||||||
"cobble", "mossycobble", "desert_cobble",
|
"cobble", "mossycobble", "desert_cobble",
|
||||||
@ -97,7 +97,7 @@ function worktable.put(_, listname, _, stack, _)
|
|||||||
|
|
||||||
if listname == "forms" then return 0 end
|
if listname == "forms" then return 0 end
|
||||||
if listname == "input" then
|
if listname == "input" then
|
||||||
if not worktable.contains(xdecor.worktable_nodes[mod], node) then return 0 end
|
if not worktable.contains(nodes[mod], node) then return 0 end
|
||||||
end
|
end
|
||||||
if listname == "hammer" then
|
if listname == "hammer" then
|
||||||
if stn ~= "xdecor:hammer" then return 0 end
|
if stn ~= "xdecor:hammer" then return 0 end
|
||||||
@ -110,8 +110,15 @@ function worktable.put(_, listname, _, stack, _)
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
function worktable.take(_, listname, _, stack, _)
|
function worktable.take(pos, listname, _, stack, _)
|
||||||
if listname == "forms" then return -1 end
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
|
local inputstack = inv:get_stack("input", 1):get_name()
|
||||||
|
local mod, node = inputstack:match("([%a_]+):([%a_]+)")
|
||||||
|
|
||||||
|
if listname == "forms" then
|
||||||
|
if not worktable.contains(nodes[mod], node) then return 0 end
|
||||||
|
return -1
|
||||||
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -127,8 +134,10 @@ local function update_inventory(inv, inputstack)
|
|||||||
for _, n in pairs(def) do
|
for _, n in pairs(def) do
|
||||||
local mat = inputstack:get_name()
|
local mat = inputstack:get_name()
|
||||||
local input = inv:get_stack("input", 1)
|
local input = inv:get_stack("input", 1)
|
||||||
|
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
|
||||||
output[#output+1] = string.format("%s_%s %d", mat, n[1], count)
|
output[#output+1] = string.format("%s_%s %d", mat, n[1], count)
|
||||||
end
|
end
|
||||||
inv:set_list("forms", output)
|
inv:set_list("forms", output)
|
||||||
@ -173,7 +182,7 @@ xdecor.register("worktable", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, d in pairs(def) do
|
for _, d in pairs(def) do
|
||||||
for mod, n in pairs(xdecor.worktable_nodes) do
|
for mod, n in pairs(nodes) do
|
||||||
for _, name in pairs(n) do
|
for _, name in pairs(n) do
|
||||||
local ndef = minetest.registered_nodes[mod..":"..name]
|
local ndef = minetest.registered_nodes[mod..":"..name]
|
||||||
if ndef then
|
if ndef then
|
||||||
|
Loading…
Reference in New Issue
Block a user