Use minetest.load_area
everywhere (#287)
also change `technic.get_or_load_node` to return loaded node instead of nil
This commit is contained in:
parent
54d5e2e6ca
commit
5ad0a8c229
@ -101,13 +101,12 @@ function technic.use_RE_charge(stack, amount)
|
||||
return true
|
||||
end
|
||||
|
||||
-- If the node is loaded, returns it. If it isn't loaded, load it and return nil.
|
||||
-- If the node is loaded, returns it. If it isn't loaded, load it.
|
||||
function technic.get_or_load_node(pos)
|
||||
local node = minetest.get_node_or_nil(pos)
|
||||
if node then return node end
|
||||
local vm = VoxelManip()
|
||||
local _, _ = vm:read_from_map(pos, pos)
|
||||
return nil
|
||||
minetest.load_area(pos)
|
||||
return minetest.get_node(pos)
|
||||
end
|
||||
|
||||
technic.tube_inject_item = pipeworks.tube_inject_item or function(pos, start_pos, velocity, item)
|
||||
|
@ -56,7 +56,7 @@ end
|
||||
|
||||
local function reset_quarry(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local node = technic.get_or_load_node(pos) or minetest.get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
meta:set_int("quarry_dir", node.param2)
|
||||
meta:set_string("quarry_pos", minetest.pos_to_string(pos))
|
||||
meta:set_string("dig_pos", "")
|
||||
@ -312,8 +312,7 @@ local function execute_dig(pos, node, meta, network)
|
||||
meta:set_int("purge_on", 1)
|
||||
break
|
||||
end
|
||||
minetest.load_area(dig_pos)
|
||||
local dig_node = minetest.get_node(dig_pos)
|
||||
local dig_node = technic.get_or_load_node(dig_pos)
|
||||
if can_dig_node(dig_pos, dig_node.name, owner, digger) then
|
||||
-- found something to dig, dig it and stop searching
|
||||
minetest.remove_node(dig_pos)
|
||||
|
@ -78,12 +78,12 @@ function technic.activate_network(network_id, timeout)
|
||||
end
|
||||
end
|
||||
|
||||
function technic.sw_pos2tier(pos, use_vm)
|
||||
function technic.sw_pos2tier(pos, load_node)
|
||||
-- Get cable tier for switching station or nil if no cable
|
||||
-- use_vm true to use VoxelManip to load node
|
||||
-- load_node true to use minetest.load_area to load node
|
||||
local cable_pos = {x=pos.x,y=pos.y-1,z=pos.z}
|
||||
if use_vm then
|
||||
technic.get_or_load_node(cable_pos)
|
||||
if load_node then
|
||||
minetest.load_area(cable_pos)
|
||||
end
|
||||
return technic.get_cable_tier(minetest.get_node(cable_pos).name)
|
||||
end
|
||||
@ -415,8 +415,7 @@ end
|
||||
|
||||
-- Generic function to add found connected nodes to the right classification array
|
||||
local function add_network_node(network, pos, machines)
|
||||
technic.get_or_load_node(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
local name = technic.get_or_load_node(pos).name
|
||||
|
||||
if technic.get_cable_tier(name) == network.tier then
|
||||
add_cable_node(pos, network)
|
||||
|
@ -18,7 +18,7 @@ function technic.register_solar_array(nodename, data)
|
||||
-- built below 0m
|
||||
local pos1 = { y = pos.y + 1, x = pos.x, z = pos.z }
|
||||
|
||||
technic.get_or_load_node(pos1)
|
||||
minetest.load_area(pos1)
|
||||
local light = minetest.get_node_light(pos1, nil)
|
||||
local time_of_day = minetest.get_timeofday()
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -201,10 +201,10 @@ end
|
||||
|
||||
local function remote_start_net(player, pos)
|
||||
local sw_pos = {x=pos.x,y=pos.y+1,z=pos.z}
|
||||
-- Try to load switch network node with VoxelManip
|
||||
local sw_node = technic.get_or_load_node(sw_pos) or minetest.get_node(sw_pos)
|
||||
-- Try to load switch network node
|
||||
local sw_node = technic.get_or_load_node(sw_pos)
|
||||
if sw_node.name ~= "technic:switching_station" then return "switchload" end
|
||||
-- Try to load network node with VoxelManip
|
||||
-- Try to load network node
|
||||
local tier = technic.sw_pos2tier(sw_pos, true)
|
||||
if not tier then return "cableload" end
|
||||
-- Check protections
|
||||
|
Loading…
x
Reference in New Issue
Block a user