Dofile Commands Updated & Spawn is now Genesis

This commit is contained in:
endev15 2016-04-04 07:55:26 -07:00
parent 5c79fe0d2e
commit 1d7312f91b
2 changed files with 14 additions and 13 deletions

View File

@ -1,26 +1,26 @@
--Set spawn command --Set Genesis Command
minetest.register_chatcommand("setspawn", { minetest.register_chatcommand("setgenesis", {
params = "", params = "",
privs = {admin = true}, privs = {admin = true},
description = "Set the spawn point.", description = "Set the Genesis point (beginning).",
func = function(name, param) func = function(name, param)
--Check for proper player [forbids console commands, not really needed] --Check for proper player [forbids console commands, not really needed]
local player = minetest.env:get_player_by_name(name) local player = minetest.env:get_player_by_name(name)
if not player then if not player then
return return
end end
--Get player position and set spawn just below that just because it looks cooler. --Get player position and set genesis just below that just because it looks cooler.
local pos = player:getpos() local pos = player:getpos()
pos.x = math.floor(0.5+pos.x) pos.x = math.floor(0.5+pos.x)
pos.z = math.floor(0.5+pos.z) pos.z = math.floor(0.5+pos.z)
minetest.setting_set("static_spawnpoint", minetest.pos_to_string(pos)) minetest.setting_set("static_spawnpoint", minetest.pos_to_string(pos))
--Notify admin who set spawn. --Notify admin who set genesis.
minetest.chat_send_player(name, "Spawn set at, "..minetest.setting_get("static_spawnpoint")); minetest.chat_send_player(name, "Genesis point set at, "..minetest.setting_get("static_spawnpoint"));
end, end,
}) })
--Make sure player spawns at set spawnpoint when he dies if it exists. --Make sure player initializes at set genesis when he hurts himself badly if it exists.
minetest.register_on_respawnplayer(function(player) minetest.register_on_respawnplayer(function(player)
if not player then if not player then
return return
@ -31,7 +31,7 @@ minetest.register_on_respawnplayer(function(player)
player:setpos(minetest.string_to_pos(minetest.setting_get("static_spawnpoint"))) player:setpos(minetest.string_to_pos(minetest.setting_get("static_spawnpoint")))
end) end)
--Make sure player spawns at set spawnpoint when he joins if it exists. --Make sure player initializes at set genesis when he joins if it exists.
minetest.register_on_newplayer(function(player) minetest.register_on_newplayer(function(player)
if not player then if not player then
return return
@ -42,11 +42,11 @@ minetest.register_on_newplayer(function(player)
player:setpos(minetest.string_to_pos(minetest.setting_get("static_spawnpoint"))) player:setpos(minetest.string_to_pos(minetest.setting_get("static_spawnpoint")))
end) end)
--Make /spawn go to a spawnpoint set by admins if it exists. --Make /genesis go to a genesis point set by admins if it exists.
minetest.register_chatcommand("spawn", { minetest.register_chatcommand("genesis", {
params = "", params = "",
privs = {}, privs = {},
description = "Set the spawn point.", description = "Initialize transportation to the Genesis.",
func = function(name, param) func = function(name, param)
local player = minetest.env:get_player_by_name(name) local player = minetest.env:get_player_by_name(name)
if not player then if not player then
@ -56,7 +56,8 @@ minetest.register_chatcommand("spawn", {
return return
end end
player:setpos(minetest.string_to_pos(minetest.setting_get("static_spawnpoint"))) player:setpos(minetest.string_to_pos(minetest.setting_get("static_spawnpoint")))
minetest.chat_send_player(name, "Initializing transportation to the Genesis point...");
end end
}) })
print("[Server_Tools] Player Spawn Module Loaded") print("[Server_Tools] Genesis Module Loaded")

View File

@ -2,5 +2,5 @@ server_tools = {}
-- Load Modules -- Load Modules
dofile(minetest.get_modpath("server_tools").."/privs.lua") dofile(minetest.get_modpath("server_tools").."/privs.lua")
dofile(minetest.get_modpath("server_tools").."/spawn.lua") dofile(minetest.get_modpath("server_tools").."/genesis.lua")
dofile(minetest.get_modpath("server_tools").."/misc.lua") dofile(minetest.get_modpath("server_tools").."/misc.lua")