2015-07-23 10:47:37 -07:00
|
|
|
minetest-australopithecus-spawn-usher
|
|
|
|
=====================================
|
|
|
|
|
|
|
|
A simple system that corrects the spawn of players without knowing anything
|
|
|
|
about the mapgen that is used.
|
|
|
|
|
2015-07-28 10:31:00 -07:00
|
|
|
|
|
|
|
Usage
|
|
|
|
=====
|
|
|
|
|
2015-07-23 10:47:37 -07:00
|
|
|
To activate the system, add it to your `depends.txt` and call this in your
|
2015-07-28 10:31:00 -07:00
|
|
|
`init.lua.`:
|
2015-07-23 10:47:37 -07:00
|
|
|
|
|
|
|
spawnusher.activate()
|
2015-09-02 10:43:43 -07:00
|
|
|
|
|
|
|
-- With parameters.
|
|
|
|
spawnusher.activate(
|
2015-09-06 02:05:40 -07:00
|
|
|
40, -- random_placement_radius
|
|
|
|
2, -- required_bubble_size
|
|
|
|
0.5) -- retry_time
|
2015-07-23 10:47:37 -07:00
|
|
|
|
2015-07-28 10:31:00 -07:00
|
|
|
Optionally, you can set parameters when activating it, it accepts three
|
|
|
|
parameters:
|
|
|
|
|
|
|
|
1. `random_placement_radius`, the player will be randomly placed around
|
|
|
|
the spawn point inside the given radius.
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
2015-09-05 13:18:50 -07:00
|
|
|
Providers
|
|
|
|
=========
|
|
|
|
|
|
|
|
You can register providers which allow to customize the spawn point of
|
|
|
|
the players. The provider is a callback that is able to provide a different
|
|
|
|
spawn point. The signature is:
|
|
|
|
|
|
|
|
function(
|
|
|
|
player, -- The Player object of the player that is going to respawn.
|
|
|
|
spawn_pos) -- The current spawn position of the player.
|
|
|
|
|
|
|
|
returns
|
|
|
|
spawn_pos -- The position at which the player should ge respawned.
|
|
|
|
-- nil to use the current one.
|
|
|
|
|
|
|
|
And a usage example:
|
|
|
|
|
|
|
|
-- Fixes the spawn point of the player named "hero" at some position.
|
|
|
|
spawnusher.register_spawnpoint_provider(function(player, spawn_pos)
|
|
|
|
if player:get_player_name() == "hero" then
|
|
|
|
return {
|
|
|
|
x = 0,
|
|
|
|
y = 125,
|
|
|
|
z = 50
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
After Spawn Callbacks
|
|
|
|
=====================
|
|
|
|
|
|
|
|
You can register a callback that will be invoked after the player has been
|
|
|
|
respawned. This callback can't modify the spawn point anymore and is only
|
|
|
|
to get informed about the actual spawn point of the player. The signature is:
|
|
|
|
|
|
|
|
function(
|
|
|
|
player, -- The Player object of the player that has respawned.
|
|
|
|
spawn_point) -- The spawn point of the player.
|
|
|
|
|
|
|
|
Usage example:
|
|
|
|
|
|
|
|
spawnusher.register_after_spawn_callback(function(player, spawn_point)
|
|
|
|
-- Do something with this information.
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
2015-07-28 10:31:00 -07:00
|
|
|
Caveats
|
|
|
|
=======
|
|
|
|
|
|
|
|
There is a good chance that the player is placed inside a cave if
|
|
|
|
the `required_bubble_size` is small, like 2. If you want to prevent that, just
|
|
|
|
pick a `required_bubble_size` that is large enough to avoid caves, 10 should
|
|
|
|
work for the most part, for example.
|
|
|
|
|