1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/modules/biter_noms_you.lua

73 lines
1.3 KiB
Lua
Raw Normal View History

2019-05-28 13:30:50 +02:00
--biters make comic like text sounds when they damage something -- mewmew
2021-03-24 21:14:55 +02:00
local Event = require 'utils.event'
2019-04-15 21:04:12 +02:00
local math_random = math.random
local strings = {
2021-03-24 17:46:00 +02:00
'delicious!',
'yum',
'yum',
'crunch',
'crunch',
'chomp',
'chomp',
'chow',
'chow',
'nibble',
'nibble',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom',
'nom'
2019-04-15 21:04:12 +02:00
}
2019-11-09 15:14:21 +02:00
local size_of_strings = #strings
2019-04-15 21:04:12 +02:00
local whitelist = {
2021-03-24 17:46:00 +02:00
['small-biter'] = true,
['medium-biter'] = true,
['big-biter'] = true,
['behemoth-biter'] = true
2019-04-15 21:04:12 +02:00
}
local function on_entity_damaged(event)
2021-03-24 17:46:00 +02:00
if not event.cause then
return
end
if not event.cause.valid then
return
end
if not whitelist[event.cause.name] then
return
end
if math_random(1, 5) == 1 then
event.cause.surface.create_entity(
{
name = 'flying-text',
position = event.cause.position,
text = strings[math_random(1, size_of_strings)],
color = {r = math_random(130, 170), g = math_random(130, 170), b = 130}
}
)
end
2019-04-15 21:04:12 +02:00
end
2021-03-24 17:46:00 +02:00
2021-03-24 21:14:55 +02:00
Event.add(defines.events.on_entity_damaged, on_entity_damaged)