Compare commits

...

7 Commits

Author SHA1 Message Date
flux 38ced5449b bls 2019-07-25 04:05:31 +00:00
AndrejIT 1e07844d3f Part teleport function as substantive func - as suggested by github user Reedych. 2017-10-08 21:36:48 +03:00
AndrejIT 580a796a87 Fix for cursed_world position
(I forgot, again, that Lua table/array asiggment is by reference)
2017-04-09 21:46:18 +03:00
AndrejIT 5d76bebe23 Add compatibility with cursed_world mod. Stay in cursed_world if already there. 2017-04-08 08:55:22 +03:00
AndrejIT d5366f1120 Merge pull request #1 from minetest-mods/sofar-patch-1
Add standard mod files
2016-04-06 12:35:45 +03:00
Auke Kok 593f680f58 Add description.txt 2016-04-06 00:20:13 -07:00
Auke Kok 0858fa1a84 Add mod.conf 2016-04-06 00:19:09 -07:00
4 changed files with 29 additions and 14 deletions

2
depends.txt Normal file
View File

@ -0,0 +1,2 @@
default
cursed_world?

1
description.txt Normal file
View File

@ -0,0 +1 @@
Adds a /spawn command that telepors you to the server spawn command.

39
init.lua Normal file → Executable file
View File

@ -6,20 +6,31 @@ if minetest.setting_get_pos("static_spawnpoint") then
spawn_command.pos = minetest.setting_get_pos("static_spawnpoint")
end
function teleport_to_spawn(name)
local player = minetest.get_player_by_name(name)
if player == nil then
-- just a check to prevent the server crashing
return false
end
local pos = player:getpos()
if _G['cursed_world'] ~= nil and --check global table for cursed_world mod
cursed_world.location_y and cursed_world.dimension_y and
pos.y < (cursed_world.location_y + cursed_world.dimension_y) and --if player is in cursed world, stay in cursed world
pos.y > (cursed_world.location_y - cursed_world.dimension_y)
then --check global table for cursed_world mod
--minetest.chat_send_player(name, "T"..(cursed_world.location_y + cursed_world.dimension_y).." "..(cursed_world.location_y - cursed_world.dimension_y))
local spawn_pos = vector.round(spawn_command.pos);
spawn_pos.y = spawn_pos.y + cursed_world.location_y;
player:setpos(spawn_pos)
minetest.chat_send_player(name, "Teleported to spawn!")
else
player:setpos(spawn_command.pos)
minetest.chat_send_player(name, "Teleported to spawn!")
end
end
minetest.register_chatcommand("spawn", {
description = "Teleport you to spawn point.",
func = function(name)
local player = minetest.get_player_by_name(name)
if player == nil then
-- just a check to prevent the server crashing
return false
end
local pos = player:getpos()
if pos.x>-20 and pos.x<20 and pos.y>-20 and pos.z>-20 and pos.z<20 then
else
player:setpos(spawn_command.pos)
minetest.chat_send_player(name, "Teleported to spawn!")
end
end,
privs = {home = true},
func = teleport_to_spawn,
})

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = spawn_command