• 0

    posted a message on AcceptTrade() ... protected?
    Quote from DigitalSorceress
    Still, I am finding that the big thing about learning LUA for WOW is in understanding what is NOT possible.


    And also "WHY it is not possible". Lots of frustrations ("why did Blizz do this or that") are avoided if the extreme behavior that triggered the lockdown is known.

    Like:
    - Why do we need to use SecureActionButtons?
    Because ppl were making addons that allowed you to play your character by just pressing one hotkey over and over. There were page-long scripts you could load up in an addon, bind to a hotkey and just spam away. Look up LazyRogue, LazyWarrior and derivatives.
    It also enables botting.

    - Why can't we make our char run and turn from addons?
    Because some ppl were using the addon "TakeMeThere" to record a certain running path and then whenever they needed to do a long trek (Auberdine -> top of Darkshore anyone?) they'd let the addon do the boring work.
    It also enables botting.

    I've seen what botting does to other games.... it ain't pretty. This is a freedom worth sacrificing.
    Posted in: Lua Code Discussion
  • 0

    posted a message on NPC Faction Standing - Help
    UnitCanAttack(unit, unit2) ??

    If you can attack it you are either in bad standing or at war with it...

    Or:

    http://www.wowwiki.com/API_UnitReaction :
    Determine the reaction of the specified unit to the other specified unit.
    reaction = UnitReaction("unit", "otherUnit");

    or

    read your own faction-list into a table and match that to the tooltip of the NPC
    local factions = {}
    local name, standingId
    for i = 1, GetNumFactions() do
      name, _, standingId = GetFactionInfo(i)
      factions[name] = standingId
    end
    for i = 1, MyTooltip:NumLines() do
      line = getglobal('MyTooltipTextLeft'..tostring(i)
      if line and factions[line]
        return factions[line]
      end
    end


    I think, seeing what standingid means, that UnitReaction() is what you need...
    Posted in: Lua Code Discussion
  • 0

    posted a message on Bartender4 - Official Topic
    Quote from Nevcairiel
    Highlighting is only visual, and visual is no issue at all, because it does not affect the behaviour of the bars. However, i currently have no plans to support the highlighting. But some other changes i've planned will make it easier to add as a 3rd party module.


    Could you give out some info on how another developer would have to go about to create such a buff/debuff highlighting plugin for BT4? My wife and I switched from Bongos2 to BT4 after 3.x hit and it didn't take long until I got the whine "my Rend isn't lighting up anymore *sadface*".

    Help me calm the storm!! :p

    Don't need specifics on detecting buffs/debuffs (I got that covered), just what the "API" for it would be...
    Posted in: General AddOns
  • 0

    posted a message on Pulling Info from a Text File
    Handy if you're inputting a lot of static data in your addon and it's easier to generate it from excel than manually inputting it in yr editor of choice...
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using the metatable for my own purposes
    As I mentioned, I don't have a problem with detecting and avoiding loops. I also detect them by remembering which ones I already parsed. It's those "premature downlinks" that distort my view. Is it usable? Sure! But I want better.

    What my question was is:
    - Will Lua go nuts if I mess w the metatable in this manner? --> Xinhuan answered that: NO
    - Should I do it? --> Best not, or only in debugmode or sth.

    --> I COULD add a little var in the top of my first-loaded .lua file like: adddownlinks = true and turn that off in releases and on in my betas. Or have it parse the addon-version for the some regex that the packager looks for...

    And as for table-recycling and metatables: I already updated my table-recycling ftion per another one of Xinhuan's suggestions in my LibMindReader-official thread.

    Frankly, the amount of really unwanted downlinks should be minimal, so I doubt performance issues are going to be a factor.

    Thanks for the feedback guys.

    Seems I'm making all the noob mistakes along with the advanced mistakes at the same time :p
    Posted in: Lua Code Discussion
  • 0

    posted a message on strsplit problem
    Hmmm, apparently this is also mentioned here:
    http://www.lua.org/pil/5.1.html
    I already had a sneaking suspicion there already was a ftion that did this.

    In any case, if you need an unpack that returns the dictionary portion of a table, you can still use my first version :D.
    Posted in: Lua Code Discussion
  • 0

    posted a message on strsplit problem
    Something like this?

    function tab2args(t, previousk)
      local nextk, v = next(t, previousk)
      if nextk then
        return v, tab2args(t, nextk)
      else
        return v
      end
    end

    It should keep concatenating the values of the table until it reaches the end. Using next means that the order is undefined though. So for sequentially-number-indexed tables you can use:
    function tab2args(t, previousi)
      local i = 1
      if previousi then
        i = previousi + 1
      end
      local v = t[i]
      if v then
        return v, tab2args(t, i)
      else
        return v
      end
    end


    then call with
    local tbl = {}
    for v in string.gmatch(text, "[^\>]+") do
      tinsert(tbl, v)
    end
    return tab2args(tbl)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wysiwyg or notepad
    Yes, that L20 UD Rogue on Hellscream EU named Wintrow that is making me rename my beloved L70 Druid on Aggramar also named Wintrow if I wanna hook up with my brother and friends on there.

    L20 and his profile is empty on eu.wowarmory.com. SO 9/10 he's an abandoned alt or worse... a 10-day trial tossed aside after reaching L20 and not having the money or inclination to continue the game...

    Damn all UD Rogues to hell and back !!
    *shakes fist*
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using the metatable for my own purposes
    Hi,

    I made a table-traversing library a while a ago to help me debug stuff (LibMindReader). In order to prevent infinite loops I did my best to detect cross- and uplinks.

    example:
    a = {
      b = '200',
      c = 4,
      d = {
        e = { 1,2,3 },
      },
    };
    d.parent = a -- this is an uplink, easy to detect
    a.firstd = a.d.e -- this is a downlink and a PITA


    Traversing var a would result in an infinite loop if I didn't keep track that I already "did" a. It works, but it's not perfect. As I said uplinks are caught nicely, crosslinks are caught if they are up-cross-links.

    What gets me in trouble is downlinks like a.firstd. Not because they cause infinite loops (they don't). But because they distort the view I get of the table being traversed. Downlinks are shortcuts made for performance reasons, they are not REALLY part of the data-structure. So I have two choices:
    a) avoid downlinks: this will reduce performance, but should be feasable.
    b) use downlinks, but mark them as such so that the lib will not descend into them (maybe the lib will then switch to just giving a count of it's children or sth, to help).

    Being a performance-optimizing-junkie I'd like to try b) first of course.

    Now marking them as such would probably be done best by adding it to the downlink itself (or it's parent). One way I was thinking of was:

    In my own addon:
    local mt = getmetatable(a)
    if not mt then
      mt = {}
      setmetatable(a,mt)
    end
    mt.downlinks = { firstd = true }


    then later in the lib while traversing:
    local mt = getmetatable(parent)
    local downlinks
    if mt then
      downlinks = mt.downlinks
    end
    ...
    for k, v in pairs(parent) do
      if type(v) == 'table' then
        if downlinks and downlinks[k] then
          -- it's a downlink! don't traverse it's children!
        else
          -- it's cool
        end
    end


    Question is: is it ok to try this with the metatable?
    I should probably also add a metafunction to clear the key out of the downlink-table if it gets nilled in the real table...

    The alternative:

    A globally reachable table (not necessarily a global though) of the format
    downlinks = {
      [a] = {
        ['firstd'] = true,
      }
    }

    or a method in my lib that lets it maintain the downlinks-table. This seems a lot less "woohoo" though...
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wysiwyg or notepad
    So... if I like XML, what does that make me?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Few LUA Questions
    To further explain/confuse:
    MyAddon = {}
    local mod = MyAddon
    
    mod.title = "My Add-On"
    mod.getTitle = function(self)
           return self.title
    end


    or even

    MyAddon = {}
    local mod = MyAddon
    
    mod.title = "My Add-On"
    
    local function gt(self)
           return self.title
    end
    
    mod.getTitle = gt


    do the same

    the only "rule" really is that, if you call ANY function in "object:method"-style it's first parameter will be "object".

    If you wanna do
    MyAddon = {}
    local mod = MyAddon
    
    mod.title = "My Add-On"
    local function gt(cowdoodoo)
           return cowdoodoo.title
    end
    
    mod.getTitle = gt


    and then call it with

    function getMATitle()
           return MyAddon:getTitle()
    end


    it'll STILL work fine
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wysiwyg or notepad
    I prefer to make my templates in XML and then creating them in LUA. Best of both worlds IMO...
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tables.. ARG!
    Groovy !
    Posted in: Lua Code Discussion
  • 0

    posted a message on OutRunner - Script runner and sharer
    Quote from LokiCoyote
    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.


    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.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tables.. ARG!
    More practically: If you have a string that has to have a single quote in it, delimit with double quotes. And vice versa. If you need a string that has both: concatenation is the name of the game.

    "My cousin's father"..' said:"Come over here". And I went.'
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.