Compare commits

...

5 Commits

Author SHA1 Message Date
Robert Zenz 00b222e63d Fixed typo. 2016-01-09 13:37:29 +01:00
Robert Zenz d8e558aaed Fixed naming collision. 2015-12-19 12:13:47 +01:00
Robert Zenz 4e0ecdd03e Added usage documentation. 2015-12-19 11:53:51 +01:00
Robert Zenz 90f83e7732 Revised activation system. 2015-12-19 11:46:32 +01:00
Robert Zenz 817dee24c8 Added setting for if the player should face a random direction. 2015-12-17 23:18:46 +01:00
3 changed files with 99 additions and 12 deletions

19
README
View File

@ -28,16 +28,20 @@ The system can be configured by adding settings to the `minetest.conf`:
# If the system should be activated, defaults to true.
spawnusher_activate = true
# The radius around the spawnpoint in which the players will be randomly
# placed, defaults to 40.
spawnusher_placement_radius = 40.
# The size of the air bubble that is required for the player to be placed.
# Note that this is only the vertical size, defaults to 2.
# If you want to avoid spawns in caves, this value needs to be increased
# to a sensible value.
spawnusher_bubble_size = 2
# The radius around the spawnpoint in which the players will be randomly
# placed, defaults to 40.
spawnusher_placement_radius = 40
# If the player should be rotatet so that they face a random direction
# after spawning, defaults to true.
spawnusher_random_direction = true
# If the player can not be placed because the block is currently not loaded,
# this amount of time will be waited before it is retried to place
# place the player, defaults to 0.5.
@ -106,6 +110,13 @@ Usage example:
end)
Force activation
----------------
You can force the activation of the system, even if it has been disabled in
the configuration, by invoking `spawnusher.activate_internal`.
Caveats
-------

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_automatically">activate_automatically</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_automatically"></a>
<strong>activate_automatically</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_automatically = 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(),
@ -54,6 +60,9 @@ spawnusher = {
--- The list of players that need to be placed.
players = List:new(),
--- If the player should be facing a random direction after spawning.
random_direction = settings.get_bool("spawnusher_random_direction", true),
--- The placement radius around the spawn.
random_placement_radius = settings.get_number("spawnusher_placement_radius", 40),
@ -81,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_automatically 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
@ -180,8 +199,10 @@ function spawnusher.move_player(player)
-- Awesome! Place the user here.
player:setpos(pos)
-- Randomize the direction in which the player looks.
player:set_look_yaw(math.rad(random.next_int(0, 360)))
if spawnusher.random_direction then
-- Randomize the direction in which the player looks.
player:set_look_yaw(math.rad(random.next_int(0, 360)))
end
-- Reset the physics override.
player:set_physics_override(spawnusher.player_physics[player:get_player_name()])