forked from narc0tiq/FactorioMaps
-
Notifications
You must be signed in to change notification settings - Fork 6
/
control.lua
66 lines (56 loc) · 1.75 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
--Include needed stdlib libs.
require "stdlib/config/config"
require "stdlib/entity/entity"
require "stdlib/event/gui"
require "stdlib/game"
require "stdlib/log/logger"
require 'stdlib/utils/string'
fm = {}
fm.log = Logger.new("FactorioMaps", "debug", true)
require "fm.config"
require "fm.generateIndex"
require "fm.generateMap"
require "fm.gui"
require "fm.helpers"
require "fm.migrations"
require "fm.remote"
require "fm.viewer"
script.on_init(function()
global.config = {}
global.player_data = {}
global._radios = {}
fm.cfg = Config.new( global.config )
fm.config.applyDefaults()
fm.gui.showAllMainButton()
end)
script.on_load(function()
--[[
The damn global table is plain annoying to work with.
modification to the global table from the global scope works but will NOT
saved to the game save file.
Any modifications here causes Factorio to blow up as of 0.13.5
So in conclusion never touch this line.
Gotta catch the migrations properly.
]]--
if global.config then
fm.cfg = Config.new( global.config )
end
end)
script.on_configuration_changed(function (event)
for modName,modTable in pairs(event.mod_changes) do
if modName == "FactorioMaps" and modTable.old_version ~= nil then
fm.migrations.doUpdate(modTable.old_version, modTable.new_version)
end
end
end)
script.on_event(defines.events.on_player_created, function(event)
fm.gui.showMainButton(event.player_index)
end)
script.on_event(defines.events.on_tick, function(event)
fm.gui.updateCoords()
if fm.cfg.get("resetDay") then
if game.tick > fm.cfg.get("resetDayTick") + 3 then
fm.helpers.makeDay(fm.cfg.get("resetDayFor"), true)
end
end
end)