From 90f83e77324ee04f30752c2600a8cbfbdc9f07c6 Mon Sep 17 00:00:00 2001 From: Robert Zenz Date: Sat, 19 Dec 2015 11:46:32 +0100 Subject: [PATCH] Revised activation system. --- doc/index.html | 65 ++++++++++++++++++++++++++++++--- mods/spawn_usher/spawnusher.lua | 18 ++++++++- 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/doc/index.html b/doc/index.html index 86200b8..2c604c3 100644 --- a/doc/index.html +++ b/doc/index.html @@ -62,6 +62,10 @@ activate () Activates the spawn usher system, if it has not been deactivated by a seeting in the configuration. + + + activate_internal () + Activates the system, without checking the configuration. is_air_bubble (start_pos) @@ -110,6 +114,14 @@

Fields

+ + + + + + + + @@ -119,8 +131,8 @@ - - + + @@ -168,6 +180,21 @@ + +
+ + activate_internal () +
+
+ Activates the system, without checking the configuration. Multiple + invokations have no effect. + + + + + + +
@@ -400,6 +427,34 @@

Fields

+
+ + activate +
+
+ If the system should be activated automatically. + + + + + + + +
+
+ + active +
+
+ If the system is active/has been activated. + + + + + + + +
after_spawn_callbacks @@ -429,11 +484,11 @@
- - random + + random_direction
- The random object that is used to get random values. + If the player should be facing a random direction after spawning. diff --git a/mods/spawn_usher/spawnusher.lua b/mods/spawn_usher/spawnusher.lua index 6ad6ca3..24d9792 100644 --- a/mods/spawn_usher/spawnusher.lua +++ b/mods/spawn_usher/spawnusher.lua @@ -36,6 +36,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- The only function that should be called from clients is activate. spawnusher = { + --- If the system should be activated automatically. + activate = settings.get_bool("spawnusher_activate", true), + + --- If the system is active/has been activated. + active = false, + --- The list of callbacks that are invoked after the player has been placed. after_spawn_callbacks = List:new(), @@ -84,9 +90,19 @@ spawnusher = { --- Activates the spawn usher system, if it has not been deactivated by -- a seeting in the configuration. function spawnusher.activate() - if settings.get_bool("spawnusher_activate", true) then + if spawnusher.activate then + spawnusher.activate_internal() + end +end + +--- Activates the system, without checking the configuration. Multiple +-- invokations have no effect. +function spawnusher.activate_internal() + if not spawnusher.active then minetest.register_on_newplayer(spawnusher.on_spawn_player) minetest.register_on_respawnplayer(spawnusher.on_spawn_player) + + spawnusher.active = true end end
activateIf the system should be activated automatically.
activeIf the system is active/has been activated.
after_spawn_callbacks The list of callbacks that are invoked after the player has been placed.The list of players that need to be placed.
randomThe random object that is used to get random values.random_directionIf the player should be facing a random direction after spawning.
random_placement_radius