1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/utils/global.lua

34 lines
629 B
Lua
Raw Normal View History

local Event = require 'utils.event_core'
2018-11-26 03:07:03 +02:00
local Token = require 'utils.token'
2018-06-09 12:43:37 +02:00
2018-07-04 17:22:26 +02:00
local Global = {}
2018-06-09 12:43:37 +02:00
function Global.register(tbl, callback)
local token = Token.register_global(tbl)
Event.on_load(
function()
callback(Token.get_global(token))
end
)
2018-06-17 12:39:55 +02:00
end
function Global.register_init(tbl, init_handler, callback)
local token = Token.register_global(tbl)
2018-06-09 12:43:37 +02:00
Event.on_init(
function()
init_handler(tbl)
callback(tbl)
2018-06-17 12:39:55 +02:00
end
)
2018-06-17 12:39:55 +02:00
Event.on_load(
function()
callback(Token.get_global(token))
2018-06-09 12:43:37 +02:00
end
)
end
2018-06-09 12:43:37 +02:00
return Global