forked from minetest-mods/worldedge
Version MFF.
This commit is contained in:
parent
8e576d69c8
commit
a70a6b7b77
0
depends.txt
Normal file → Executable file
0
depends.txt
Normal file → Executable file
50
init.lua
Normal file → Executable file
50
init.lua
Normal file → Executable file
@ -19,13 +19,7 @@ local waiting_list = {}
|
|||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
local function tick()
|
||||||
count = count + dtime
|
|
||||||
if count < 3 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
for k, v in pairs(waiting_list) do
|
for k, v in pairs(waiting_list) do
|
||||||
if v.player and v.player:is_player() then
|
if v.player and v.player:is_player() then
|
||||||
local pos = get_surface_pos(v.pos)
|
local pos = get_surface_pos(v.pos)
|
||||||
@ -53,19 +47,40 @@ minetest.register_globalstep(function(dtime)
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if not waiting_list[name] then
|
if not waiting_list[name] then
|
||||||
local pos = vector.round(player:getpos())
|
local pos = vector.round(player:getpos())
|
||||||
|
|
||||||
|
-- Sanity check for insane coordinates
|
||||||
|
if pos.x > 31000 or pos.y > 31000 or pos.z > 31000
|
||||||
|
or pos.x < -31000 or pos.y < -31000 or pos.z < -31000 then
|
||||||
|
-- Move to spawn asap
|
||||||
|
-- The server probably set invalid/insane coordinates. We have not saved the previous ones,
|
||||||
|
-- So we need to teleport the player to the spawn to save them from an endless loop of
|
||||||
|
-- Teleportation.
|
||||||
|
local spawn = minetest.string_to_pos(minetest.setting_get("static_spawnpoint") or "0,0,0")
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "An internal error has occured. Your coordinates were corrupted. You are now teleported to the spawn." ..
|
||||||
|
" Please report it to any staff member.")
|
||||||
|
minetest.log("error", "[WorldEdge] Corrupted position detected for player " .. player:get_player_name())
|
||||||
|
player:setpos(spawn)
|
||||||
|
else -- Indent skipped, too many lines to change... We'll wait for "continue" to be introduced in Lua5.2
|
||||||
|
|
||||||
local newpos = nil
|
local newpos = nil
|
||||||
if pos.x >= edge then
|
if pos.x >= edge then
|
||||||
newpos = {x = -newedge, y = 10, z = pos.z}
|
newpos = {x = -newedge, y = 10, z = pos.z}
|
||||||
elseif pos.x <= -edge then
|
elseif pos.x <= -edge then
|
||||||
newpos = {x = newedge, y = 10, z = pos.z}
|
newpos = {x = newedge, y = 10, z = pos.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
if pos.z >= edge then
|
if pos.z >= edge then
|
||||||
newpos = {x = pos.x, y = 10, z = -newedge}
|
newpos = {x = pos.x, y = 10, z = -newedge}
|
||||||
|
if get_surface_pos(newpos) then
|
||||||
|
newpos.y = get_surface_pos(newpos).y+1 -- /MFF (Mg|19/05//15)
|
||||||
|
end -- /MFF (Mg|14/07/15)
|
||||||
elseif pos.z <= -edge then
|
elseif pos.z <= -edge then
|
||||||
newpos = {x = pos.x, y = 10, z = newedge}
|
newpos = {x = pos.x, y = 10, z = newedge}
|
||||||
|
if get_surface_pos(newpos) then
|
||||||
|
newpos.y = get_surface_pos(newpos).y+1 -- /MFF (Mg|19/05/15)
|
||||||
|
end -- /MFF (Mg|14/07/15)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Teleport the player
|
-- Teleport the player
|
||||||
if newpos then
|
if newpos then
|
||||||
minetest.chat_send_player(name, "Please wait a few seconds. We will teleport you soon.")
|
minetest.chat_send_player(name, "Please wait a few seconds. We will teleport you soon.")
|
||||||
@ -78,9 +93,12 @@ minetest.register_globalstep(function(dtime)
|
|||||||
}
|
}
|
||||||
obj:setpos(newpos)
|
obj:setpos(newpos)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
minetest.after(3, tick)
|
||||||
|
end
|
||||||
|
tick()
|
||||||
|
|
||||||
function get_surface_pos(pos)
|
function get_surface_pos(pos)
|
||||||
local minp = {
|
local minp = {
|
||||||
@ -93,19 +111,19 @@ function get_surface_pos(pos)
|
|||||||
y = 50,
|
y = 50,
|
||||||
z = pos.z + radius - 1
|
z = pos.z + radius - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
local c_air = minetest.get_content_id("air")
|
local c_air = minetest.get_content_id("air")
|
||||||
local c_ignore = minetest.get_content_id("ignore")
|
local c_ignore = minetest.get_content_id("ignore")
|
||||||
|
|
||||||
local vm = minetest.get_voxel_manip()
|
local vm = minetest.get_voxel_manip()
|
||||||
local emin, emax = vm:read_from_map(minp, maxp)
|
local emin, emax = vm:read_from_map(minp, maxp)
|
||||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||||
local data = vm:get_data()
|
local data = vm:get_data()
|
||||||
|
|
||||||
local seen_air = false
|
local seen_air = false
|
||||||
local deepest_place = vector.new(pos)
|
local deepest_place = vector.new(pos)
|
||||||
deepest_place.y = 50
|
deepest_place.y = 50
|
||||||
|
|
||||||
for x = minp.x, maxp.x do
|
for x = minp.x, maxp.x do
|
||||||
for z = minp.z, maxp.z do
|
for z = minp.z, maxp.z do
|
||||||
local solid = 0
|
local solid = 0
|
||||||
@ -125,7 +143,7 @@ function get_surface_pos(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if seen_air then
|
if seen_air then
|
||||||
return deepest_place
|
return deepest_place
|
||||||
else
|
else
|
||||||
@ -140,4 +158,4 @@ minetest.register_entity("worldedge:lock", {
|
|||||||
on_activate = function(staticdata, dtime_s)
|
on_activate = function(staticdata, dtime_s)
|
||||||
--self.object:set_armor_groups({immortal = 1})
|
--self.object:set_armor_groups({immortal = 1})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user