mirror of
https://github.com/minetest-mods/worldedge.git
synced 2024-11-18 08:00:30 +01:00
6f6650c252
Add comments and TODO
38 lines
894 B
Lua
38 lines
894 B
Lua
--------------
|
|
-- TODO: Check for terrain height
|
|
|
|
-- Defines the edge of a world
|
|
local edge = 30000
|
|
--------------
|
|
|
|
local count = 0
|
|
minetest.register_globalstep(function(dtime)
|
|
count = count + dtime
|
|
if count < 5 then
|
|
return
|
|
end
|
|
count = 0
|
|
|
|
local newedge = edge - 5
|
|
-- Check if the players are near the edge and teleport them
|
|
local players = minetest.get_connected_players()
|
|
for _,player in pairs(players) do
|
|
local pos = player:getpos()
|
|
if pos.x >= edge then
|
|
player:moveto({x = -newedge, y = pos.y, z = pos.z})
|
|
end
|
|
if pos.x <= -edge then
|
|
player:moveto({x = newedge, y = pos.y, z = pos.z})
|
|
end
|
|
|
|
if pos.z >= edge then
|
|
player:moveto({x = pos.x, y = pos.y, z = -newedge})
|
|
end
|
|
if pos.z <= -edge then
|
|
player:moveto({x = pos.x, y = pos.y, z = newedge})
|
|
end
|
|
end
|
|
end)
|
|
|
|
|