I wanna get the material of the one cell located at the pos value(which I know returns a valid 4x4 grid vector
r.Convert =
function(region)
local dist = (region.Min.X - region.Max.X)
local dist2 = (region.Min.Y - region.Max.Y)
local dist3 = (region.Min.Z - region.Max.Z)
dist = dist / 4
dist2 = dist2/4
dist3 = dist3/4
local absdist = math.abs(dist)
local absdist2 = math.abs(dist2)
local absdist3 = math.abs(dist3)
local stdrpos = region.Min
local region3 = Region3int16toRegion3(region)
print("Regions ",region.Min,region.Max)
print("ABSDIST ",absdist,absdist2,absdist3)
print("DIST ", dist,dist2,dist3)
local count = 0
local pos
for x = 0,absdist do
for y = 0,absdist2 do
for z = 0,absdist3 do
if absdist == dist then
pos = Vector3.new(GridPos(stdrpos.X - x*4),GridPos(stdrpos.Y+y*4),GridPos(stdrpos.Z))
else
pos = Vector3.new(GridPos(stdrpos.X + x*4),GridPos(stdrpos.Y+y*4),GridPos(stdrpos.Z))
end
if absdist3 == dist3 then
pos = Vector3.new(pos.X,pos.Y,GridPos(stdrpos.Z - z*4))
else pos = Vector3.new(pos.X,pos.Y,GridPos(stdrpos.Z + z*4))
end
count += 1
print(pos)
local materials,occupancies = game.Workspace.Terrain:ReadVoxels(region3,4)
local size = materials.Size
print(size)
print(materials[x][y][z].Name)
if math.floor(count/50) ==count/50 then --if int
wait(0)
end
end
end
end
end