1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00
RedMew/features/fish_burps.lua
RedRafe 26e1c28dc0
Factorio 2.0 update (#1436)
* Init Factorio 2.0 update

* add credits

* fix test module

* I know luackeck, I know

* Fixes

* Fix bad event.player_index handling

* Hotfixes

* Remove all filter inserters

* Migrate removed items

* Deprecating spidertron control and landfill features
2024-10-22 20:22:35 +01:00

28 lines
920 B
Lua

-- A feature to add cute flying text of a fish when a player uses a fish to heal themselves. Useful for teamwork.
local Event = require 'utils.event'
local Game = require 'utils.game'
local function capsule_used(event)
if event.item.name ~= "raw-fish" then
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid or not player.character or not player.character.valid then
return
end
local health_ratio = player.character.get_health_ratio()
if health_ratio == 1 then -- to stop people spamming it
return
end
Game.create_local_flying_text {
surface = player.physical_surface,
text = '[img=item.raw-fish]',
position = {player.physical_position.x,player.physical_position.y-3} -- creates the fish just above players head
}
end
Event.add(defines.events.on_player_used_capsule, capsule_used)