View Single Post
04/26/24, 09:05 AM   #3
VessVelendas
Join Date: Apr 2024
Posts: 5
Originally Posted by Baertram View Post
Code:
--- @param timestamp integer53
--- @return year integer, month integer, day integer
function GetDateElementsFromTimestamp(timestamp) end

Rough example
Lua Code:
  1. local oldYear, oldMonth, oldDay = GetDateElementsFromTimestamp(timeStampFromSavedVariables)
  2. local year, month, day = GetDateElementsFromTimestamp(GetTimeStamp())
  3. if year == oldYear and month == oldMonth then
  4.   if day ~= oldDay then
  5.      --changed
  6.   end
  7. else
  8.   if year ~= oldYear or month ~= oldMonth or day ~= oldDay then
  9.     --changed
  10.   end
  11. 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.
  Reply With Quote