This commit is contained in:
Megaf 2017-12-21 01:51:35 +00:00 committed by GitHub
commit e9bbd63c31
2 changed files with 73 additions and 6 deletions

View File

@ -315,7 +315,7 @@ for n,data in ipairs(guide_infos) do
elseif typ == "x" then
x = math.max(x, content)
elseif typ == "text" then
local tab = minetest.wrap_text(content, guide_size.fx)
local tab = minetest.wrap_text(content, guide_size.fx, true)
local l = guide_size.cx
for _,str in ipairs(tab) do
form = form.."label["..guide_size.cx ..","..guide_size.cy+y..";"..str.."]"

View File

@ -130,6 +130,43 @@ local function table_contains(t, v)
return false
end
-- Function from vector_extras - added by Megaf.
local function get_data_pos_table(tab)
local t,n = {},1
local minz, miny, minx, maxz, maxy, maxx
for z,yxs in pairs(tab) do
if not minz then
minz = z
maxz = z
else
minz = math.min(minz, z)
maxz = math.max(maxz, z)
end
for y,xs in pairs(yxs) do
if not miny then
miny = y
maxy = y
else
miny = math.min(miny, y)
maxy = math.max(maxy, y)
end
for x,v in pairs(xs) do
if not minx then
minx = x
maxx = x
else
minx = math.min(minx, x)
maxx = math.max(maxx, x)
end
t[n] = {z,y,x, v}
n = n+1
end
end
end
return t, {x=minx, y=miny, z=minz}, {x=maxx, y=maxy, z=maxz}, n-1
end
-- Weierstrass function stuff from https://github.com/slemonide/gen
local SIZE = 1000
local ssize = math.ceil(math.abs(SIZE))
@ -691,10 +728,40 @@ function nether.grow_netherstructure(pos, generated)
set_vm_data(manip, nodes, pos, t1, "blood", generated)
end
local function set(tab, z,y,x, data)
if tab[z] then
if tab[z][y] then
tab[z][y][x] = data
return
end
tab[z][y] = {[x] = data}
return
end
tab[z] = {[y] = {[x] = data}}
end
local set = vector.set_data_to_pos
local get = vector.get_data_from_pos
local remove = vector.remove_data_from_pos
local function get(tab, z,y,x)
local data = tab[z]
if data then
data = data[y]
if data then
return data[x]
end
end
end
local function remove(tab, z,y,x)
if get(tab, z,y,x) == nil then
return
end
tab[z][y][x] = nil
if not next(tab[z][y]) then
tab[z][y] = nil
end
if not next(tab[z]) then
tab[z] = nil
end
end
local function soft_node(id)
return id == c.air or id == c.ignore
@ -733,7 +800,8 @@ local h_trunk_max = h_max-h_arm_max
function nether.grow_tree(pos, generated)
local t1 = os.clock()
local ps, trmin, trmax, trunk_count = get_data_pos_table(trunks)
if not contents_defined then
define_contents()
contents_defined = true
@ -799,7 +867,6 @@ function nether.grow_tree(pos, generated)
local fruits = {}
local trunk_ps = {}
local count = 0
local ps, trmin, trmax, trunk_count = vector.get_data_pos_table(trunks)
update_minmax(min, max, trmin)
update_minmax(min, max, trmax)