Avoiding Lua Errors by any price? menu

User Tag List

Results 1 to 6 of 6
  1. #1
    Corthezz's Avatar Elite User Authenticator enabled
    Reputation
    386
    Join Date
    Nov 2011
    Posts
    325
    Thanks G/R
    191/98
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Avoiding Lua Errors by any price?

    Hello,
    right now I am working with 1.12.1. To archiev certain things I am using Framescript_Execute aswell Framescript_GetText.
    When I was thinking about different steps I could take to optimize my code the following Idea came into my mind:

    Lets say my bot is executing a Lua statement with Framescript_Execute and the client disconnects at the same time.
    In this case WoW will most likely throw some Lua errors cause of function which are nil or better said not avaible while disconnected.

    Should I try to avoid such situations by adding some code to prevent execution if not logged in with a character or is it useless effort which wont get me any benefit?
    Code:
    if WorldFrame ~= nil then .... end

    Avoiding Lua Errors by any price?
  2. #2
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like for every other race condition, this would not be sufficient. WoW could always exit while you are within that if block.
    I'd say you should try wrapping it with pcall, but that wouldn't make it any better for the same reason...

    Edit: All of the above of course under the assumption that you are calling lua from another thread... If you are running lua from the main thread, both ways might be valid.

  3. #3
    Corthezz's Avatar Elite User Authenticator enabled
    Reputation
    386
    Join Date
    Nov 2011
    Posts
    325
    Thanks G/R
    191/98
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    Like for every other race condition, this would not be sufficient. WoW could always exit while you are within that if block.
    I'd say you should try wrapping it with pcall, but that wouldn't make it any better for the same reason...

    Edit: All of the above of course under the assumption that you are calling lua from another thread... If you are running lua from the main thread, both ways might be valid.
    Yep I am running Lua from the endscene but thats not my point.
    Are a few lua errors affecting anything?
    Last edited by Corthezz; 07-07-2013 at 11:26 AM.

  4. #4
    ck298's Avatar Private
    Reputation
    1
    Join Date
    Jul 2013
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    Like for every other race condition, this would not be sufficient. WoW could always exit while you are within that if block.
    I'd say you should try wrapping it with pcall, but that wouldn't make it any better for the same reason...

    Edit: All of the above of course under the assumption that you are calling lua from another thread... If you are running lua from the main thread, both ways might be valid.
    i got main thread TEB->TLS,but there is not CurMgr.
    if i will call lua from dll thread than still need update main threads TLS to dll thread?

  5. #5
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Corthezz View Post
    Yep I am running Lua from the endscene but thats not my point.
    Are a few lua errors affecting anything?
    Can't say that, but if you wrap your stuff in a pcall, then no lua error will escape. IMO more elegant than littering your code with if-checks.

    Originally Posted by ck298 View Post
    i got main thread TEB->TLS,but there is not CurMgr.
    if i will call lua from dll thread than still need update main threads TLS to dll thread?
    I'm generally doing my stuff from the main thread, so I'm not sure about this.
    At least the ObjMgr address isn't saved in TLS anymore nowadays. They are using a regular global.
    Ahh wait, this is 1.12, so they probably use TLS. In that case you have to copy the environment into your thread, but I really advise you to call lua only from the main thread for race (condition) reasons.

  6. #6
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Corthezz View Post
    Yep I am running Lua from the endscene but thats not my point.
    Are a few lua errors affecting anything?

    No. FrameScript_Execute uses lua_pcall to execute the buffer.
    You might have to pop the error message off the lua stack but I am pretty sure FrameScript_Execute does that for you, you might want to check the disassembly.
    Hey, it compiles! Ship it!

Similar Threads

  1. LUA error
    By mager1794 in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 05-23-2008, 07:17 PM
  2. LUA Error.
    By controlsx2 in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 05-07-2008, 04:31 PM
  3. Custom Lua`s (Post all your custom lua`s of any kind bosses anything)
    By Chrispee in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 04-16-2008, 11:43 AM
  4. [Lua] Error
    By ~ViVo~ in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 03-15-2008, 11:15 AM
  5. [Errorz] A Lua Error I Havent seen before
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 02-14-2008, 10:12 AM
All times are GMT -5. The time now is 06:59 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search