1. #1
    Deleted

    ToggleSpellBook causes Lua errors in Combat!

    Hi, I am using buttons with scripts like "ToggleSpellBook("spell") to toggle Blizzard Frames but this cannot be used in Combat because it causes crazy Lua errors due to Taint of my code being linked to Blizzards own functions. I am not sure if there is a safe way of toggling a spell book in combat. Does anyone know anything about this or has had a similar issue in the past?

    Thanks!

    I could block the button from working in combat but seems a shame when the keybind for opening the spell book can be used in combat which would make the button a lot less useful.

    - - - Updated - - -

    Also "/run ToggleFrame(SpellBookFrame)" or in a Lua file does not work while in Combat either unless the frame has been previously opened before a reload of the UI :/

    - - - Updated - - -

    Fixed the problem, the only way I could find out how to do it was to include:
    ToggleFrame(SpellBookFrame)
    ToggleFrame(SpellBookFrame)

    In a PLAYER_ENTERING_WORLD event, probably not the best solution as I am worried what would happen if I reloaded the UI while in combat..

  2. #2
    Why would you use a script command to open your spellbook? o,o
    Simmons: There's no "I" in "team".
    Griff: There's no "U" in "team" either. so if "U" and "I" aren't in the team, who gives a f_ _ k about the team?
    "Gotta' trust some one to be betrayed. I never did." - Captain Price
    Bungie Has My Studio Of The Decade Vote. "Hours Played" is greater than "Money Made".

  3. #3
    If you use the taintlog you will see something like this, when trying what you want to do:

    Code:
    RunScript()
    An action was blocked in combat because of taint from MACRO_TAINT - SpellBookFrame:SetAttribute()
    Interface\FrameXML\UIParent.lua:67 GetUIPanelWindowInfo()
    Interface\FrameXML\UIParent.lua:2278 ShowUIPanel()
    Interface\FrameXML\UIParent.lua:2270 ToggleFrame()
    ToggleFrame(SpellBookFrame):1
    RunScript()
    Interface\FrameXML\ChatFrame.lua:2036 ?()
    Interface\FrameXML\ChatFrame.lua:4315 ChatEdit_ParseText()
    Interface\FrameXML\ChatFrame.lua:3969 ChatEdit_SendText()
    Interface\FrameXML\ChatFrame.lua:4008 ChatEdit_OnEnterPressed()
    ChatFrame1EditBox:OnEnterPressed()
    So ToggleFrame(SpellBookFrame) at some point calls the SetAttribute function, which is protected during combat (this means it requires a hardware event), hence the spreading taint. The only workaround for using it in combat is the SecureActionButtonTemplate in lua or the equivalent in a macro:

    Code:
    /click SpellbookMicroButton

    If you are okay with it loading after combat you can just check with InCombatLockdown() and/or listen to the "PLAYER_REGEN_ENABLED" event.
    Last edited by Crudor; 2014-09-20 at 11:21 AM.

  4. #4
    Deleted
    Quote Originally Posted by Crudor View Post
    So ToggleFrame(SpellBookFrame) at some point calls the SetAttribute function, which is protected during combat (this means it requires a hardware event), hence the spreading taint.
    Not true. You're confusing a h-req function (can only be called in the direct execution chain in response to a hardware event) and a protected function (can only be called from secure (= Blizzard-signed)) code.

  5. #5
    Quote Originally Posted by Treeston View Post
    Not true. You're confusing a h-req function (can only be called in the direct execution chain in response to a hardware event) and a protected function (can only be called from secure (= Blizzard-signed)) code.
    In my understanding there is no real difference between those two. All protected functions taint the environment. Some functions when called during combat, some function when not called from a hardware event, some functions always. Or is there a deeper distinction between "h-req" and "protected"?

  6. #6
    Deleted
    You can call a h-req from insecure code at any time, as long as it is called in the direct execution chain of a hardware event (originating from onclick/onkeydown/onkeyup etc).
    You can't call a protected function from insecure code. Doing so will throw an error.

    "Tainting" is a side effect of how the Lua engine determines whether code is "secure". Code is considered insecure ("tainted") if it is called from insecure code or reads variables/return values that are insecure (note: except if the values are returned from securecall).
    Any variable modified by insecure code will also become insecure.

    "Tainting" generally refers to a function call to a FrameXML function or modification of a global variable from insecure code modifying some table or variable - thus "tainting" them, e.g. making them insecure - causing all later calls to that function (or other code using that variable) to make the execution path insecure, causing issues in Blizzard code that relies on using secure functions (thus needing to execution to be secure).



    The issue here, however, is simpler. SpellBookFrame:SetAttribute() is called from secure code in the implementation of the spellbook toggle function - however, if said spellbook toggle function itself is invoked from insecure code, the execution is still considered to be insecure, so the call to :SetAttribute (which changes from a standard function to a secure function in combat lockdown) fails with the error you posted.

    /click is special in that it its slash command handler is secure code and it is invoked from secure code (chat frame handlers), so its execution path is secure and can call :Click() on a frame without the OnClick handler being insecure (meaning the call to SetAttribute won't fail in combat).
    Last edited by mmocba105e19de; 2014-09-20 at 07:01 PM.

  7. #7
    Deleted
    Quote Originally Posted by Arkuri View Post
    Why would you use a script command to open your spellbook? o,o
    I am creating an AddOn to allow a user to click a bottom to toggle any frame they want and one of the options is to toggle the spell book. I've seen many other AddOns provide short cut buttons to open Blizzard Frames, it's not that strange ^^

    Thanks guys!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •