mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 20:11:06 +01:00
add API.md for lightning mod
This commit is contained in:
parent
fe91d7f3e0
commit
9188467a6a
1 changed files with 31 additions and 0 deletions
31
mods/ENVIRONMENT/lightning/API.md
Normal file
31
mods/ENVIRONMENT/lightning/API.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# lightning
|
||||
Lightning mod for MineClone2 with the following API:
|
||||
|
||||
## lightning.register_on_strike(function(pos, pos2, objects))
|
||||
Custom function called when a lightning strikes.
|
||||
|
||||
* `pos`: impact position
|
||||
* `pos2`: rounded node position where fire is placed
|
||||
* `objects`: table with ObjectRefs of all objects within a radius of 3.5 around pos2
|
||||
|
||||
## lightning.strike(pos)
|
||||
Let a lightning strike.
|
||||
|
||||
* pos: optional, if not given a random pos will be chosen
|
||||
* returns: bool - success if a strike happened
|
||||
|
||||
|
||||
### Examples:
|
||||
|
||||
```
|
||||
lightning.register_on_strike(function(pos, pos2, objects)
|
||||
for _, obj in pairs(objects) do
|
||||
obj:remove()
|
||||
end
|
||||
minetest.add_entity(pos, "mobs_mc:sheep")
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
lightning.strike(player:get_pos())
|
||||
end)
|
||||
```
|
Loading…
Reference in a new issue