Module:GameData: Difference between revisions

Update code
(Implement p.skillData as an easy way to reference skill data by local ID/skill name)
(Update code)
Line 67: Line 67:
-- Sets the cache for entity ID within the given entity type to idx.
-- Sets the cache for entity ID within the given entity type to idx.
local function setCache(entityType, ID, idx)
local function setCache(entityType, ID, idx)
if type(entityType) == 'string' and type(ID) == 'string' and type(idx) == 'number' and idx == math.floor(idx) then
if type(entityType) == 'string' and type(ID) == 'string' and type(idx) == 'number' then
if indexCache[entityType] == nil then
if indexCache[entityType] == nil then
indexCache[entityType] = {}
indexCache[entityType] = {}
end
end
if indexCache[entityType][ID] == nil then
if indexCache[entityType][ID] == nil then
indexCache[entityType][ID] = idx
indexCache[entityType][ID] = math.floor(idx)
end
end
end
end