-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontrol.lua
132 lines (104 loc) · 4.89 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
-- Credit:
-- -- The Oddlers Factorio World
-- -- -- The world loader is done via his code
-- -- MojoD -- Frontier Extended
-- -- -- The Pre-Placed Silo is from his work
-- -- OARC
-- -- -- Terrain manipulation
-- -- Loren1350
-- -- -- Spawn Map Generation Settings
-- -- RedRafe
-- -- -- Krastorio 2 integration
-- -- Nexela
-- -- -- code modules, reviews, and guidance
-- You may re-use what is written here. It would be nice to give credit where you can.
local Utils = require( "utils/utils" )
local Player = require( "scripts/coe_player" )
local Surface = require( "scripts/coe_surface" )
local WorldGen = require( "scripts/coe_worldgen" )
local Silo = require( "scripts/coe_silo" )
local Teleporter = require( "scripts/coe_teleporter" )
local TeleporterGUI = require( "scripts/coe_teleporter_gui" )
local StatsGUI = require( "scripts/coe_stats_gui" )
require( "commands" )
---@param event EventData.CustomInputEvent
local function run_test_function( event )
local player = game.get_player( event.player_index )
player.game_view_settings["show_research_info"] = not player.game_view_settings["show_research_info"]
player.game_view_settings["show_side_menu"] = not player.game_view_settings["show_side_menu"]
player.game_view_settings["show_minimap"] = not player.game_view_settings["show_minimap"]
player.game_view_settings["show_map_view_options"] = not player.game_view_settings["show_map_view_options"]
player.game_view_settings["show_controller_gui"] = not player.game_view_settings["show_controller_gui"]
player.game_view_settings["show_shortcut_bar"] = not player.game_view_settings["show_shortcut_bar"]
player.game_view_settings["show_alert_gui"] = not player.game_view_settings["show_alert_gui"]
player.game_view_settings["update_entity_selection"] = not player.game_view_settings["update_entity_selection"]
end
-- =============================================================================
---Load order matters for init and load
---WorldGen -> Player -> Others
script.on_init( function()
global = {}
Utils.saveStartupSettings()
Utils.skipIntro()
WorldGen.onInit()
Player.onInit()
Surface.onInit()
Silo.onInit()
Teleporter.onInit()
end )
---Use on_load to setup metatables and link local upvalues
script.on_load( function()
WorldGen.onLoad()
Surface.onLoad()
Silo.onLoad()
Teleporter.onLoad()
end )
script.on_configuration_changed( function()
local pre_place_silo = global.settings.startup.coe_pre_place_silo.value
Utils.saveStartupSettings()
Utils.moveSiloData()
Silo.checkEnablingSilos( Utils.calculateMaxLaunches( pre_place_silo ) )
Silo.setPrePlacedSilo( pre_place_silo )
end )
-------------------------------------------------------------------------------
script.on_event( defines.events.on_surface_cleared, WorldGen.onSurfaceCleared )
script.on_event( defines.events.on_chunk_generated, function( event )
if not WorldGen.onChunkGenerated(event) then return end
Surface.onChunkGenerated(event)
end )
script.on_event( Surface.on_city_generated, function( event )
if not Surface.onCityGenerated( event ) then return end
Teleporter.onCityGenerated( event )
Silo.onCityGenerated( event )
end )
script.on_event( defines.events.on_chunk_charted, Surface.onChunkCharted )
script.on_event( Surface.on_city_charted, function( event )
if not Surface.onCityCharted( event ) then return end
Teleporter.onCityCharted( event )
Silo.onCityCharted( event )
end )
-------------------------------------------------------------------------------
script.on_event( defines.events.on_gui_opened, TeleporterGUI.onGuiOpened )
-------------------------------------------------------------------------------
script.on_event( defines.events.on_gui_closed, TeleporterGUI.onGuiClosed )
-------------------------------------------------------------------------------
---Return any truthy value from these events to stop processing the next event
script.on_event( defines.events.on_gui_click, function( event )
if TeleporterGUI.onGuiClick( event ) then return end
if StatsGUI.onGuiClick( event ) then return end
end )
-------------------------------------------------------------------------------
script.on_nth_tick( 60, TeleporterGUI.onNthTick ) -- doesn't seem to work on multiplayer
-------------------------------------------------------------------------------
script.on_event( defines.events.on_player_created, function( event )
Player.onPlayerCreated( event )
Teleporter.onPlayerCreated( event )
StatsGUI.onPlayerCreated( event )
end )
-------------------------------------------------------------------------------
script.on_event( defines.events.on_research_finished, Silo.onResearchFinished )
script.on_event( defines.events.on_rocket_launched, Silo.onRocketLaunched )
if Utils.getStartupSetting( "coe_dev_mode" ) then
script.on_event( "coe-reload-mods", Utils.reload_mods )
script.on_event( "coe-run-function", run_test_function )
end