• 0

    posted a message on ElkBuffBars v2 (finally Ace3 version)
    Looks like the infamous FuBarPlugin-2.1 commit bug. Make sure you aren't pulling in r7 of FuBarPlugin-2.0.
    Posted in: General AddOns
  • 0

    posted a message on Tabard Management Addon
    I'm using the following script with Outfitter:
    -- $EVENTS ZONE_CHANGED_NEW_AREA
    -- $DESC Equips the outfit when you are in one of the zones
    -- $SETTING zoneList={Type="ZoneList", Label="Zones"}
    local currentZone = GetZoneText()
    local inInstance, party_or_raid = IsInInstance()
    if inInstance and ("party" == party_or_raid or "raid" == party_or_raid) then
        if setting.zoneList then
            for _, zoneName in ipairs(setting.zoneList) do
                if zoneName == currentZone then
                    equip = true
                    break
                end
            end
        end
        if nil == equip and 2 <= GetInstanceDifficulty() then
            equip = true
        end
    else
        eqiup = false
    end
    
    if didEquip and equip == nil then
        equip = false
    end


    You will need to add the following zones to the zone list i think:
    • Halls of Lightning
    • The Oculus
    Posted in: Addon Ideas
  • 0

    posted a message on AceConfigDialog-3.0 SelectGroup
    This is the simplest test case that demonstrates the error. It doesn't use Locales, metatables, or plugins. All it does is create two blizzard options frames, puts an execute on the first that takes you to the second. After some testing, I think the problem is not SelectGroup (which is working), but rather the InterfaceOptionsFrame_OpenToCategory being called within the execute function and tripping over some internal state.

    local kAddon = "AceConfigDialogTest_ExecuteOpenToCategory"
    local kOptionsPrefix = "ACD: Test"
    
    AceConfigDialogTest_ExecuteOpenToCategory = LibStub("AceAddon-3.0"):NewAddon(kAddon)
    
    local addon = LibStub("AceAddon-3.0"):GetAddon(kAddon)
    
    local function execute_test(info)
            local self = info.handler
            InterfaceOptionsFrame_OpenToCategory(self.optionsFrame2)
            LibStub("AceConfigDialog-3.0"):SelectGroup(kOptionsPrefix .. " Panel 2", "second")
    end
    
    function addon:OnInitialize()
            -- Create options tables
            local AceConfig = LibStub("AceConfig-3.0")
            AceConfig:RegisterOptionsTable(kOptionsPrefix, {
                            type = "group"
                            , handler = self
                            , name = kOptionsPrefix
                            , args = {
                                    test = {
                                            type = "execute"
                                            , name = "Test"
                                            , func = execute_test
                                    }
                            }
                    })
            AceConfig:RegisterOptionsTable(kOptionsPrefix .. " Panel 2", {
                            type = "group"
                            , name = "Panel 2"
                            , childGroups = "select"
                            , args = {
                                    first = {
                                            type = "group"
                                            , name = "First"
                                            , args = {
                                                    hello = {
                                                            type = "description"
                                                            , name = "Hello World!"
                                                    }
                                            }
                                    }, second = {
                                            type = "group"
                                            , name = "Second"
                                            , args = {
                                                    goodbye = {
                                                            type = "description"
                                                            , name = "Goodbye cruel world!"
                                                    }
                                            }
                                    }
                            }
                    })
    
            -- Create blizzard panels
            local AceConfigDialog = LibStub("AceConfigDialog-3.0")
            self.optionsFrame = AceConfigDialog:AddToBlizOptions(kOptionsPrefix, kOptionsPrefix)
            self.optionsFrame2 = AceConfigDialog:AddToBlizOptions(kOptionsPrefix .. " Panel 2", "Panel 2", kOptionsPrefix)
    end


    To test:
    1. Save this text as a file, say Test.lua
    2. Create a simple TOC, add Ace3 as a Required Dependency, and include Test.lua
    3. Put the two files (and optionally LibStub.lua) into an appropriately named addon folder
    4. Start WoW
    5. Open the Interface > Addons menu
    6. Select the "ACD: Test" addon panel
    7. Hit the "Test" button

    At this point you should get the error as was originally posted.
    Posted in: AddOn HELP!
  • 0

    posted a message on OutRunner - Script runner and sharer
    Quote from Arrowmaster
    BAD!

    I'm seriously hopping you mean setfenv(1, g) and not 0, otherwise that's extremely bad and I'm wondering how you haven't noticed it yet (unless I'm not aware and WoW is protecting you from doing what I'm fairly certain that's supposed to do.


    My bad, yes, I meant setfenv(1, g) to replace the current function's environment.

    Either way, it's an example of what-not-to-do-cause-it-is-bad-and-you-don't-want-random-people-doing-that-in-your-client. (And no, WoW doesn't protect against /script setfenv(0, {}).)

    Also I really hope somebody else finds your library useful, otherwise it falls into the useless libraries that never should have been made category because only one addon uses it. And you don't want that if you're going to hang around here.


    Thanks, I was just looking for something else and stumbled upon this thread by accident. The addon in question needed to create script objects, so i created an internal library with the intent to make a meta addon later. For better or worse someone else is creating a meta addon, maybe they can find it useful (and similar functionality already exists in at least one addon, Outfitter).
    Posted in: Lua Code Discussion
  • 0

    posted a message on OutRunner - Script runner and sharer
    Isn't it then a matter of calling one method that resides outside the sandbox?

    Anyway, I'm interested in one such addon for personal developer-aid usage. It'll help me debug my addons quicker.


    I've posted the script library to curseforge. It can be found at http://wow.curseforge.com/projects/lib-user-script/. The library doesn't do anything other than define a New method for creating scripts. ATM it does not support upgrading already created scripts.

    Basically it uses the ideas from Wiki: Protecting the global environment. You can create the sandbox as closed off as you desire from what I understand. From what I can see, you can get out of the sandbox if:
    • Change the current environment
      1. local g = getfenv(<some global function>)
      2. setfenv(0, g)
      3. Have access to getglobal / setglobal
      4. Play tricks with rawget / rawset (not clear on this one)
      5. Play tricks with getmetatable / setmetatable (not clear on this one, either)

      PhotoOp doesn't allow access to those functions for scripts. For taking the actual screen shot, it does provide access to LibStub, which of course can get you anything you want.

      The only thing missing right now is checking for pathological scripts that don't nest properly to avoid being properly defined.
      Posted in: Lua Code Discussion
    • 0

      posted a message on AceConfigDialog-3.0 SelectGroup
      I'm getting the following with when calling
      LibStub("AceConfigDialog-3.0"):SelectGroup("PhotoOp Scripts", "<some option on this panel>")


      [2008/11/18 01:51:35-917-x1]: AceConfigDialog-3.0-25:786: attempt to index field 'rootframe' (a nil value)
      (tail call): ?:
      <in C code>: ?
      <string>:"safecall Dispatcher[2]":9: in function <[string "safecall Dispatcher[2]"]:5>
      (tail call): ?:
      AceGUI-3.0-16 (Ace3):264: in function `Fire'
      Ace3\AceGUI-3.0\widgets\AceGUIWidget-Button.lua:20: in function <...dOns\Ace3\AceGUI-3.0\widgets\AceGUIWidget-Button.lua:19>
      


      The addon in question is PhotoOp.

      Basically I am jumping from one pane in the blizzard addon window to another pane. This works, but somewhere the button gets confused and throws the error. I wasn't able to find an example of this function being used amongst my other Ace3 addons, though it does exactly what I want (aside from the error).

      The action takes place on an "execute" option. I have created several tables with RegisterOptionsTables, one of which is "PhotoOp Scripts", and then created Blizzard options using AddToBlizOptions. The options view in question accepts several fields and then performs an action (type=execute) and on success jumps to another panel and then selects the appropriate sub-option using SelectGroup.

      local function setFrameOption(info, value) info.handler.var.frame[ info.arg[ 1 ] ][ info.arg[ 2 ] ] = value end
      local function getFrameOption(info, ...) return info.handler.var.frame[ info.arg[ 1 ] ][ info.arg[ 2 ] ] end
      local function createNewScript(info)
        local self = info.handler
        -- returns a string describing the failure or else true on success
        -- creates a new script, which (amongst other things)...
        -- updates the "PhotoOp Scripts" table with the new script information
        if type(self:createNewScript(self.var.frame[ info.arg ])) ~= "string" then
          if self.optionsFrame then
            InterfaceOptionsFrame_OpenToCategory(self.optionsFrame[ "scripts" ])
            -- switch to the script editor
            LibStub("AceConfigDialog-3.0"):SelectGroup("PhotoOp Scripts", self.var.frame[ info.arg ].name)
          end
        end
      end
      -- relevant sub-options definition
      new_script_gui = {
        type = "group"
        , cmdHidden = true
        , name = L["new_script"]
        , set = setFrameOption
        , get = getFrameOption
        , args = {
          name = {
            type = "input"
            , name = L["new_script.name"]
            , validate = validateName
            , arg = { "new_script", "name" }
          }, description = {
            -- more element definitions ...
          }, create = {
            type = "execute"
            , name = L["new_script.create"]
            , disabled = function(info) return type(validateName(info, info.handler.var.frame.new_script.name)) == "string" end
            , func = createNewScript
            , arg = "new_script"
          }
        }
      }
      -- more options
      
      
      Posted in: AddOn HELP!
    • 0

      posted a message on OutRunner - Script runner and sharer
      I've actually just about finished writing a similar addon, PhotoOp, that takes screenshots based on provided scripts.

      I separated the script running code into a separate library. I also created an AceGUI-3.0 widget that adds line numbers to a multiline text box. Both are still bundled with the addon, but will probably be separated once I get to a 1.0 version.

      Some of the things that I have implemented include:
      • Scripts are given a reduced set of global variables
      • The global variable namespace is read only
      • A "self" variable is provided to store transient information
      • A "settings" variable provides access to allow storing persistent information (must be declared, very similar to how Outfitter works)
      • Scripts are checked for returning a random value (to provide some structural integrity)
      • Script frequency is tracked and if exceeds a threshold, disables the script temporarily (the program then uses a 5 strikes your out scheme)
      • Script duration is checked and likewise results in a temporary suspension

      Whether these are enough is another question.

      I hadn't thought to implement a sharing feature, but it might be possible to exploit it despite the reduced access. The main question is whether you can escape a global environment when the environment does not include setmetatable, getmetatable, or setfenv.
      Posted in: Lua Code Discussion
    • To post a comment, please or register a new account.