summaryrefslogtreecommitdiff
path: root/spawn
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 20:02:19 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2016-04-01 21:09:33 -0400
commitda66780a569712c23ae4f2996cfb4608a9f9d69d (patch)
tree217556029a78bc23ad4564720afc86de97228a04 /spawn
parent615b22df4d423aded3613db7716943a2f389b047 (diff)
downloaddreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz
dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'spawn')
-rw-r--r--spawn/init.lua67
1 files changed, 67 insertions, 0 deletions
diff --git a/spawn/init.lua b/spawn/init.lua
new file mode 100644
index 0000000..09eec7b
--- /dev/null
+++ b/spawn/init.lua
@@ -0,0 +1,67 @@
+
+-- Some modified from: Minetest: builtin/static_spawn.lua
+
+local function check_spawnpoint(config_setting)
+ if not minetest.setting_get(config_setting) then
+ minetest.log('error', "The \"" .. config_setting .. "\" setting is not set")
+ return false
+ end
+
+ if not minetest.setting_get_pos(config_setting) then
+ minetest.log('error', "The " .. config_setting .. " setting is invalid: \""..
+ core.setting_get(config_setting).."\"")
+ return false
+ end
+ return true
+end
+
+
+local function put_player_at_spawn(obj)
+
+ local config_setting
+
+ -- players with interact spawn at the location specified by
+ -- "alt_spawnpoint" in the .conf file. Those *without* interact go to
+ -- "static_spawnpoint".
+
+ if not minetest.get_player_privs(obj:get_player_name()).interact then
+ config_setting = "static_spawnpoint"
+ else
+ config_setting = "alt_spawnpoint"
+ end
+
+ if not check_spawnpoint(config_setting) then
+ return false
+ end
+
+ local spawnpoint = minetest.setting_get_pos(config_setting)
+
+ minetest.log('action', "Moving " .. obj:get_player_name() ..
+ " to " .. config_setting .. " at "..
+ minetest.pos_to_string(spawnpoint))
+
+ obj:setpos(spawnpoint)
+
+ return true
+end
+
+
+minetest.register_chatcommand("spawn", {
+ description = "Teleport to the spawn location",
+ func = function(name, _)
+ local ok = put_player_at_spawn(minetest.get_player_by_name(name))
+ if ok then
+ return true, "Teleporting to spawn..."
+ end
+ return false, "Teleport failed"
+ end
+})
+
+
+minetest.register_on_newplayer(function(obj)
+ return put_player_at_spawn(obj)
+end)
+
+minetest.register_on_respawnplayer(function(obj)
+ return put_player_at_spawn(obj)
+end)