VoxeLibre/mods/ENVIRONMENT/lightning/API.md

32 lines
820 B
Markdown
Raw Permalink Normal View History

2021-09-09 14:31:19 +02:00
# lightning
2024-05-02 06:04:41 +02:00
Lightning mod for VoxeLibre with the following API:
2021-09-09 14:31:19 +02:00
## 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.
2021-09-09 14:35:05 +02:00
* `pos`: optional, if not given a random pos will be chosen
* `returns`: bool - success if a strike happened
2021-09-09 14:31:19 +02:00
### 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)
2024-05-02 06:04:41 +02:00
```