worldedge/init.lua

38 lines
894 B
Lua
Raw Normal View History

2014-12-15 19:58:14 +01:00
--------------
-- TODO: Check for terrain height
2014-12-14 15:25:47 +01:00
2014-12-15 19:58:14 +01:00
-- Defines the edge of a world
local edge = 30000
--------------
2014-12-14 15:52:09 +01:00
2014-12-14 15:25:47 +01:00
local count = 0
minetest.register_globalstep(function(dtime)
count = count + dtime
2014-12-15 19:58:14 +01:00
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
2014-12-14 15:25:47 +01:00
end
end)
2014-12-14 15:52:09 +01:00