mirror of
https://github.com/joe7575/techpack.git
synced 2024-09-12 07:58:39 +02:00
forceload and quarry bugfixes
This commit is contained in:
parent
1b0992734f
commit
958495acee
@ -42,6 +42,24 @@ local function chat(player, text)
|
|||||||
minetest.chat_send_player(player:get_player_name(), "[Tubelib] "..text)
|
minetest.chat_send_player(player:get_player_name(), "[Tubelib] "..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_node_lvm(pos)
|
||||||
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
if node then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
local vm = minetest.get_voxel_manip()
|
||||||
|
local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
|
||||||
|
local data = vm:get_data()
|
||||||
|
local param2_data = vm:get_param2_data()
|
||||||
|
local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge})
|
||||||
|
local idx = area:index(pos.x, pos.y, pos.z)
|
||||||
|
node = {
|
||||||
|
name = minetest.get_name_from_content_id(data[idx]),
|
||||||
|
param2 = param2_data[idx]
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
|
||||||
local function calc_area(pos)
|
local function calc_area(pos)
|
||||||
local xpos = (math.floor(pos.x / 16) * 16)
|
local xpos = (math.floor(pos.x / 16) * 16)
|
||||||
local ypos = (math.floor(pos.y / 16) * 16)
|
local ypos = (math.floor(pos.y / 16) * 16)
|
||||||
@ -73,6 +91,10 @@ local function get_pos_list(player)
|
|||||||
return minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
return minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function set_pos_list(player, lPos)
|
||||||
|
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
||||||
|
end
|
||||||
|
|
||||||
local function get_data(pos, player)
|
local function get_data(pos, player)
|
||||||
local pos1, pos2 = calc_area(pos)
|
local pos1, pos2 = calc_area(pos)
|
||||||
local num = #minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or 0
|
local num = #minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or 0
|
||||||
@ -175,9 +197,15 @@ if tubelib.max_num_forceload_blocks > 0 then
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
local lPos = {}
|
||||||
for _,pos in ipairs(get_pos_list(player)) do
|
for _,pos in ipairs(get_pos_list(player)) do
|
||||||
|
local node = get_node_lvm(pos)
|
||||||
|
if node.name == "tubelib:forceload" then
|
||||||
minetest.forceload_block(pos, true)
|
minetest.forceload_block(pos, true)
|
||||||
|
lPos[#lPos+1] = pos
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
set_pos_list(player, lPos)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
@ -363,7 +363,7 @@ function NodeStates:on_node_load(pos)
|
|||||||
|
|
||||||
-- legacy node number/state/counter?
|
-- legacy node number/state/counter?
|
||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
if number ~= "" then
|
if number ~= "" and number ~= nil then
|
||||||
meta:set_string("tubelib_number", number)
|
meta:set_string("tubelib_number", number)
|
||||||
meta:set_int("tubelib_state", tubelib.state(meta:get_int("running")))
|
meta:set_int("tubelib_state", tubelib.state(meta:get_int("running")))
|
||||||
if self.has_item_meter then
|
if self.has_item_meter then
|
||||||
|
@ -459,9 +459,11 @@ tubelib.register_node("tubelib_addons1:quarry",
|
|||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_node_load = function(pos)
|
-- Function has some negative impact on the cycle time for the
|
||||||
State:on_node_load(pos)
|
-- cobble generator mode (5s on/5s off)
|
||||||
end,
|
-- on_node_load = function(pos)
|
||||||
|
-- State:on_node_load(pos)
|
||||||
|
-- end,
|
||||||
on_node_repair = function(pos)
|
on_node_repair = function(pos)
|
||||||
return State:on_node_repair(pos)
|
return State:on_node_repair(pos)
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user