update #39

Merged
milan merged 1 commit from develop into master 2021-08-14 17:54:46 +02:00
9 changed files with 45 additions and 27 deletions
Showing only changes of commit a887fcaaf2 - Show all commits

View file

@ -0,0 +1,3 @@
Mythrodak (fixed)
Christian_Soldier
CC 0 (1.0)

View file

@ -0,0 +1,3 @@
BadBoyHalo (fixed)
Christian_Soldier
CC 0 (1.0)

View file

@ -0,0 +1,3 @@
Sapnap (fixed)
Christian_Soldier
CC 0 (1.0)

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View file

@ -508,6 +508,9 @@ tubelib.register_node("tubelib_addons3:distributor",
on_pull_item = function(pos, side) on_pull_item = function(pos, side)
return tubelib.get_item(M(pos), "src") return tubelib.get_item(M(pos), "src")
end, end,
on_pull_stack = function(pos, side)
return tubelib.get_stack(M(pos), "src")
end,
on_push_item = function(pos, side, item) on_push_item = function(pos, side, item)
return tubelib.put_item(M(pos), "src", item) return tubelib.put_item(M(pos), "src", item)
end, end,

View file

@ -7,9 +7,9 @@
AGPL v3 AGPL v3
See LICENSE.txt for more information See LICENSE.txt for more information
pushing_chest.lua pushing_chest.lua
A high performance pushing chest A high performance pushing chest
]]-- ]]--
@ -49,11 +49,11 @@ local function allow_metadata_inventory_move(pos, from_list, from_index, to_list
end end
Cache[minetest.get_meta(pos):get_string("number")] = nil Cache[minetest.get_meta(pos):get_string("number")] = nil
return count return count
end end
local function keep_the_rest(meta, list, taken) local function keep_the_rest(meta, list, taken)
if taken then if taken then
local inv = meta:get_inventory() local inv = meta:get_inventory()
local rest = ItemStack(taken:get_name()) local rest = ItemStack(taken:get_name())
if not inv:contains_item(list, rest) then if not inv:contains_item(list, rest) then
inv:add_item(list, rest) inv:add_item(list, rest)
@ -65,7 +65,7 @@ local function keep_the_rest(meta, list, taken)
return taken return taken
end end
end end
end end
local function aging(pos, meta) local function aging(pos, meta)
local cnt = meta:get_int("tubelib_aging") + 1 local cnt = meta:get_int("tubelib_aging") + 1
@ -83,7 +83,7 @@ local function set_state(meta, state)
local number = meta:get_string("number") local number = meta:get_string("number")
meta:set_string("infotext", S("HighPerf Pushing Chest").." "..number..": "..state) meta:set_string("infotext", S("HighPerf Pushing Chest").." "..number..": "..state)
meta:set_string("state", state) meta:set_string("state", state)
end end
local function configured(pos, item) local function configured(pos, item)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -110,9 +110,10 @@ local function shift_items(pos, elapsed)
for i = 0,7 do for i = 0,7 do
local idx = ((i + offs) % 8) + 1 local idx = ((i + offs) % 8) + 1
local stack = inv:get_stack("shift", idx) local stack = inv:get_stack("shift", idx)
if stack:get_count() > 0 then local count = stack:get_count()
if count > 0 then
if tubelib.push_items(pos, "R", stack, player_name) then if tubelib.push_items(pos, "R", stack, player_name) then
-- The effort is needed here for the case the -- The effort is needed here for the case the
-- pusher pushes into its own chest. -- pusher pushes into its own chest.
local num = stack:get_count() local num = stack:get_count()
stack = inv:get_stack("shift", idx) stack = inv:get_stack("shift", idx)
@ -121,7 +122,12 @@ local function shift_items(pos, elapsed)
aging(pos, meta) aging(pos, meta)
return true return true
else else
set_state(meta, "blocked") -- Complete stack rejected
if count == stack:get_count() then
set_state(meta, "blocked")
else
inv:set_stack("shift", idx, stack)
end
end end
end end
end end
@ -153,7 +159,7 @@ local function defect(pos, meta)
node.name = "tubelib_addons3:pushing_chest_defect" node.name = "tubelib_addons3:pushing_chest_defect"
minetest.swap_node(pos, node) minetest.swap_node(pos, node)
return true return true
end end
-- code duplication of method "NodeStates:on_dig_node" (node_states.lua) -- code duplication of method "NodeStates:on_dig_node" (node_states.lua)
-- (in contrast to (all?) other tubelib nodes that can go defect class "NodeStates" isn't applied here) -- (in contrast to (all?) other tubelib nodes that can go defect class "NodeStates" isn't applied here)
@ -163,15 +169,15 @@ function on_dig_node(pos, node, player)
if (not cnt or cnt < 1) then if (not cnt or cnt < 1) then
cnt = 1 cnt = 1
end end
local is_defect = (cnt > AGING_LEVEL1) and ( math.random(math.max(1, math.floor(AGING_LEVEL2 / cnt))) == 1 ) local is_defect = (cnt > AGING_LEVEL1) and ( math.random(math.max(1, math.floor(AGING_LEVEL2 / cnt))) == 1 )
if is_defect then if is_defect then
defect(pos, meta) -- replace node with defect one defect(pos, meta) -- replace node with defect one
node = minetest.get_node(pos) node = minetest.get_node(pos)
end end
minetest.node_dig(pos, node, player) -- default behaviour (this function is called automatically if on_dig() callback isn't set) minetest.node_dig(pos, node, player) -- default behaviour (this function is called automatically if on_dig() callback isn't set)
end end
@ -204,10 +210,10 @@ minetest.register_node("tubelib_addons3:pushing_chest", {
inv:set_size('main', 32) inv:set_size('main', 32)
inv:set_size('shift', 8) inv:set_size('shift', 8)
end, end,
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local number = tubelib.add_node(pos, "tubelib_addons3:pushing_chest") local number = tubelib.add_node(pos, "tubelib_addons3:pushing_chest")
meta:set_string("player_name", placer:get_player_name()) meta:set_string("player_name", placer:get_player_name())
meta:set_string("number", number) meta:set_string("number", number)
meta:set_string("formspec", formspec()) meta:set_string("formspec", formspec())
@ -237,7 +243,7 @@ minetest.register_node("tubelib_addons3:pushing_chest", {
on_timer = shift_items, on_timer = shift_items,
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
paramtype2 = "facedir", paramtype2 = "facedir",
@ -264,10 +270,10 @@ minetest.register_node("tubelib_addons3:pushing_chest_defect", {
inv:set_size('main', 32) inv:set_size('main', 32)
inv:set_size('shift', 8) inv:set_size('shift', 8)
end, end,
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local number = tubelib.add_node(pos, "tubelib_addons3:pushing_chest") local number = tubelib.add_node(pos, "tubelib_addons3:pushing_chest")
meta:set_string("player_name", placer:get_player_name()) meta:set_string("player_name", placer:get_player_name())
meta:set_string("number", number) meta:set_string("number", number)
meta:set_string("formspec", formspec()) meta:set_string("formspec", formspec())
@ -291,7 +297,7 @@ minetest.register_node("tubelib_addons3:pushing_chest_defect", {
allow_metadata_inventory_move = allow_metadata_inventory_move, allow_metadata_inventory_move = allow_metadata_inventory_move,
on_rotate = screwdriver.disallow, on_rotate = screwdriver.disallow,
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
paramtype2 = "facedir", paramtype2 = "facedir",
@ -310,14 +316,14 @@ minetest.register_craft({
}, },
}) })
tubelib.register_node("tubelib_addons3:pushing_chest", tubelib.register_node("tubelib_addons3:pushing_chest",
{"tubelib_addons3:pushing_chest_defect"}, { {"tubelib_addons3:pushing_chest_defect"}, {
on_recv_message = function(pos, topic, payload) on_recv_message = function(pos, topic, payload)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if topic == "state" then if topic == "state" then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if inv:is_empty("main") then if inv:is_empty("main") then
return "empty" return "empty"
end end
return meta:get_string("state") return meta:get_string("state")
@ -368,7 +374,7 @@ tubelib.register_node("tubelib_addons3:pushing_chest",
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("tubelib_aging", 0) meta:set_int("tubelib_aging", 0)
meta:set_int("idx", 2) meta:set_int("idx", 2)
meta:set_string("formspec", formspec()) meta:set_string("formspec", formspec())
set_state(meta, "empty") set_state(meta, "empty")
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
@ -377,4 +383,4 @@ tubelib.register_node("tubelib_addons3:pushing_chest",
minetest.get_node_timer(pos):start(2) minetest.get_node_timer(pos):start(2)
return true return true
end, end,
}) })

View file

@ -105,7 +105,7 @@ function ts_doors.register_door(item, description, texture, sounds, recipe)
local groups = minetest.registered_nodes[item].groups local groups = minetest.registered_nodes[item].groups
local door_groups = {door=1} local door_groups = {door=1, not_in_creative_inventory=1}
for k, v in pairs(groups) do for k, v in pairs(groups) do
if k ~= "wood" then if k ~= "wood" then
door_groups[k] = v door_groups[k] = v