Revised activation system.

master
Robert Zenz 2015-12-19 11:46:32 +01:00
parent 817dee24c8
commit 90f83e7732
2 changed files with 77 additions and 6 deletions

View File

@ -62,6 +62,10 @@
<td class="name" nowrap><a href="#activate">activate ()</a></td>
<td class="summary">Activates the spawn usher system, if it has not been deactivated by
a seeting in the configuration.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#activate_internal">activate_internal ()</a></td>
<td class="summary">Activates the system, without checking the configuration.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_air_bubble">is_air_bubble (start_pos)</a></td>
@ -110,6 +114,14 @@
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#activate">activate</a></td>
<td class="summary">If the system should be activated automatically.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#active">active</a></td>
<td class="summary">If the system is active/has been activated.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#after_spawn_callbacks">after_spawn_callbacks</a></td>
<td class="summary">The list of callbacks that are invoked after the player has been placed.</td>
@ -119,8 +131,8 @@
<td class="summary">The list of players that need to be placed.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#random">random</a></td>
<td class="summary">The random object that is used to get random values.</td>
<td class="name" nowrap><a href="#random_direction">random_direction</a></td>
<td class="summary">If the player should be facing a random direction after spawning.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#random_placement_radius">random_placement_radius</a></td>
@ -168,6 +180,21 @@
</dd>
<dt>
<a name = "activate_internal"></a>
<strong>activate_internal ()</strong>
</dt>
<dd>
Activates the system, without checking the configuration. Multiple
invokations have no effect.
</dd>
<dt>
<a name = "is_air_bubble"></a>
@ -400,6 +427,34 @@
</dl>
<h2><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "activate"></a>
<strong>activate</strong>
</dt>
<dd>
If the system should be activated automatically.
</dd>
<dt>
<a name = "active"></a>
<strong>active</strong>
</dt>
<dd>
If the system is active/has been activated.
</dd>
<dt>
<a name = "after_spawn_callbacks"></a>
<strong>after_spawn_callbacks</strong>
@ -429,11 +484,11 @@
</dd>
<dt>
<a name = "random"></a>
<strong>random</strong>
<a name = "random_direction"></a>
<strong>random_direction</strong>
</dt>
<dd>
The random object that is used to get random values.
If the player should be facing a random direction after spawning.

View File

@ -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