diff --git a/README.md b/README.md index ad58189..d9045f9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/init.lua b/init.lua index f6dfada..bc5e144 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/settings.txt b/settings.txt index 160680f..8146113 100644 --- a/settings.txt +++ b/settings.txt @@ -2,4 +2,5 @@ TOOLS_ENHANCE = true CLEAN_UNKNOWN = true EXTERNAL_CMD = true PLAYER_AFK = true +SPAWN_POINT = true AREAS_ENHANCE = false diff --git a/spawn.lua b/spawn.lua new file mode 100644 index 0000000..4c07bf8 --- /dev/null +++ b/spawn.lua @@ -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, +})