Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/thoda-dev/DualUniverse. DualUniverse scripts
Something went wrong. Try again.
1.8 kB · 71 lines
Lua
at v2.x-archive
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172--[[ Remove duplicate elements in a lua table By Jericho]]function removeDuplicatesInTable(data) local hash = {} local res = {} for _,v in ipairs(data) do if (not hash[v]) then res[#res+1] = v hash[v] = true end end return resend
--[[ split a string on a delimiter By jericho]]function strSplit(s, delimiter) result = {}; for match in (s..delimiter):gmatch("(.-)"..delimiter) do table.insert(result, match); end return result;end
--[[ Convert timestamp in a string representing a dureation in days, hours, minutes and seconds By Jericho]]function SecondsToClockString(seconds) local seconds = tonumber(seconds)
if seconds == nil or seconds <= 0 then return "-"; else days = string.format("%2.f", math.floor(seconds/(3600*24))); hours = string.format("%2.f", math.floor(seconds/3600 - (days*24))); mins = string.format("%2.f", math.floor(seconds/60 - (hours*60) - (days*24*60))); secs = string.format("%2.f", math.floor(seconds - hours*3600 - (days*24*60*60) - mins *60)); str = "" if tonumber(days) > 0 then str = str .. days.."d " end if tonumber(hours) > 0 then str = str .. hours.."h " end if tonumber(mins) > 0 then str = str .. mins.."m " end if tonumber(secs) > 0 then str = str .. secs .."s" end return str endend
--[[ remove the quality if exist in a string]]function removeQualityInName(name) if not name then return '' end return name:lower():gsub('basic ', ''):gsub('uncommon ', ''):gsub('advanced ', ''):gsub('rare ', ''):gsub('exotic ', '')end
--[[ check if a value exist in a table]]function has_value (tab, val) for index, value in ipairs(tab) do if value == val then return true end end
return falseend