-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.lua
39 lines (34 loc) · 1.21 KB
/
control.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local event = require("__flib__.event")
local function search_chunk(surface, chunk, player)
local chunkCoords = chunk.area.left_top
if surface.get_pollution({chunkCoords.x, chunkCoords.y}) <= 0 then
return false
end
local pollutedEntities = surface.find_entities_filtered {
area = chunk.area,
type = "unit-spawner"
}
if #pollutedEntities <= 0 then return false end
player.force.add_chart_tag(surface, {
position = pollutedEntities[1].position,
icon = {type = "virtual", name = "signal-red"},
text = "[entity=spitter-spawner]",
last_user = player
})
return true
end
event.on_lua_shortcut(function(e)
if e.prototype_name == "biter-finder" then
local player = game.get_player(e.player_index)
local surface = player.surface
local found = false
for chunk in surface.get_chunks() do
found = search_chunk(surface, chunk, player) or found
end
if found then
player.add_custom_alert(player.character,
{type = "virtual", name = "signal-red"},
{"biter-finder-spawners-found"}, true)
end
end
end)