MeseCraft wrote: ↑Wed Dec 23, 2020 21:57
I know on PB you guys have a task that autogenerates the map so people can jump drive to areas. How does that work? What is that? I might be interested in using that as I'd eventually like a jumpdrive to be an aspect of exploring space.
honestly it shouldn't be difficult. Just put
minetest.emerge_area(pos1, pos2) with the positions being the corners of the jumpdrive area before the code that checks if the jumpdrive can move there. maybe add or remove 16 from each pos to increase the area and prevent errors.
replacing the same function in is_area_empty.lua with this should do it:
Code: Select all
jumpdrive.is_area_empty = function(pos1, pos2)
minetest.emerge_area({ -- generates or loads the area before checking emptiness
x= pos1.x > 0 and pos1.x+16 or pos1.x-16, -- expands area by 16 in each axis to prevent border overlap
y= pos1.y > 0 and pos1.y+16 or pos1.y-16,
z= pos1.z > 0 and pos1.z+16 or pos1.z-16
}, {
x= pos2.x > 0 and pos2.x+16 or pos2.x-16,
y= pos2.y > 0 and pos2.y+16 or pos2.y-16,
z= pos2.z > 0 and pos2.z+16 or pos2.z-16
})
local manip = minetest.get_voxel_manip()
local e1, e2 = manip:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
local data = manip:get_data()
for z=pos1.z, pos2.z do
for y=pos1.y, pos2.y do
for x=pos1.x, pos2.x do
local index = area:index(x, y, z)
local id = data[index]
if id == c_ignore then
return false, "Uncharted"
end
if not buildable_to_nodes[id] then
-- not buildable_to
return false, "Occupied"
end
end
end
end
-- only buildable_to nodes found
return true, ""
end
I just tested and was able to successfully jump directly to y 10000 without going there first.
Imo this simple addition would make the mod way better, and the "Uncharted" response still has a purpose: to indicate that the jump attempted to exit the world boundary. I'll make a pr after I test it a bit more.