Change to uuid system

This commit is contained in:
Cooldude2606
2018-10-14 20:05:58 +01:00
parent 9af7e14305
commit b221108f07

View File

@@ -21,6 +21,7 @@ local module_verbose = false --true|false
-- @field named a name index for thread uuids -- @field named a name index for thread uuids
-- @field print_to contains players that event details will be printed to -- @field print_to contains players that event details will be printed to
-- @field uuid contains the random number generator for the uuid system -- @field uuid contains the random number generator for the uuid system
local pre_load_uuid = 0
local global = global{ local global = global{
all={_n=0}, all={_n=0},
queue={}, queue={},
@@ -38,12 +39,20 @@ local global = global{
-- @treturn string the new uuid -- @treturn string the new uuid
Server.uuid = add_metatable({},function() Server.uuid = add_metatable({},function()
-- when it is called as a function -- when it is called as a function
global.uuid=global.uuid+1 local uuid = 0
verbose('UUID Created: '..global.uuid) if game then
return global.uuid global.uuid=global.uuid+1
uuid=global.uuid+pre_load_uuid
verbose('Game UUID Increased: '..uuid)
else
pre_load_uuid=pre_load_uuid+1
uuid=pre_load_uuid
verbose('Load UUID Increased: '..uuid)
end
return add_metatable({uuid},nil,function(tbl) return string.to_hex(tostring(tbl[1])) end)
end,function() end,function()
-- when it is treated as a string -- when it is treated as a string
return string.to_hex(tostring(Server.uuid())) return tostring(Server.uuid())
end) end)
--- Redirect to the thread index --- Redirect to the thread index