[nalc_technic] Tentative pour améliorer les performances

This commit is contained in:
Sys Quatre 2019-03-20 21:57:02 +01:00
parent d8016d3b71
commit 1822cf2d48

View File

@ -9,7 +9,7 @@ minetest.register_craft({
{"technic:motor", "technic:quarry", "technic:diamond_drill_head"},
{"technic:quarry", "technic:hv_cable", "technic:quarry"}
},
output = "nalc_technic:superquarry",
output = "nalc:superquarry",
})
local superquarry_dig_above_nodes = 3 -- How far above the superquarry we will dig nodes
@ -21,7 +21,7 @@ local function set_superquarry_formspec(meta)
local radius = meta:get_int("size")
local formspec = "size[6,4.3]"..
"list[context;cache;0,1;4,3;]"..
"item_image[4.8,0;1,1;nalc_technic:superquarry]"..
"item_image[4.8,0;1,1;nalc:superquarry]"..
"label[0,0.2;"..S("%s superquarry"):format("HV").."]"..
"field[4.3,3.5;2,1;size;"..S("Radius:")..";"..radius.."]"
if meta:get_int("enabled") == 0 then
@ -104,7 +104,7 @@ local function superquarry_run(pos, node)
local inv = meta:get_inventory()
-- initialize cache for the case we load an older world
inv:set_size("cache", 12)
-- toss a coin whether we do an automatic purge. Chance 1:100
-- toss a coin whether we do an automatic purge. Chance 1:200
local purge_rand = math.random()
if purge_rand <= 0.005 then
meta:set_int("purge_on", 1)
@ -122,15 +122,6 @@ local function superquarry_run(pos, node)
vector.new(0, superquarry_dig_above_nodes, 0)),
pdir),
vector.multiply(qdir, -radius))
local endpos = vector.add(vector.add(vector.add(startpos,
vector.new(0, -superquarry_dig_above_nodes-superquarry_max_depth, 0)),
vector.multiply(pdir, diameter-1)),
vector.multiply(qdir, diameter-1))
local vm = VoxelManip()
local minpos, maxpos = vm:read_from_map(startpos, endpos)
local area = VoxelArea:new({MinEdge=minpos, MaxEdge=maxpos})
local data = vm:get_data()
local c_air = minetest.get_content_id("air")
local owner = meta:get_string("owner")
local nd = meta:get_int("dug")
while nd ~= diameter*diameter * (superquarry_dig_above_nodes+1+superquarry_max_depth) do
@ -154,7 +145,17 @@ local function superquarry_run(pos, node)
if can_dig then
dignode = technic.get_or_load_node(digpos) or minetest.get_node(digpos)
local dignodedef = minetest.registered_nodes[dignode.name] or {diggable=false}
if not dignodedef.diggable or (dignodedef.can_dig and not dignodedef.can_dig(digpos, nil)) then
-- doors mod among other thing does NOT like a nil digger...
local fakedigger = {
get_player_name = function()
return "!technic_quarry_fake_digger"
end,
is_player = function() return false end,
get_wielded_item = function()
return ItemStack("air")
end,
}
if not dignodedef.diggable or (dignodedef.can_dig and not dignodedef.can_dig(digpos, fakedigger)) then
can_dig = false
end
end
@ -209,7 +210,7 @@ local function send_move_error(player)
return 0
end
minetest.register_node("nalc_technic:superquarry", {
minetest.register_node(":nalc:superquarry", {
description = S("%s superquarry"):format("HV"),
tiles = {
"moreores_mithril_block.png",
@ -270,6 +271,6 @@ minetest.register_node("nalc_technic:superquarry", {
end
})
technic.register_machine("HV", "nalc_technic:superquarry", technic.receiver)
technic.register_machine("HV", "nalc:superquarry", technic.receiver)
minetest.register_alias("nalc:superquarry", "nalc_technic:superquarry")
minetest.register_alias("nalc_technic:superquarry", "nalc:superquarry")