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

46 lines
637 B
Lua
Raw Normal View History

2018-04-07 01:24:30 +02:00
local Token = {}
2018-04-06 23:51:17 +02:00
local tokens = {}
2018-05-20 17:28:54 +02:00
local counter = 0
2018-04-06 23:51:17 +02:00
function Token.register(var)
2018-05-20 17:28:54 +02:00
counter = counter + 1
2018-04-06 23:51:17 +02:00
2018-05-20 17:28:54 +02:00
tokens[counter] = var
2018-04-06 23:51:17 +02:00
2018-05-20 17:28:54 +02:00
return counter
2018-04-06 23:51:17 +02:00
end
function Token.get(token_id)
return tokens[token_id]
end
2018-05-16 12:37:22 +02: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-06-17 12:39:55 +02:00
function Token.set_global(token_id, var)
global.tokens[token_id] = var
end
2018-05-20 17:28:54 +02:00
local uid_counter = 0
function Token.uid()
uid_counter = uid_counter + 1
return uid_counter
end
return Token