--[[ Return the timestamp from today's reset (specifically for craft writs) ]] function LeoAltholic.TodayReset() local diff = zo_floor(GetDiffBetweenTimeStamps(GetTimeStamp(), 1538200800) / 86400) return 1538200800 + (diff * 86400) end --[[ Return if the timestamp is after the today's reset. ]] function LeoAltholic.IsAfterReset(timestamp) return timestamp >= LeoAltholic.TodayReset() end --[[ Return if the timestamp is before the today's reset. ]] function LeoAltholic.IsBeforeReset(timestamp) return timestamp <= LeoAltholic.TodayReset() end --[[ Return if the craft is done for the day for the charName (if not specified, the current character is used) ]] function LeoAltholic.IsWritDoneToday(craft, charName) local char if not charName then char = LeoAltholic.globalData.CharList[LeoAltholic.CharName] end if not char then return end for _, writ in pairs(char.quests.writs) do if craft == writ.craft then return writ.lastDone ~= nil and LeoAltholic.IsAfterReset(writ.lastDone) end end return false end function LeoAltholic.IsWritStartedToday(craft, charName) local char if not charName then char = LeoAltholic.globalData.CharList[LeoAltholic.CharName] end if not char then return end for _, writ in pairs(char.quests.writs) do if craft == writ.craft then return writ.lastStarted ~= nil and LeoAltholic.IsAfterReset(writ.lastStarted) end end return false end function LeoAltholic.HasStillResearchFor(craft, charName) local char if not charName then char = LeoAltholic.globalData.CharList[LeoAltholic.CharName] end for line = 1, GetNumSmithingResearchLines(craft) do local _, _, numTraits = GetSmithingResearchLineInfo(craft, line) for trait = 1, numTraits do if not char.research.done[craft][line][trait] then return true end end end end --[[ Return the number of researching in progress, the total and the time of the first one to be completed (can be 0 or negative, indicating it's done) ]] function LeoAltholic.GetResearchCounters(craft, charName) local char if not charName then char = LeoAltholic.globalData.CharList[LeoAltholic.CharName] end if not char then return end local lowest = -1 if #char.research.doing[craft] > 0 then local research = char.research.doing[craft][1] lowest = research.time end return #char.research.doing[craft], char.research.done[craft].max, lowest end local function copy(obj, seen) if type(obj) ~= 'table' then return obj end if seen and seen[obj] then return seen[obj] end local s = seen or {} local res = setmetatable({}, getmetatable(obj)) s[obj] = res for k, v in pairs(obj) do res[copy(k, s)] = copy(v, s) end return res end --[[ Return a copy of the complete table with all tracked chars. Structure soon. ]] function LeoAltholic.ExportCharacters(forceUpdate) LeoAltholic.GetCharacters(forceUpdate) local chars = copy(LeoAltholic.charList) return chars end --[[ Return all info on 1 char by name ]] function LeoAltholic.GetCharByName(name, forceUpdate) local chars = LeoAltholic.ExportCharacters(forceUpdate) for k, v in pairs(chars) do if v.bio.name == name then return v end end return nil end --[[ Return all info on the current char ]] function LeoAltholic.GetMyself() local myself = copy(LeoAltholic.globalData.CharList[LeoAltholic.CharName]) return myself end --[[ Return if a specific tab is visible ]] function LeoAltholic.IsTabVisible(tab) return LeoAltholic.hidden == false and LeoAltholic.globalData.activeTab == tab end