First commit
[places.git] / init.lua
1 local spawn_spawnpos = minetest.setting_get_pos("static_spawnpoint")
2
3 places = {}
4
5 places.register_place = function (name, pos, command)
6 if not command then
7 command = name
8 end
9 minetest.register_chatcommand(command, {
10 params = "",
11 description = "Teleport to "..name,
12 func = function(nm, param)
13 local player = minetest.get_player_by_name(nm)
14 if not player then
15 return false, "Player not found"
16 end
17 player:setpos(pos)
18 return true, "Teleporting to "..name.."..."
19 end,
20 })
21 end
22
23
24 if spawn_spawnpos then
25 places.register_place("Spawn", spawn_spawnpos, "spawn")
26 end
27 places.register_place("Origin", {x=0, y=0, z=0}, "origin")
28 places.register_place("South Forest", {x=285, y=9, z=-2047}, "sf")
29
30 -- minetest.register_chatcommand("spawn", {
31 -- params = "",
32 -- description = "Teleport to the spawn point",
33 -- func = function(name, param)
34 -- local player = minetest.get_player_by_name(name)
35 -- if not player then
36 -- return false, "Player not found"
37 -- end
38 -- if spawn_spawnpos then
39 -- player:setpos(spawn_spawnpos)
40 -- return true, "Teleporting to spawn..."
41 -- else
42 -- return false, "The spawn point is not set!"
43 -- end
44 -- end,
45 -- })
46
47 -- minetest.register_chatcommand("origin", {
48 -- params = "",
49 -- privs = {teleport = true},
50 -- description = "Teleport to (0,0,0)",
51 -- func = function(name, param)
52 -- local player = minetest.get_player_by_name(name)
53 -- if not player then
54 -- return false, "Player not found"
55 -- end
56 -- player:setpos({x=0, y=0, z=0})
57 -- return true, "Teleporting to origin..."
58 -- end,
59 -- })
60
61
62 minetest.register_on_newplayer(function(player)
63 player:setpos({x=0, y=-1, z=0})
64 end
65 )