-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dofile(DATA_DIRECTORY .. '/lib/core/storages.lua') | ||
dofile(DATA_DIRECTORY .. '/lib/core/storagesCustom.lua') | ||
dofile(DATA_DIRECTORY .. '/lib/core/quests.lua') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
StorageCustom = { | ||
testing = 90000, | ||
} | ||
|
||
-- Values extraction function | ||
local function extractValues(tab, ret) | ||
if type(tab) == "number" then | ||
table.insert(ret, tab) | ||
else | ||
for _, v in pairs(tab) do | ||
extractValues(v, ret) | ||
end | ||
end | ||
end | ||
|
||
local extraction = {} | ||
extractValues(Storage, extraction) -- Call function | ||
table.sort(extraction) -- Sort the table | ||
-- The choice of sorting is due to the fact that sorting is very cheap O (n log2 (n)) | ||
-- And then we can simply compare one by one the elements finding duplicates in O(n) | ||
|
||
-- Scroll through the extracted table for duplicates | ||
if #extraction > 1 then | ||
for i = 1, #extraction - 1 do | ||
if extraction[i] == extraction[i + 1] then | ||
logger.warn("Duplicate Storage Custom value found: {}", | ||
extraction[i]) | ||
end | ||
end | ||
end |
Binary file not shown.