Spawn Usher can now be configured from the configuration.
parent
f591243212
commit
66eafdfa8c
42
README
42
README
|
@ -8,29 +8,29 @@ about the mapgen that is used.
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
To activate the system, add it to your `depends.txt` and call this in your
|
The system activates itself, you just need to add the mod to the subgame.
|
||||||
`init.lua.`:
|
|
||||||
|
|
||||||
spawnusher.activate()
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
The system can be configured by adding settings to the `minetest.conf`:
|
||||||
|
|
||||||
|
# The radius around the spawnpoint in which the players will be randomly
|
||||||
|
# placed, defaults to 40.
|
||||||
|
spawnusher_placement_radius = 40.
|
||||||
|
|
||||||
-- With parameters.
|
# The size of the air bubble that is required for the player to be placed.
|
||||||
spawnusher.activate(
|
# Note that this is only the vertical size, defaults to 2.
|
||||||
40, -- random_placement_radius
|
# If you want to avoid spawns in caves, this value needs to be increased
|
||||||
2, -- required_bubble_size
|
# to a sensible value.
|
||||||
0.5) -- retry_time
|
spawnusher_bubble_size = 2
|
||||||
|
|
||||||
Optionally, you can set parameters when activating it, it accepts three
|
# If the player can not be placed because the block is currently not loaded,
|
||||||
parameters:
|
# this amount of time will be waited before it is retried to place
|
||||||
|
# place the player, defaults to 0.5.
|
||||||
1. `random_placement_radius`, the player will be randomly placed around
|
# In seconds.
|
||||||
the spawn point inside the given radius.
|
spawnusher_retry_time = 0.5
|
||||||
Defaults to 40.
|
|
||||||
2. `required_bubble_size`, the size of the air bubble that is required for
|
|
||||||
the player to be placed there. Note this is only the vertical size.
|
|
||||||
Defaults to 2.
|
|
||||||
3. `retry_time`, if the player can't be placed because a block is not loaded
|
|
||||||
yet, this is the amount of time that is elapsed until a retry.
|
|
||||||
Defaults to 0.5 seconds.
|
|
||||||
|
|
||||||
|
|
||||||
Providers
|
Providers
|
||||||
|
|
238
doc/index.html
238
doc/index.html
|
@ -30,6 +30,8 @@
|
||||||
<h2>Contents</h2>
|
<h2>Contents</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#Functions">Functions</a></li>
|
<li><a href="#Functions">Functions</a></li>
|
||||||
|
<li><a href="#Tables">Tables</a></li>
|
||||||
|
<li><a href="#Fields">Fields</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,8 +59,9 @@
|
||||||
<h2><a href="#Functions">Functions</a></h2>
|
<h2><a href="#Functions">Functions</a></h2>
|
||||||
<table class="function_list">
|
<table class="function_list">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" nowrap><a href="#activate">activate (random_placement_radius, required_bubble_size, retry_time)</a></td>
|
<td class="name" nowrap><a href="#activate">activate ()</a></td>
|
||||||
<td class="summary">Activates the spawn usher system.</td>
|
<td class="summary">Activates the spawn usher system, if it has not been deactivated by
|
||||||
|
a seeting in the configuration.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="name" nowrap><a href="#is_air_bubble">is_air_bubble (start_pos)</a></td>
|
<td class="name" nowrap><a href="#is_air_bubble">is_air_bubble (start_pos)</a></td>
|
||||||
|
@ -94,6 +97,52 @@
|
||||||
the player has been determined.</td>
|
the player has been determined.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<h2><a href="#Tables">Tables</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#physics_override">physics_override</a></td>
|
||||||
|
<td class="summary">The physics override that is set to make the player inmovable.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#player_physics">player_physics</a></td>
|
||||||
|
<td class="summary">The original physics of the payers.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h2><a href="#Fields">Fields</a></h2>
|
||||||
|
<table class="function_list">
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#players">players</a></td>
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#random_placement_radius">random_placement_radius</a></td>
|
||||||
|
<td class="summary">The placement radius around the spawn.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#required_bubble_size">required_bubble_size</a></td>
|
||||||
|
<td class="summary">The required air bubble size.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#retry_time">retry_time</a></td>
|
||||||
|
<td class="summary">The retry time.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#scheduled">scheduled</a></td>
|
||||||
|
<td class="summary">If the system is currently scheduled for execution.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="name" nowrap><a href="#spawnpoint_providers">spawnpoint_providers</a></td>
|
||||||
|
<td class="summary">The registered spawnpoint providers.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -103,28 +152,13 @@
|
||||||
<dl class="function">
|
<dl class="function">
|
||||||
<dt>
|
<dt>
|
||||||
<a name = "activate"></a>
|
<a name = "activate"></a>
|
||||||
<strong>activate (random_placement_radius, required_bubble_size, retry_time)</strong>
|
<strong>activate ()</strong>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Activates the spawn usher system.
|
Activates the spawn usher system, if it has not been deactivated by
|
||||||
|
a seeting in the configuration.
|
||||||
|
|
||||||
|
|
||||||
<h3>Parameters:</h3>
|
|
||||||
<ul>
|
|
||||||
<li><span class="parameter">random_placement_radius</span>
|
|
||||||
Optional. The player will be respawned in
|
|
||||||
the given radius around the spawn point.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">required_bubble_size</span>
|
|
||||||
Optional. The size/height of the bubble of
|
|
||||||
air that is required for the player to spawn.
|
|
||||||
Defaults to 2.
|
|
||||||
</li>
|
|
||||||
<li><span class="parameter">retry_time</span>
|
|
||||||
Optional. This is the time that passes between tries to
|
|
||||||
place to the player.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -309,6 +343,170 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<h2><a name="Tables"></a>Tables</h2>
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "physics_override"></a>
|
||||||
|
<strong>physics_override</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The physics override that is set to make the player inmovable.
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Fields:</h3>
|
||||||
|
<ul>
|
||||||
|
<li><span class="parameter">speed</span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">jump</span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">gravity</span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">sneak</span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><span class="parameter">sneak_glitch</span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "player_physics"></a>
|
||||||
|
<strong>player_physics</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The original physics of the payers.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<h2><a name="Fields"></a>Fields</h2>
|
||||||
|
<dl class="function">
|
||||||
|
<dt>
|
||||||
|
<a name = "after_spawn_callbacks"></a>
|
||||||
|
<strong>after_spawn_callbacks</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The list of callbacks that are invoked after the player has been placed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "players"></a>
|
||||||
|
<strong>players</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The list of players that need to be placed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "random"></a>
|
||||||
|
<strong>random</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The random object that is used to get random values.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "random_placement_radius"></a>
|
||||||
|
<strong>random_placement_radius</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The placement radius around the spawn.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "required_bubble_size"></a>
|
||||||
|
<strong>required_bubble_size</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The required air bubble size.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "retry_time"></a>
|
||||||
|
<strong>retry_time</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The retry time.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "scheduled"></a>
|
||||||
|
<strong>scheduled</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
If the system is currently scheduled for execution.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<a name = "spawnpoint_providers"></a>
|
||||||
|
<strong>spawnpoint_providers</strong>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
The registered spawnpoint providers.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
|
@ -30,3 +30,6 @@ local base_path = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
dofile(base_path .. "/spawnusher.lua")
|
dofile(base_path .. "/spawnusher.lua")
|
||||||
|
|
||||||
|
|
||||||
|
spawnusher.activate()
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
--
|
--
|
||||||
-- The only function that should be called from clients is activate.
|
-- The only function that should be called from clients is activate.
|
||||||
spawnusher = {
|
spawnusher = {
|
||||||
|
--- The list of callbacks that are invoked after the player has been placed.
|
||||||
after_spawn_callbacks = List:new(),
|
after_spawn_callbacks = List:new(),
|
||||||
|
|
||||||
|
--- The physics override that is set to make the player inmovable.
|
||||||
physics_override = {
|
physics_override = {
|
||||||
speed = 0,
|
speed = 0,
|
||||||
jump = 0,
|
jump = 0,
|
||||||
|
@ -44,38 +47,45 @@ spawnusher = {
|
||||||
sneak = false,
|
sneak = false,
|
||||||
sneak_glitch = false
|
sneak_glitch = false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
--- The original physics of the payers.
|
||||||
player_physics = {},
|
player_physics = {},
|
||||||
|
|
||||||
|
--- The list of players that need to be placed.
|
||||||
players = List:new(),
|
players = List:new(),
|
||||||
|
|
||||||
|
--- The random object that is used to get random values.
|
||||||
random = nil,
|
random = nil,
|
||||||
random_placement_radius = 40,
|
|
||||||
required_bubble_size = 2,
|
--- The placement radius around the spawn.
|
||||||
retry_time = 0.5,
|
random_placement_radius = settings.get_number("spawnusher_placement_radius", 40),
|
||||||
|
|
||||||
|
--- The required air bubble size.
|
||||||
|
required_bubble_size = settings.get_number("spawnusher_bubble_size", 2),
|
||||||
|
|
||||||
|
--- The retry time.
|
||||||
|
retry_time = settings.get_number("spawnusher_retry_time", 0.5),
|
||||||
|
|
||||||
|
--- If the system is currently scheduled for execution.
|
||||||
scheduled = false,
|
scheduled = false,
|
||||||
|
|
||||||
|
--- The registered spawnpoint providers.
|
||||||
spawnpoint_providers = List:new()
|
spawnpoint_providers = List:new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Activates the spawn usher system.
|
--- Activates the spawn usher system, if it has not been deactivated by
|
||||||
--
|
-- a seeting in the configuration.
|
||||||
-- @param random_placement_radius Optional. The player will be respawned in
|
function spawnusher.activate()
|
||||||
-- the given radius around the spawn point.
|
if settings.get_bool("spawnusher_activate", true) then
|
||||||
-- @param required_bubble_size Optional. The size/height of the bubble of
|
-- Initialize the PcgRandom with the current time. Given that placement
|
||||||
-- air that is required for the player to spawn.
|
-- of the player is not critical or needs to be reproducable in any way,
|
||||||
-- Defaults to 2.
|
-- it really does not matter here.
|
||||||
-- @param retry_time Optional. This is the time that passes between tries to
|
spawnusher.random = PcgRandom(os.time())
|
||||||
-- place to the player.
|
|
||||||
function spawnusher.activate(random_placement_radius, required_bubble_size, retry_time)
|
minetest.register_on_newplayer(spawnusher.on_spawn_player)
|
||||||
spawnusher.random_placement_radius = random_placement_radius or 40
|
minetest.register_on_respawnplayer(spawnusher.on_spawn_player)
|
||||||
spawnusher.required_bubble_size = required_bubble_size or 2
|
end
|
||||||
spawnusher.retry_time = retry_time or 0.5
|
|
||||||
|
|
||||||
-- Initialize the PcgRandom with the current time. Given that placement
|
|
||||||
-- of the player is not critical or needs to be reproducable in any way,
|
|
||||||
-- it really does not matter here.
|
|
||||||
spawnusher.random = PcgRandom(os.time())
|
|
||||||
|
|
||||||
minetest.register_on_newplayer(spawnusher.on_spawn_player)
|
|
||||||
minetest.register_on_respawnplayer(spawnusher.on_spawn_player)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Tests if the given position is an air bubble big enough.
|
--- Tests if the given position is an air bubble big enough.
|
||||||
|
|
Loading…
Reference in New Issue