View Single Post
04/14/14, 08:07 AM   #14
Tyx
 
Tyx's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
I didn't test it but I think it has something to do with the time (OS Time) which is at the top left corner if you open your map.

EDIT1: I created a little AddOn on base of a DB where you can put a example time to calc the in-game time from there.
Like I see the sun setting and use the command /cl sunset to save the time.
Because we know that a day is 6h long (2h night 4h day) - I hope this is right^^ - it will now set the midnight 1h, the sunrise 2h and noon 4h later (and all of that 4x because 6*4 = 24 )

But it has one big problem if the day-night cycle isn't 6h long xD
And an other small one because I get an Error right after the login.
Lua Code:
  1. local mid_h = settings.gameTime["midnight"]["h"] --[[ <-- ERROR ATTEMPED
  2.             user:/AddOns/Clock/Clock.lua:135: attempt to index a nil value stack traceback:
  3.             user:/AddOns/Clock/Clock.lua:135: in function 'GetInGameTime'
  4.             user:/AddOns/Clock/Clock.lua:199: in function 'PrintClock'
  5.             18135679543117558641:3: in function '(main chunk)' ]]

Lua Code:
  1. -------------------------------------------
  2. --                Start
  3. -------------------------------------------
  4. local function Clock_OnLoaded(eventCode, addOnName)
  5.     if(addOnName ~= "Clock") then
  6.         return
  7.     end
  8.     settings = ZO_SavedVars:NewAccountWide("Clock_Settings", 0.1, "settings", defaults)
  9.     -- Commands
  10.     -- Register
  11.     -- Unregister
  12. end
  13. ------------------
  14. --   Init
  15. ------------------
  16. local function Clock_Init()
  17.     EVENT_MANAGER:RegisterForEvent("Clock", EVENT_ADD_ON_LOADED, Clock_OnLoaded)
  18. end
  19.  
  20. Clock_Init()

I use the xml OnUpdate function to call my function PrintClock(). I think it is called before the settings are loaded/saved and so it only gets a nil value...

EDIT2: I fixed it (and a lot more) by giving the local settings not the = nil value but the defaults (with the database). So the first few times hte OnUpdate asks for a value it gets the default values back until the user values are loaded.

BTW: http://www.esoui.com/downloads/info2...ndartTime.html my AddOn is online

Last edited by Tyx : 04/14/14 at 04:57 PM.
  Reply With Quote