-
Notifications
You must be signed in to change notification settings - Fork 13
/
control.lua
68 lines (53 loc) · 1.64 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
require "libs.all"
require "constants"
require "libs.control.entities"
require "control.incinerators"
require "control.migration_0_4_1"
local railloader = require "interfaces.railloader"
-- global data used:
-- hardCrafting.version = $version
-- hardCrafting.incinerators = { $incinerator:LuaEntity, ... }
-- hardCrafting.eincinerators = { $incinerator:LuaEntity, ... }
-- Init --
script.on_init(function()
init()
end)
script.on_load(function()
railloader.AddBulkItems()
end)
script.on_configuration_changed(function()
local hc = global.hardCrafting
local previousVersion = hc.version
if hc.version < "0.4.1" then migration_0_4_1() end
if hc.version ~= previousVersion then
info("Previous global data version: "..previousVersion)
info("Migrated to version "..hc.version)
end
railloader.AddBulkItems()
end)
function init()
if not global.hardCrafting then global.hardCrafting = {} end
local hc = global.hardCrafting
if not hc.version then hc.version = modVersion end
if hc.incinerators == nil then hc.incinerators = {} end
if hc.eincinerators == nil then hc.eincinerators = {} end
entities_init()
info("global after init: "..serpent.block(global))
railloader.AddBulkItems()
end
script.on_event(defines.events.on_tick, function(event)
updateIncinerators()
entities_tick()
end)
---------------------------------------------------
-- Building Entities
---------------------------------------------------
script.on_event(defines.events.on_built_entity, function(event)
entityBuilt(event)
end)
script.on_event(defines.events.on_robot_built_entity, function(event)
entityBuilt(event)
end)
function entityBuilt(event)
entities_build(event)
end