Add "worldedge" mod.
This commit is contained in:
parent
0b5e266244
commit
bdc8da3226
@ -54,6 +54,8 @@ The following mods are also included:
|
||||
* weather/
|
||||
* [lightning][] ([LGPL/CC-BY-SA](mods/weather/lightning/README.md))
|
||||
* [weather][] ([LGPL/WTFPL/CC-BY-SA](mods/weather/weather/README))
|
||||
* world/
|
||||
* [worldedge][] ([DWYWPL](mods/world/worldedge/licence.txt))
|
||||
|
||||
|
||||
|
||||
@ -83,3 +85,4 @@ The following mods are also included:
|
||||
[vines]: https://forum.minetest.net/viewtopic.php?f=11&t=2344
|
||||
[weather]: https://forum.minetest.net/viewtopic.php?t=5245
|
||||
[workbench]: https://forum.minetest.net/viewtopic.php?t=14085
|
||||
[worldedge]: https://forum.minetest.net/viewtopic.php?t=10753
|
||||
|
0
mods/world/modpack.txt
Normal file
0
mods/world/modpack.txt
Normal file
13
mods/world/worldedge/README.md
Normal file
13
mods/world/worldedge/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
worldedge
|
||||
=========
|
||||
|
||||
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.
|
||||
|
||||
You can change the worlds edge by changing the first variable in init.lua
|
||||
local edge = 30000
|
||||
|
||||
License of code: DWYWPL
|
||||
|
||||
Written by Amaz
|
||||
Modified by Don
|
0
mods/world/worldedge/depends.txt
Normal file
0
mods/world/worldedge/depends.txt
Normal file
1
mods/world/worldedge/description.txt
Normal file
1
mods/world/worldedge/description.txt
Normal file
@ -0,0 +1 @@
|
||||
Allows you to limit the size of your world.
|
143
mods/world/worldedge/init.lua
Normal file
143
mods/world/worldedge/init.lua
Normal file
@ -0,0 +1,143 @@
|
||||
--------------
|
||||
-- TODO: Check for terrain height
|
||||
|
||||
-- Defines the edge of a world
|
||||
local edge = 30000
|
||||
-- Radius which should be checked for a good teleportation place
|
||||
local radius = 2
|
||||
--------------
|
||||
|
||||
local count = 0
|
||||
local waiting_list = {}
|
||||
--[[ 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)
|
||||
count = count + dtime
|
||||
if count < 3 then
|
||||
return
|
||||
end
|
||||
count = 0
|
||||
|
||||
for k, v in pairs(waiting_list) do
|
||||
if v.player and v.player:is_player() then
|
||||
local pos = get_surface_pos(v.pos)
|
||||
if pos then
|
||||
v.obj:setpos(pos)
|
||||
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
|
||||
|
||||
local newedge = edge - 5
|
||||
-- Check if the players are near the edge and teleport them
|
||||
local players = minetest.get_connected_players()
|
||||
for i, player in ipairs(players) do
|
||||
local name = player:get_player_name()
|
||||
if not waiting_list[name] then
|
||||
local pos = vector.round(player:getpos())
|
||||
local newpos = nil
|
||||
if pos.x >= edge then
|
||||
newpos = {x = -newedge, y = 10, z = pos.z}
|
||||
elseif pos.x <= -edge then
|
||||
newpos = {x = newedge, y = 10, z = pos.z}
|
||||
end
|
||||
|
||||
if pos.z >= edge then
|
||||
newpos = {x = pos.x, y = 10, z = -newedge}
|
||||
elseif pos.z <= -edge then
|
||||
newpos = {x = pos.x, y = 10, z = newedge}
|
||||
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)
|
||||
|
||||
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
|
||||
})
|
13
mods/world/worldedge/licence.txt
Normal file
13
mods/world/worldedge/licence.txt
Normal file
@ -0,0 +1,13 @@
|
||||
DO WHAT YOU WANT TO PUBLIC LICENSE
|
||||
or abbreviated DWYWPL
|
||||
|
||||
December 2nd 2015
|
||||
License Copyright (C) 2015 Michael Tomaino (PlatinumArts@gmail.com)
|
||||
www.sandboxgamemaker.com/DWYWPL/
|
||||
|
||||
DO WHAT YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
1. You are allowed to do whatever you want to with what content is using this license.
|
||||
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.
|
1
mods/world/worldedge/mod.conf
Normal file
1
mods/world/worldedge/mod.conf
Normal file
@ -0,0 +1 @@
|
||||
name = worldedge
|
BIN
mods/world/worldedge/screenshot.png
Normal file
BIN
mods/world/worldedge/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 KiB |
Loading…
x
Reference in New Issue
Block a user