Loop freezes game on load
Im trying to make a simple addon that switches the action bar if a player has certain spells learned. Dont ask
Without a loop, it works fine, upon reloading the bar switches successfully, but with the loop the game becomes unresponsive upon load I look up the 'OnUpdate' event but it says I need a frame to update and bunch of other things, the code I've tried doesnt work and is just too excessive for my needs Would appreciate a point in the right direction Code:
local looping = true, a, b, c, d |
Any time a, b, c, or d is not true you'll enter an infinite loop causing the crash
|
Thats the point, it should loop till the player learns the spells
|
Ya, but you're in an infinite loop if they don't, so literally if there's like a millisecond where that function runs and it's not true, you'll enter an infinite loop you can't get out of because you can't "learn" a spell while the while loop is running
|
You're better off writing an OnUpdate function that runs until they're learned. That may not be optimal, because you haven't posted all of your code, just some random snippet out of context
|
To clarify, WoW addon code is loaded sequentially and an infinite loop would halt it.
Using an event like LEARNED_SPELL_IN_TAB may help as it fires when a new spell is added/learned. Lua Code:
|
Or Check for the spells (once) when you first login and then use an event like LEARNED_SPELL_IN_TAB to check again only when you learn something new.
What you are doing is telling your computer to run as hard and fast as it can until all conditions are met, so that's all it can do. Edit: like jeruku said :) |
I was hoping itd get offloaded to another thread instead of stalling the engine :/ thanks for the info, very much appreciate the suggestions
|
Lua is singlethreaded. This is a limitation of Lua itself and will never change. The rest of WoW may have recently been updated to multithreaded, but the UI will freeze if any for or while loops have an infinite state.
|
All times are GMT -6. The time now is 09:44 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI