First commit
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sun, 17 Dec 2017 23:04:26 +0000 (00:04 +0100)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Sun, 17 Dec 2017 23:04:26 +0000 (00:04 +0100)
init.lua [new file with mode: 0644]

diff --git a/init.lua b/init.lua
new file mode 100644 (file)
index 0000000..d47e014
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,65 @@
+local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
+
+places = {}
+
+places.register_place = function (name, pos, command)
+   if not command then
+      command = name
+   end
+   minetest.register_chatcommand(command, {
+        params = "",
+        description = "Teleport to "..name,
+        func = function(nm, param)
+                local player = minetest.get_player_by_name(nm)
+                if not player then
+                        return false, "Player not found"
+                end
+               player:setpos(pos)
+               return true, "Teleporting to "..name.."..."
+        end,
+   })
+end
+
+                                   
+if spawn_spawnpos then
+   places.register_place("Spawn", spawn_spawnpos, "spawn")
+end
+places.register_place("Origin", {x=0, y=0, z=0}, "origin")
+places.register_place("South Forest", {x=285, y=9, z=-2047}, "sf")
+
+-- 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("origin", {
+--         params = "",
+--         privs = {teleport = true},
+--         description = "Teleport to (0,0,0)",
+--         func = function(name, param)
+--                 local player = minetest.get_player_by_name(name)
+--                 if not player then
+--                         return false, "Player not found"
+--                 end
+--                 player:setpos({x=0, y=0, z=0})
+--                 return true, "Teleporting to origin..."
+--         end,
+-- })
+
+
+minetest.register_on_newplayer(function(player)
+        player:setpos({x=0, y=-1, z=0})
+        end
+)