mirror of
https://github.com/minetest-mods/worldedge.git
synced 2025-06-29 22:20:28 +02:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
5366c1df07 |
@ -1,13 +1,13 @@
|
|||||||
worldedge
|
worldedge
|
||||||
=========
|
=========
|
||||||
|
|
||||||
A Luanti Mod that teleports you to the other side of the map when you reach its edge.
|
A Minetest Mod that teleports you to the other side of the map when you reach its edge.
|
||||||
This gives the illusion that that world is round and you can walk all the way around.
|
This gives the illusion that that world is round and you can walk all the way around.
|
||||||
|
|
||||||
You can change the worlds edge by changing the first variable in init.lua
|
You can change the worlds edge by changing the first variable in init.lua
|
||||||
local edge = 30000
|
local edge = 30000
|
||||||
|
|
||||||
License of code: MIT
|
License of code: DWYWPL
|
||||||
|
|
||||||
Written by Amaz
|
Written by Amaz
|
||||||
Modified by Don
|
Modified by Don
|
||||||
|
176
init.lua
176
init.lua
@ -1,41 +1,149 @@
|
|||||||
local world = tonumber(core.settings:get("worldedge.world_size")) or 5000
|
--------------
|
||||||
|
-- TODO: Check for terrain height
|
||||||
|
|
||||||
|
-- Defines the edge of a world
|
||||||
|
local edge = tonumber(minetest.settings:get("world_edge")) or 30000
|
||||||
|
-- Radius which should be checked for a good teleportation place
|
||||||
|
local radius = 2
|
||||||
|
--------------
|
||||||
|
|
||||||
|
if minetest.settings:get_bool("log_mods") then
|
||||||
|
minetest.log("action", "World edge: " .. edge)
|
||||||
|
end
|
||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
local edge = world --sets the edge of map
|
local waiting_list = {}
|
||||||
local newedge = world --sets the other side where player teleports to. Should be a few blocks less than edge
|
--[[ Explanation of waiting_list table
|
||||||
|
Index = Player name
|
||||||
|
Value = {
|
||||||
|
player = Player to teleport
|
||||||
|
pos = Destination
|
||||||
|
obj = Attacked entity
|
||||||
|
notified = When the player must wait longer...
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
count = count + dtime
|
count = count + dtime
|
||||||
if count > 5 then
|
if count < 3 then
|
||||||
count = 0
|
return
|
||||||
local players = minetest.get_connected_players()
|
end
|
||||||
for _,player in pairs(players) do
|
count = 0
|
||||||
local pos = player:getpos()
|
|
||||||
if pos.x >= edge then
|
for k, v in pairs(waiting_list) do
|
||||||
player:moveto({x = -newedge, y = pos.y, z = pos.z})
|
if v.player and v.player:is_player() then
|
||||||
end
|
local pos = get_surface_pos(v.pos)
|
||||||
if pos.x <= -edge then
|
if pos then
|
||||||
player:moveto({x = newedge, y = pos.y, z = pos.z})
|
v.obj:setpos(pos)
|
||||||
end
|
minetest.after(0.2, function(p, o)
|
||||||
|
p:set_detach()
|
||||||
|
o:remove()
|
||||||
|
end, v.player, v.obj)
|
||||||
|
waiting_list[k] = nil
|
||||||
|
elseif not v.notified then
|
||||||
|
v.notified = true
|
||||||
|
minetest.chat_send_player(k, "Sorry, we have not found a free place yet. Please be patient.")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
v.obj:remove()
|
||||||
|
waiting_list[k] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- This section is for the Y cord. It will move you from bottom to top or top to bottom of map
|
local newedge = edge - 5
|
||||||
--[[
|
-- Check if the players are near the edge and teleport them
|
||||||
if pos.y >= edge then
|
local players = minetest.get_connected_players()
|
||||||
player:moveto({x = pos.x, y = -newedge, z = pos.z})
|
for i, player in ipairs(players) do
|
||||||
end
|
local name = player:get_player_name()
|
||||||
if pos.y <= -edge then
|
if not waiting_list[name] then
|
||||||
player:moveto({x = pos.x, y = newedge, z = pos.z})
|
local pos = vector.round(player:getpos())
|
||||||
end
|
local newpos = nil
|
||||||
--]]
|
if pos.x >= edge then
|
||||||
|
newpos = {x = -newedge, y = 10, z = pos.z}
|
||||||
|
elseif pos.x <= -edge then
|
||||||
if pos.z >= edge then
|
newpos = {x = newedge, y = 10, z = pos.z}
|
||||||
player:moveto({x = pos.x, y = pos.y, z = -newedge})
|
end
|
||||||
end
|
|
||||||
if pos.z <= -edge then
|
if pos.z >= edge then
|
||||||
player:moveto({x = pos.x, y = pos.y, z = newedge})
|
newpos = {x = pos.x, y = 10, z = -newedge}
|
||||||
end
|
elseif pos.z <= -edge then
|
||||||
end
|
newpos = {x = pos.x, y = 10, z = newedge}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Teleport the player
|
||||||
|
if newpos then
|
||||||
|
minetest.chat_send_player(name, "Please wait a few seconds. We will teleport you soon.")
|
||||||
|
local obj = minetest.add_entity(newpos, "worldedge:lock")
|
||||||
|
player:set_attach(obj, "", {x=0, y=0, z=0}, {x=0, y=0, z=0})
|
||||||
|
waiting_list[name] = {
|
||||||
|
player = player,
|
||||||
|
pos = newpos,
|
||||||
|
obj = obj
|
||||||
|
}
|
||||||
|
obj:setpos(newpos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function get_surface_pos(pos)
|
||||||
|
local minp = {
|
||||||
|
x = pos.x - radius - 1,
|
||||||
|
y = -10,
|
||||||
|
z = pos.z - radius - 1
|
||||||
|
}
|
||||||
|
local maxp = {
|
||||||
|
x = pos.x + radius - 1,
|
||||||
|
y = 50,
|
||||||
|
z = pos.z + radius - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
local c_ignore = minetest.get_content_id("ignore")
|
||||||
|
|
||||||
|
local vm = minetest.get_voxel_manip()
|
||||||
|
local emin, emax = vm:read_from_map(minp, maxp)
|
||||||
|
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||||
|
local data = vm:get_data()
|
||||||
|
|
||||||
|
local seen_air = false
|
||||||
|
local deepest_place = vector.new(pos)
|
||||||
|
deepest_place.y = 50
|
||||||
|
|
||||||
|
for x = minp.x, maxp.x do
|
||||||
|
for z = minp.z, maxp.z do
|
||||||
|
local solid = 0
|
||||||
|
for y = deepest_place.y, -10, -1 do
|
||||||
|
local node = data[area:index(x, y, z)]
|
||||||
|
if y < deepest_place.y and node == c_air then
|
||||||
|
deepest_place = vector.new(x, y, z)
|
||||||
|
seen_air = true
|
||||||
|
end
|
||||||
|
if solid > 5 then
|
||||||
|
-- Do not find caves!
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if node ~= c_air and node ~= c_ignore then
|
||||||
|
solid = solid + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if seen_air then
|
||||||
|
return deepest_place
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_entity("worldedge:lock", {
|
||||||
|
initial_properties = {
|
||||||
|
is_visible = false
|
||||||
|
},
|
||||||
|
on_activate = function(staticdata, dtime_s)
|
||||||
|
--self.object:set_armor_groups({immortal = 1})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.log("action", "[worldedge] loaded.")
|
||||||
|
31
licence.txt
31
licence.txt
@ -1,24 +1,13 @@
|
|||||||
The MIT License (MIT)
|
DO WHAT YOU WANT TO PUBLIC LICENSE
|
||||||
|
or abbreviated DWYWPL
|
||||||
|
|
||||||
Copyright (c) 2025 Don Michaud
|
December 2nd 2015
|
||||||
|
License Copyright (C) 2015 Michael Tomaino (PlatinumArts@gmail.com)
|
||||||
|
www.sandboxgamemaker.com/DWYWPL/
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
DO WHAT YOU WANT TO PUBLIC LICENSE
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
1. You are allowed to do whatever you want to with what content is using this license.
|
||||||
all copies or substantial portions of the Software.
|
2. This content is provided 'as-is', without any express or implied warranty. In no event
|
||||||
|
will the authors be held liable for any damages arising from the use of this content.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
Textures by Don Michaud (CC0) unless listed below
|
|
||||||
|
4
mod.conf
4
mod.conf
@ -1,5 +1 @@
|
|||||||
name = worldedge
|
name = worldedge
|
||||||
description = Changes the size of your world
|
|
||||||
depends = default
|
|
||||||
author = Don Michaud & Amaz & Krock
|
|
||||||
title = World Edge
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
#Change world size
|
|
||||||
worldedge.world_size (Set world size) int 5000
|
|
Reference in New Issue
Block a user