-
Notifications
You must be signed in to change notification settings - Fork 11
/
control.lua
88 lines (68 loc) · 2.71 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require("util")
require("config.config") -- config for squad control mechanics - important for anyone using
require("robolib.util") -- some utility functions not necessarily related to robot army mod
require("robolib.robotarmyhelpers") -- random helper functions related to the robot army mod
require("robolib.Squad") -- allows us to control squads, add entities to squads, etc.
require("robolib.eventhandlers")
require("robolib.onload")
require("prototypes.DroidUnitList") -- so we know what is spawnable
require("stdlib/log/logger")
require("stdlib/game")
LOGGER = Logger.new("robotarmy", "robot_army_logs", false, {log_ticks = false})
global.runOnce = false
function init_robotarmy()
LOGGER.log("Robot Army mod Init script running...")
if not global.Squads then
global.Squads = {}
end
if not global.uniqueSquadId then
global.uniqueSquadId = {}
end
if not global.DroidAssemblers then
global.DroidAssemblers = {}
end
if not global.droidCounters then
global.droidCounters = {}
end
if not global.lootChests then
global.lootChests = {}
end
if global.rallyBeacons then
global.rallyBeacons = nil
end
if not global.droidGuardStations then
global.droidGuardStations = {}
end
if not global.updateTable then
global.updateTable = {}
end
if not global.units then
global.units = {}
end
--deal with player force as default set-up process
event = {} --event stub, to match function inputs
for _, v in pairs(game.forces) do
event.force = v
handleForceCreated(event)
end
LOGGER.log("Robot Army mod Init script finished...")
game.print("Robot Army mod Init completed!")
end
script.on_init(init_robotarmy)
script.on_event(defines.events.on_force_created, handleForceCreated)
script.on_event(defines.events.on_built_entity, handleOnBuiltEntity)
script.on_event(defines.events.on_robot_built_entity, handleOnRobotBuiltEntity)
script.on_event(defines.events.script_raised_built, handleOnScriptRaisedBuilt)
script.on_event(defines.events.on_ai_command_completed, AiCommandCompleteHandler)
function playerSelectedArea(event)
reportSelectedUnits(event, false)
end
function playerAltSelectedArea(event)
reportSelectedUnits(event, true)
end
script.on_event(defines.events.on_player_selected_area, playerSelectedArea)
script.on_event(defines.events.on_player_alt_selected_area, playerAltSelectedArea)
-- this on tick handler will get replaced on the first tick after 'live' migrations have run
script.on_event(defines.events.on_tick, bootstrap_migration_on_first_tick)
script.on_event(defines.events.on_player_joined_game, onPlayerJoined)
script.on_configuration_changed(handleModChanges)