ArguablySane wrote:Here's a function for spawning the player in a random position:
https://github.com/CasimirKaPazi/spawna ... r/init.lua
What you're trying to do is very similar, so take a look at that code.
Basically, calculate random x, y, and z coordinates within some volume, use minetest.forceload_block(pos) to load that position, then use minetest.get_node(pos) to check if it's a valid location. If it is a valid location, create your block, otherwise call minetest.forceload_free_block(pos) and repeat the process again.
rubenwardy wrote:It would be better to choose a random XYZ, then use LVM to find the nearest surface.
blert2112 wrote:I always get a load of "ignore"s returned to me. I think I must be missing a step or not doing something right.
ArguablySane wrote:You're probably missing the minetest.forceload_block(pos) part. If you try to get map data from a section of the map which isn't loaded then you'll just get a load of "ignore"s as you observed. Just don't forget to minetest.forceload_free_block(pos) after you have finished with the LVM.
rubenwardy wrote:LVM should force the MapBlocks to generate though.
It has whenever I've used it.
local vm = VoxelManip()
local e1, e2 = vm:read_from_map(minp, maxp)
local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
local data = vm:get_data()
minetest.register_craftitem("test:axe", {
description = "Test Axe",
inventory_image = "default_tool_steelaxe.png",
on_use = function(itemstack, user, pointed_thing)
if not pointed_thing or pointed_thing.type ~= "node" then return end
local pos = pointed_thing.under
pos.x = pos.x + 2000
pos.z = pos.z + 2000
pos.y = pos.y + 10
minetest.forceload_block(pos)
minetest.set_node(pos, {name = "default:mese"})
end,
})
TenPlus1 wrote:This seemed to work for me...
TenPlus1 wrote:...
If I may ask, what exactly are you trying to place from afar ??
TenPlus1 wrote:you could make an abm for the 1st door which when entered, teleport player, clear area around player and place return door...
local selected_pos = positions[math.random(pos_count)]
selected_pos = {
x=selected_pos.x,
y=selected_pos.y + 0.5,
z=selected_pos.z
}
print("SELECTED POSITION: "..minetest.pos_to_string(selected_pos))
working.lock_ent:setpos(selected_pos)
Users browsing this forum: No registered users and 1 guest