1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00
RedMew/utils/global_token.lua

42 lines
557 B
Lua
Raw Normal View History

2018-04-07 00:24:30 +01:00
local Token = {}
2018-04-06 22:51:17 +01:00
local tokens = {}
2018-05-20 16:28:54 +01:00
local counter = 0
2018-04-06 22:51:17 +01:00
function Token.register(var)
2018-05-20 16:28:54 +01:00
counter = counter + 1
2018-04-06 22:51:17 +01:00
2018-05-20 16:28:54 +01:00
tokens[counter] = var
2018-04-06 22:51:17 +01:00
2018-05-20 16:28:54 +01:00
return counter
2018-04-06 22:51:17 +01:00
end
function Token.get(token_id)
return tokens[token_id]
end
2018-05-16 11:37:22 +01:00
global.tokens = {}
function Token.register_global(var)
local c = #global.tokens + 1
global.tokens[c] = var
return c
end
function Token.get_global(token_id)
return global.tokens[token_id]
end
2018-05-20 16:28:54 +01:00
local uid_counter = 0
function Token.uid()
uid_counter = uid_counter + 1
return uid_counter
end
return Token