Quantcast Why ReloadUI() method causes mistake - WoWInterface
Thread Tools Display Modes
04-02-20, 08:46 AM   #1
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 11
Why ReloadUI() method causes mistake

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:
Click image for larger version

Name:	error.png
Views:	182
Size:	35.7 KB
ID:	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.
  Reply With Quote
04-02-20, 08:50 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,203
ReloadUI is protected and requires a hardware event (button/keyboard press) so it can't be run from a timer.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-02-20 at 08:52 AM.
  Reply With Quote
04-02-20, 09:35 AM   #3
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 11
Originally Posted by Fizzlemizz View Post
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.

Last edited by blocker147 : 04-02-20 at 09:38 AM.
  Reply With Quote
04-02-20, 09:42 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,203
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().
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
04-02-20, 09:53 AM   #5
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 11
It means there is no way to create auto reloadui after delay?
  Reply With Quote
04-02-20, 09:58 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,203
Specially around April 1
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
04-02-20, 10:23 AM   #7
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 11
a ? now I absolutely don't understand anything. It's real or not? This is not funny man.
  Reply With Quote
04-02-20, 10:26 AM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,203
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
04-02-20, 10:34 AM   #9
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 11
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.
  Reply With Quote
04-02-20, 10:54 AM   #10
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 11
Fizzlemizz
Anyway thank for response !
  Reply With Quote
04-02-20, 11:02 AM   #11
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 915
Originally Posted by blocker147 View Post
So is it possible to make Logout() and then Login() automatically with addons only.

No, not legally
  Reply With Quote
04-02-20, 11:28 AM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,721
No, as Fizzlemizz says, give them a button to press. You want your users to be ready for the UI to reload anyway.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Why ReloadUI() method causes mistake

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off