-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_claw-multi-silo.lua
More file actions
54 lines (50 loc) · 2.24 KB
/
remove_claw-multi-silo.lua
File metadata and controls
54 lines (50 loc) · 2.24 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/sc
if not storage.multi_silo then
game.player.print("Multi Silo is not running", {color = {r=0.9,g=0,b=0}})
return
end
for _,player in pairs(game.players) do
if storage.chosen_team[player.name] then
player.remove_item{name = "rocket-silo", count = 1000000}
end
end
for _, force in pairs({"north", "south"}) do
local silos = storage.multi_silo[force]
if not storage.rocket_silo[force] and #silos > 0 then
local function closest_silo(pos)
local closest_silo = silos[1]
local dist = (pos.x - closest_silo.position.x) ^ 2 + (pos.y - closest_silo.position.y) ^ 2
for i = 2, #silos do
local other_silo = silos[i]
local other_dist = (pos.x - other_silo.position.x) ^ 2 + (pos.y - other_silo.position.y) ^ 2
if other_dist < dist then
closest_silo = other_silo
dist = other_dist
end
end
return closest_silo
end
storage.rocket_silo[force] = closest_silo({x = 0, y = 0})
end
end
local surface = game.surfaces[storage.bb_surface_name]
local chest = surface.find_entity("wooden-chest", {0.5, -25.5})
if chest then
chest.destroy()
end
local Event = require "utils.event"
Event.remove_removable_function(defines.events.on_surface_deleted, "multi_silo_on_surface_deleted")
Event.remove_removable_function(defines.events.on_player_respawned, "multi_silo_on_player_respawned")
Event.remove_removable_function(defines.events.on_built_entity, "multi_silo_on_built_entity")
Event.remove_removable_function(defines.events.on_robot_built_entity, "multi_silo_on_built_entity_robot")
Event.remove_removable_function(defines.events.on_player_died, "multi_silo_on_player_died")
Event.remove_removable_function(defines.events.on_gui_click, "multi_silo_on_gui_click")
Event.remove_removable_function(defines.events.on_entity_died, "multi_silo_on_entity_died")
Event.remove_removable_function(defines.events.on_player_changed_force, "multi_silo_on_player_changed_force")
Event.remove_removable_function(defines.events.on_unit_group_finished_gathering, "multi_silo_on_unit_group_finished_gathering")
Event.remove_removable_nth_tick_function(300, "multi_silo_chart_silos")
storage.multi_silo_join_team_delay_template = nil
storage.multi_silo_max_build = nil
storage.multi_silo_respawn = nil
storage.multi_silo = nil
game.print("Special game: Multi Silo removed.")