'wait()' for Elder Scrolls Online?
How would I prevent a while loop from crashing the client?
|
I broke my gigantic loops into smaller pieces and then called them at intervals like this:
EVENT_MANAGER:RegisterForUpdate(addon.name, milliseconds, function() loop() end) |
You get an (infinite) loop : You break the loop. 99.9% of loops crashing the client are bad codes and can be avoided by refactoring it, no need wait(), pause() or other sleep() you may know. |
Quote:
And he is not talking about infinite loop, but huge loop. |
ESO can at least handle a loop of 500,000 iterations without being noticed by users if there's no output.. I know it, I did it.
I'd like to see the kind of loop requiring a pause in order to do this without the complaints of users having so many addons and after months of investigation by the author.. Here we have : Quote:
It can be nothing and anything, and for me the best answer to "how to prevent a while loop from crashing the client" asked by a newbie is "BETTER CODING" , not Lua Code:
It's disclose bad practices. It's like when your grand'ma ask how to change a registry setting when she just bought Win10. The answer should be adapted. So Yes, the first answer can be accepted, but it's not (for my point of view) the best to give. Quote:
control:RegisterForUpdate and zo_callLater can be interesting but in the long list of things a addon author should use when writing their first addon .. they comes at the very end. |
In some cases when I have an infinite loop (somehow) that shouldn't be there I"ll add a counter and break it if the counter is too high. That's just for debugging purposes though, and once I figure it out I remove it.
|
Lua Code:
There's a lot more problems than just wait() here, and I'm still figuring out the differences between ESO's Lua and the implementation of Lua I know. |
Because there are events for entering and exiting combat. So trying to tie up the thread with sleeping is a bad idea.
|
there is no os library, and please use the BBCode to help .. you don't need to end your lines with ";" .. creating GUI should be done in XML not lua
When you don't know how to do.. a good thing is to look at others does. |
Hi BrizonTG.
Did you read the getting started guide or followed any of the tutorials we have on our wiki? They should clear up some of your questions. As for differences between ESO Lua and "normal" Lua, ESO uses a variation of Lua5.1 with only math, string and table + global functions + zos api available. |
All times are GMT -6. The time now is 07:27 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI