Originally Posted by Baertram
Code:
--- @param timestamp integer53
--- @return year integer, month integer, day integer
function GetDateElementsFromTimestamp(timestamp) end
Rough example
Lua Code:
local oldYear, oldMonth, oldDay = GetDateElementsFromTimestamp(timeStampFromSavedVariables) local year, month, day = GetDateElementsFromTimestamp(GetTimeStamp()) if year == oldYear and month == oldMonth then if day ~= oldDay then --changed end else if year ~= oldYear or month ~= oldMonth or day ~= oldDay then --changed end end
Add event_add_on_loaded you need to save the current timestamp to your SavedVariables then.
Remember that event is called each time for all addons so only update if YOUR addon is found, and also remember that event is called on each reloadui too!
So only update once per same year, month and day e.g. or you will overwrite it on each reloadui/login with current date.
Your check "old vs. current" needs to be done before updating the SavedVariables too or you will always comapre current with current.
|
Thank you for all the help you've been giving me.