···11+--[[
22+ Remove duplicate elements in a lua table
33+ By Jericho
44+]]
55+function removeDuplicatesInTable(data)
66+ local hash = {}
77+ local res = {}
88+ for _,v in ipairs(data) do
99+ if (not hash[v]) then
1010+ res[#res+1] = v
1111+ hash[v] = true
1212+ end
1313+ end
1414+ return res
1515+end
1616+1717+--[[
1818+ split a string on a delimiter
1919+ By jericho
2020+]]
2121+function strSplit(s, delimiter)
2222+ result = {};
2323+ for match in (s..delimiter):gmatch("(.-)"..delimiter) do
2424+ table.insert(result, match);
2525+ end
2626+ return result;
2727+end
2828+2929+--[[
3030+ Convert timestamp in a string representing a dureation in days, hours, minutes and seconds
3131+ By Jericho
3232+]]
3333+function SecondsToClockString(seconds)
3434+ local seconds = tonumber(seconds)
3535+3636+ if seconds == nil or seconds <= 0 then
3737+ return "-";
3838+ else
3939+ days = string.format("%2.f", math.floor(seconds/(3600*24)));
4040+ hours = string.format("%2.f", math.floor(seconds/3600 - (days*24)));
4141+ mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60)));
4242+ secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60));
4343+ str = ""
4444+ if tonumber(days) > 0 then str = str .. days.."d " end
4545+ if tonumber(hours) > 0 then str = str .. hours.."h " end
4646+ if tonumber(mins) > 0 then str = str .. mins.."m " end
4747+ if tonumber(secs) > 0 then str = str .. secs .."s" end
4848+ return str
4949+ end
5050+end
5151+5252+--[[
5353+ remove the quality if exist in a string
5454+]]
5555+function removeQualityInName(name)
5656+ if not name then return '' end
5757+ return name:lower():gsub('basic ', ''):gsub('uncommon ', ''):gsub('advanced ', ''):gsub('rare ', ''):gsub('exotic ', '')
5858+end
5959+6060+--[[
6161+ check if a value exist in a table
6262+]]
6363+function has_value (tab, val)
6464+ for index, value in ipairs(tab) do
6565+ if value == val then
6666+ return true
6767+ end
6868+ end
6969+7070+ return false
7171+end