diff options
author | ShadowNinja <shadowninja@minetest.net> | 2014-04-27 17:55:49 -0400 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2014-05-07 17:14:23 -0400 |
commit | 1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528 (patch) | |
tree | 8c1e2c708f567656684e89faee4f7c8e6c5ec673 /builtin/game/static_spawn.lua | |
parent | fef2729fd0945601e6772780514ee55fec35b068 (diff) | |
download | minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.tar.gz minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.tar.bz2 minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.zip |
Organize builtin into subdirectories
Diffstat (limited to 'builtin/game/static_spawn.lua')
-rw-r--r-- | builtin/game/static_spawn.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/builtin/game/static_spawn.lua b/builtin/game/static_spawn.lua new file mode 100644 index 000000000..e8c107d86 --- /dev/null +++ b/builtin/game/static_spawn.lua @@ -0,0 +1,33 @@ +-- Minetest: builtin/static_spawn.lua + +local function warn_invalid_static_spawnpoint() + if minetest.setting_get("static_spawnpoint") and + not minetest.setting_get_pos("static_spawnpoint") then + minetest.log('error', "The static_spawnpoint setting is invalid: \"".. + minetest.setting_get("static_spawnpoint").."\"") + end +end + +warn_invalid_static_spawnpoint() + +local function put_player_in_spawn(obj) + warn_invalid_static_spawnpoint() + local static_spawnpoint = minetest.setting_get_pos("static_spawnpoint") + if not static_spawnpoint then + return false + end + minetest.log('action', "Moving "..obj:get_player_name().. + " to static spawnpoint at ".. + minetest.pos_to_string(static_spawnpoint)) + obj:setpos(static_spawnpoint) + return true +end + +minetest.register_on_newplayer(function(obj) + put_player_in_spawn(obj) +end) + +minetest.register_on_respawnplayer(function(obj) + return put_player_in_spawn(obj) +end) + |