1. #1

    Slash commands with WA

    i'am out of ideas why slash commands don't work for me in Weak Auras...

    let's take simple example:
    PHP Code:
    SLASH_ZTN1="/ztn"
    SLASH_ZTN2="/ztnko"
        
    SlashCmdList["ZTN"]=function(msg)
        
    local id,text=msg:match("(%S+)%s+(.+)")
        if 
    id and text then
            
    print(id.." "..text)
        
    end
    end 
    this code works if it's in standalone addon. it works even from macros
    Code:
    /run SLASH_ZTN1="/ztn" SLASH_ZTN2="/ztnko" SlashCmdList["ZTN"]=function(msg) id,text=msg:match("(%S+)%s+(.+)") if id and text then print(id.." "..text) end end
    but i can't achieve any results from WA. it dont show any errors and it even register my function in SlashCmdList table because i receive valid results when /run print(SlashCmdList["ZTN"]) instead of nil.

    Please, any ideas what i do wrong?

  2. #2
    Since you need to set a truly global value for SLASH_prefix1, you need to make use of setglobal.

    So in short, you need to make these calls


    SlashCmdList.SOME_FUNCTION = function(msg) ... end

    setglobal("SOME_FUNCTION1", "/sf")


    And that should give you access to your /sf command from outside of the WA environment.

    edit for clarification on the first part: Setting a global variable from within WA will not make it "truly global." The value will be stored in a _G table from within WA's environment, so it can't be accessed outside of WA's. setglobal circumvents this, and allows a variable to be accessed both in and out of WA's environment.

  3. #3
    thank you! it's working!

Posting Permissions

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