added static spawn point script

master
juraj 2016-03-02 22:43:28 +01:00
parent 275b7690ca
commit 9e0e474f89
4 changed files with 53 additions and 0 deletions

View File

@ -7,6 +7,7 @@ To install, rename to "enhancements" and place in the mods/ directory.
* clean-up server - unknown nodes and entities
* [external_cmd]server chat messages from outside Minetest game
* detect AFK player
* spawn - set and go to static spawn point
* areas - control privilages
External Commands

View File

@ -31,6 +31,13 @@ if PLAYER_AFK then
print("[Mod][enhancements] PLAYER_AFK enabled")
end
-- go to and set SPAWN_POINT
if SPAWN_POINT then
dofile(minetest.get_modpath("enhancements").."/spawn.lua")
print("[Mod][enhancements] SPAWN_POINT enabled")
end
-- manage privileges i areas mod - if using areas mod only for admin purposes
-- WIP DONT ENABLE!
if AREAS_ENHANCE and minetest.get_modpath("areas") then

View File

@ -2,4 +2,5 @@ TOOLS_ENHANCE = true
CLEAN_UNKNOWN = true
EXTERNAL_CMD = true
PLAYER_AFK = true
SPAWN_POINT = true
AREAS_ENHANCE = false

44
spawn.lua Normal file
View File

@ -0,0 +1,44 @@
--Spawn mod for Minetest
--Originally written by VanessaE (I think), rewritten by cheapie
--WTFPL
local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
minetest.register_chatcommand("spawn", {
params = "",
description = "Teleport to the spawn point",
func = function(name, param)
local player = minetest.get_player_by_name(name)
if not player then
return false, "Player not found"
end
if spawn_spawnpos then
player:setpos(spawn_spawnpos)
return true, "Teleporting to spawn..."
else
return false, "The spawn point is not set!"
end
end,
})
minetest.register_chatcommand("setspawn", {
params = "",
description = "Sets the spawn point to your current position",
privs = { server=true },
func = function(name, param)
local player = minetest.get_player_by_name(name)
if not player then
return false, "Player not found"
end
local pos = player:getpos()
local x = pos.x
local y = pos.y
local z = pos.z
local pos_string = x..","..y..","..z
local pos_string_2 = "Setting spawn point to ("..x..", "..y..", "..z..")"
minetest.setting_set("static_spawnpoint",pos_string)
spawn_spawnpos = pos
minetest.setting_save()
return true, pos_string_2
end,
})