File tree Expand file tree Collapse file tree 7 files changed +15
-23
lines changed
exp_commands/module/commands Expand file tree Collapse file tree 7 files changed +15
-23
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ local Clustorio = require("modules/clusterio/api")
1010
1111local json_to_table = helpers .json_to_table
1212
13+ Commands .add_rcon_static (" Clustorio" , Clustorio )
14+ Commands .add_rcon_static (" ipc" , Clustorio .send_json )
15+
1316Commands .new (" _ipc" , { " exp-commands_ipc.description" })
1417 :argument (" channel" , { " exp-commands_ipc.arg-channel" }, Commands .types .string )
1518 :argument (" message" , { " exp-commands_ipc.arg-message" }, Commands .types .string )
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ System command which runs arbitrary code within a custom (not sandboxed) environ
1111local ExpUtil = require (" modules/exp_util" )
1212local Async = require (" modules/exp_util/async" )
1313local Storage = require (" modules/exp_util/storage" )
14- local Clustorio = require (" modules/clusterio/api" )
1514
1615local Commands = require (" modules/exp_commands" ) --- @class Commands
1716
@@ -26,9 +25,7 @@ setmetatable(rcon_env, { __index = rcon_static })
2625rcon_static .Async = Async
2726rcon_static .ExpUtil = ExpUtil
2827rcon_static .Commands = Commands
29- rcon_static .Clustorio = Clustorio
3028rcon_static .print = Commands .print
31- rcon_static .ipc = Clustorio .send_json
3229--- @diagnostic enable : name-style-check
3330
3431--- Some common callback values which are useful when a player uses the command
Original file line number Diff line number Diff line change @@ -41,6 +41,6 @@ for _, error in ipairs(errors) do log(error) end
4141
4242log (" [END] -----| Explosive Gaming Scenario Loader |-----" )
4343
44- --- Register all event handlers via clusterio
44+ --- Register all event handlers via event handler
4545local Event = require (" modules/exp_legacy/utils/event" )
4646return Event .real_handlers
Original file line number Diff line number Diff line change 1- local Clustorio = require (" modules/clusterio/api" )
21local ExpUtil = require (" modules/exp_util" )
32
43local Event = {
@@ -66,7 +65,8 @@ function Event.on_init(handler)
6665 end
6766
6867 handlers [# handlers + 1 ] = handler
69- Event .add (Clustorio .events .on_server_startup , handler )
68+ Event .add (defines .events .on_singleplayer_init , handler )
69+ Event .add (defines .events .on_multiplayer_init , handler )
7070end
7171
7272function Event .on_load (handler )
Original file line number Diff line number Diff line change @@ -408,13 +408,10 @@ end
408408local e = defines .events
409409local events = {
410410 [e .on_tick ] = on_tick ,
411+ [e .on_singleplayer_init ] = Async .on_init ,
412+ [e .on_multiplayer_init ] = Async .on_init ,
411413}
412414
413- local Clustorio = ExpUtil .optional_require (" modules/clusterio/api" )
414- if Clustorio then
415- events [Clustorio .events .on_server_startup ] = Async .on_init
416- end
417-
418415Async ._function_metatable .__call = Async ._function_prototype .start_soon
419416Async .events = events --- @package
420417return Async
Original file line number Diff line number Diff line change 11-- luacheck:ignore global package
22
3- local Clustorio = require (" modules/clusterio/api" )
4-
53--- Enum values for the different lifecycle stages within a factorio module
64-- Info on the data lifecycle and how we use it: https://lua-api.factorio.com/latest/auxiliary/data-lifecycle.html
75-- We start in control stage and so values 1 thorough 3 are only present for completeness
@@ -25,10 +23,9 @@ return setmetatable({
2523 on_load = function () package .lifecycle = package .lifecycle_stage .load end ,
2624 on_configuration_changed = function () package .lifecycle = package .lifecycle_stage .config_change end ,
2725 events = {
28- -- TODO find a reliable way to set to runtime because currently it will desync if accessed before player joined
29- -- TODO make clusterio optional dependency
3026 [defines .events .on_player_joined_game ] = function () package .lifecycle = package .lifecycle_stage .runtime end ,
31- [Clustorio .events .on_server_startup ] = function () package .lifecycle = package .lifecycle_stage .runtime end ,
27+ [defines .events .on_singleplayer_init ] = function () package .lifecycle = package .lifecycle_stage .runtime end ,
28+ [defines .events .on_multiplayer_init ] = function () package .lifecycle = package .lifecycle_stage .runtime end ,
3229 },
3330}, {
3431 __index = package ,
Original file line number Diff line number Diff line change @@ -119,12 +119,10 @@ function Storage.on_init()
119119 end
120120end
121121
122- local events = {}
123-
124- local Clustorio = ExpUtil .optional_require (" modules/clusterio/api" )
125- if Clustorio then
126- events [Clustorio .events .on_server_startup ] = Storage .on_init
127- end
122+ --- @package
123+ Storage .events = {
124+ [defines .events .on_multiplayer_init ] = Storage .on_init ,
125+ [defines .events .on_singleplayer_init ] = Storage .on_init ,
126+ }
128127
129- Storage .events = events --- @package
130128return Storage
You can’t perform that action at this time.
0 commit comments