WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Why ReloadUI() method causes mistake (https://www.wowinterface.com/forums/showthread.php?t=57905)

blocker147 04-02-20 08:46 AM

Why ReloadUI() method causes mistake
 
1 Attachment(s)
I'm trying to call ReloadUI() method after one minute. This is code I'm using.
Code:

local isEnd = false

local f = CreateFrame("Frame")
function f:onUpdate(sinceLastUpdate)
  if isEnd then
      print("END")
      f:SetScript("OnUpdate",nil)
      ReloadUI()
  end
 
  self.sinceLastUpdate = (self.sinceLastUpdate or 0) + sinceLastUpdate
  if ( self.sinceLastUpdate >= 60 ) then -- in seconds
      -- do stuff here
      print("MSG")
      self.sinceLastUpdate = 0
      isEnd = true
  end
end
f:SetScript("OnUpdate",f.onUpdate)

When the minute passes I get an error:
Attachment 9433
How to fix this? Or any ideas how to make one minute delay?
I found other function on https://wowwiki.fandom.com/wiki/USERAPI_wait
Code:

<PREFIX>_wait(delay, func [, param [,param [,...]]])
But I don't understand how to use it. What is <PREFIX>? And code example on same link not working.

Fizzlemizz 04-02-20 08:50 AM

ReloadUI is protected and requires a hardware event (button/keyboard press) so it can't be run from a timer.

blocker147 04-02-20 09:35 AM

Quote:

Originally Posted by Fizzlemizz (Post 335523)
ReloadUI is protected and requires a hardware event (button/keyboard press) so it can't be run from a timer.

So any ideas how to make delay and then reloadui?
I also tried to use with mybtn:Click() method where OnClick method has reloadui().
But this did not work.


But i can call it like this:
a = true
if a then
ReloadUI()
end
and this works.

Fizzlemizz 04-02-20 09:42 AM

Calling an OnClick script from a timer is not the same as physically pressing a button.

Your timer could show a hidden button that the user then presses in order to run ReloadUI().

blocker147 04-02-20 09:53 AM

It means there is no way to create auto reloadui after delay?

Fizzlemizz 04-02-20 09:58 AM

Specially around April 1 ;)

blocker147 04-02-20 10:23 AM

a ? now I absolutely don't understand anything. It's real or not? This is not funny man. :confused:

Fizzlemizz 04-02-20 10:26 AM

Blizzard don't want addons reloading the UI unless the user OKs it by clicking a mouse or keyboard button.

I was using April 1 as an example where programmatically reloading the UI might be misused.

blocker147 04-02-20 10:34 AM

I want to update SavedVariables file. Which is updated only when player logouts or reloads ui.
So is it possible to make Logout() and then Login() automatically with addons only.

blocker147 04-02-20 10:54 AM

Quote:

Fizzlemizz
Anyway thank for response !

Ketho 04-02-20 11:02 AM

Quote:

Originally Posted by blocker147 (Post 335531)
So is it possible to make Logout() and then Login() automatically with addons only.


No, not legally

Seerah 04-02-20 11:28 AM

No, as Fizzlemizz says, give them a button to press. You want your users to be ready for the UI to reload anyway.


All times are GMT -6. The time now is 03:30 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI