Created
July 17, 2018 20:55
-
-
Save MEXAHOTABOP/f78f8ee8d96353fdfa525caa03d3c9b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local comp = require("component") | |
local geolyzer = comp.geolyzer | |
--[[ | |
-1.0 корпорода | |
0.0 воздух, нефть, бамбук, факел | |
0.4 кактус | |
0.5 земля, провод ic2 | |
0.6 гравий | |
1.0 гевея, верстак | |
1.5 камень(гранит и адчетотам входят в одну группу) | |
2.0 монитор(всё из oc?), булыжник,донный камень rc,свинец ic2 | |
2.5 сундук | |
3.0 уголь, медь ic2/pr, дверь, электротин pr, олово ic2, серебро tf, лазуритn rc, сера rc, | |
железо, свенец tf, (всё из tc?), кремень gc, редстоун, алмазы n/rc, золото, никель tf, рубины pr | |
5.0 олово gc | |
6.0 алюмений gc | |
50.0 обсидиан | |
100.0 вода лава | |
]] | |
local scan = {} | |
function scan.scan_box(x, z, y, sensitivity) | |
local geo_table = {} | |
local geo_table_min = {} | |
local geo_table_max = {} | |
for pass = 1, sensitivity do | |
geo_table[pass] = geolyzer.scan(x, z, y, 4, 4, 4, false) --ignore replacable багованый и возвращает 0,0 обсолютно на всё | |
for i = 1, 64 do -- всегда 64 значения | |
geo_table_max[i] = geo_table_max[i] or -9999999.0 | |
geo_table_min[i] = geo_table_min[i] or 99999999.0 | |
if geo_table[pass][i] > geo_table_max[i] then geo_table_max[i] = geo_table[pass][i] end | |
if geo_table[pass][i] < geo_table_min[i] then geo_table_min[i] = geo_table[pass][i] end | |
end | |
geo_table[pass] = nil | |
end | |
for i = 1, 64 do | |
geo_table[i] = (geo_table_max[i] + geo_table_min[i]) / 2 | |
end | |
return geo_table | |
end | |
function scan.scan(x, z, y, w, d, h, sensitivity, threshold_min, threshold_max, interactive) | |
--сканирует только блоками 4x4x4 потому что я роч | |
local size_w = math.abs(math.ceil(w / 4) - 1) | |
local size_d = math.abs(math.ceil(d / 4) - 1) | |
local size_h = math.abs(math.ceil(h / 4) - 1) | |
local res_table = {} | |
local scan_total = 0 | |
local scan_complited = 0 | |
if interactive then | |
scan_total = ((size_w+1) * (size_d+1) * (size_h+1)) * sensitivity | |
end | |
for num_h = 0, size_h do | |
local offset_y = num_h * 4 | |
for num_d = 0, size_d do | |
local offset_z = num_d * 4 | |
for num_w = 0, size_w do | |
local offset_x = num_w * 4 | |
local geo_table = scan.scan_box(x + offset_x, z + offset_z, y + offset_y, sensitivity) | |
if interactive then | |
scan_complited = scan_complited + sensitivity | |
print(scan_complited .. "/" .. scan_total) | |
end | |
local pos = 1 | |
for y_local = 0, 3 do | |
for z_local = 0, 3 do | |
for x_local = 0, 3 do | |
if threshold_min < geo_table[pos] and geo_table[pos] < threshold_max then | |
res_table[x+offset_x+x_local] = res_table[x+offset_x+x_local] or {} | |
res_table[x+offset_x+x_local][z+offset_z+z_local] = res_table[x+offset_x+x_local][z+offset_z+z_local] or {} | |
res_table[x+offset_x+x_local][z+offset_z+z_local][y+offset_y+y_local] = geo_table[pos] | |
end | |
pos = pos + 1 | |
end | |
end | |
end | |
end | |
end | |
end | |
return res_table | |
end | |
return scan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment