CurseForge and Overwolf are joining forces!
Awesome More Information
  • 0

    posted a message on Question:Acetimer3.0 and Libsimpletimer.
    okay testing it i don't think bucket is what i am looking for, so i tried timer and a one shot timer is what i needed.

    now my question is: If i call the timer scheduler from inside the function do i run a risk of making too many timers or does a timer named the same as another overlap the other?((and again answering myself..it does build up...I r teh newb))


    to further explain..I am working on a Roleplaying mod for free form combat, what i am doing is making a virtual combat timer

    so they use a skill in the addon,
    a Incombat function is called again flagging them as in combat(among other things)
    the timer is scheduled in that function for the skill under the above call

    if they don't use another skill for so many seconds they will drop the virtual combat flag (timer expires).
    Posted in: Libraries
  • 0

    posted a message on Question:Acetimer3.0 and Libsimpletimer.
    Okay. You get a thank you too then! ^^
    Posted in: Libraries
  • 0

    posted a message on Question:Acetimer3.0 and Libsimpletimer.
    ugh i am back..after digging on my own can i use this for custom addon events or just blizzard defined events?

    edit: wait i answered my own question, i would need to use addon:RegisterBucketMessage( message, inteval[, method] )
    instead of registerbucketevent?
    Posted in: Libraries
  • 0

    posted a message on Question:Acetimer3.0 and Libsimpletimer.
    Thank you very much. :D
    Posted in: Libraries
  • 0

    posted a message on Question:Acetimer3.0 and Libsimpletimer.
    i was scared of that...acebucket confuses me not matter how many times i look at it, though i tend to may things to hard for myself when i think on them until i get it. go figure.

    Could you please provide me with a filled in example or simple example?
    Posted in: Libraries
  • 0

    posted a message on Question:Acetimer3.0 and Libsimpletimer.
    Just a question on advice and maybe suggested implentation examples to the newb.

    I just want to do a simple thing of haveing a 'cooldown' period in the addon i am working on the simple event fires >trigger timer > force wait until timer expires to do event again.

    With libsimpletimer it seems like i have more control, Acetimer looks the same but i am not sure i have the coding structure right in my head.

    Thanks in advance.
    Posted in: Libraries
  • 0

    posted a message on making a slash command work like the /me emote command
    Thank you my friend i shall try this. *gives a cookie*
    Posted in: Lua Code Discussion
  • 0

    posted a message on making a slash command work like the /me emote command
    okay so what i am trying to do is use a addon / command to emulate the /me command.

    i tried registerchatcommand with the Ace3 frame work but i couldn't get it to accept a long string of input.

    basiccly i am going "/<addonslash> <emote input>" passing to <function that does a sendchatmessage with input and a whole bunch of other things>
    Posted in: Lua Code Discussion
  • 0

    posted a message on AceComm-3.0 Best Practices Examples
    so is the comms={} table filled preemptively with a list of current functions in addon? just running through the process in my head

    also the on decode check, could this be if say you recive an unsterilized comm message from another addon? (IE An addon directs a message at your addon but the message isn't seralized..kinda a hypothetical thing here)
    Posted in: Ace3
  • 0

    posted a message on Question:
    So i started hacking this with a rusty knife...its all wrong but its baisclly me stripping out the ace2 bits and trying to force in the Libstub bits, I get a cannot find instance of libery with my call in my test lua(whitch is a modified example thing from the end of the orginal lib itself.
    Insight welcome..But when tearing into me for please avoid Vital organs.

    Again only reason i want this lib stub cuase a mod me and my friends are doing is gonna be ace3 and this was a ace2 lib...I don't want to clash frameworks.
    UPDATE: I got it..semi working in my test lua..BUT around frame_names[self][frame_name] = frame_label in the Lib it pops a Nil error at me. Help.
    local MAJOR_VERSION = "StatFrameLib-1.0"
    local MINOR_VERSION = 90000 + tonumber(("$Revision: 40 $"):match("(%d+)"))
    
    local StatFrameLib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
    
    
    --not sure what how to handle the below
    --[[local StatFrameLib = AceOO.Mixin {
       "AddStatFrame",
       "RemoveStatFrame",
       "RemoveAllStatFrames",
       "StatFrameReport",
       "IsShowingStatFrame",
       "RepaintStatFrame",
       "RepaintAllStatFrames",
       "StatBoxSet",
       "StatBoxSetWithoutShow",
    }]]--
    
    -- local declarations
    local frame_index_from_name, frame_label_from_name, frame_name_from_index
    local paintLeftStatFrame, paintRightStatFrame, repaintTooltips
    local setupLeftStatFrame, setupRightStatFrame
    local default_mouseovers, slurpDefaultEventHooks, setDefaultEventHooks
    local UpdatePaperdollStatsHook, activate
    
    local StatFrameLeft, StatFrameRight
    local stat_frame_left_default_hooks,stat_frame_right_default_hooks
    local setBlizEventHooks
    
    -- indexes => frame_name
    -- names => labels
    local frame_indexes,frame_names
    --#NODOC local
    function frame_index_from_name(name)
       return "STATFRAME_"..string.upper(name)
    end
    --#NODOC local
    function frame_label_from_name(name)
       return frame_labels[self][name]
    end
    --#NODOC local
    function frame_name_from_index(index)
       return frame_name[self][index]
    end
    
    
    --[[-------------------------------------------
      Public methods
    --]]
    
    --[[-------------------------------------------
    -- Notes:
    --         * Adds a stat frame to the dropdown list.
    --         * Should be added on enable, not on load - frames will be dropped on suspend
    --         * You MUST have a method for painting the frame. This will be a method
    --           on your object named Paint[frame name]. So if you called AddStatFrame("Peter")
    --           then it would be :PaintPeter. See the example.
    --         * You MAY have a method for setting up custom mouseovers and such for the lines.
    --           This method will be called SetupFrame[frame name] like the above. See the example.
    --         * If you just want tooltips, create methods like Paint[frame name]Line1Tooltip.
    --           GameTooltip anchor will be set up for you, just go ahead and write to it.
    --           This will not work if you do a custom SetupFrame. See the example for more.
    -- Arguments:
    --         string - name of the frame to add. This is the programmatic name, not the label.
    --         string - label for the frame.
    --]]
    function StatFrameLib:AddStatFrame(frame_name,frame_label)
       local frame_index = frame_index_from_name(frame_name)
    
       for _,v in ipairs(PLAYERSTAT_DROPDOWN_OPTIONS) do
          if v == frame_index then
             error(string.format("Attempted to doubly add stat frame %s",frame_name))
          end
       end
    
       tinsert(PLAYERSTAT_DROPDOWN_OPTIONS,frame_index)
       _G[frame_index] = frame_label
    
       frame_names[self][frame_name] = frame_label
       frame_indexes[self][frame_index] = frame_name
    
       local paint_method = self["Paint"..frame_name]
       if not paint_method then
          error(self.format("Cannot add stat frame %s: paint method %s does not exist!",frame_name,paint_method))
       end
    end
    
    --[[-------------------------------------------
    -- Arguments:
    --         string - programmatic name of the frame to remove
    -- Notes:
    --         * Not necessary to call this method on disable - will automatically be called.
    --]]
    function StatFrameLib:RemoveStatFrame(frame_name)
       local frame_index = frame_index_from_name(frame_name)
       local removed = false
       for k,v in ipairs(PLAYERSTAT_DROPDOWN_OPTIONS) do
          if v == frame_index then
             removed = true
             tremove(PLAYERSTAT_DROPDOWN_OPTIONS,k)
          end
       end
       if not removed then
          error("Attempted to remove non-existant StatFrame %s",frame_name);
       end
    
       -- cleanup after ourselves
       if GetCVar("playerStatLeftDropdown") == frame_index then
          SetCVar("playerStatLeftDropdown", "PLAYERSTAT_BASE_STATS")
       end
       if GetCVar("playerStatRightDropdown") == frame_index then
          local _,class = UnitClass("player")
          if "MAGE" == class or "PRIEST" == class or "WARLOCK" == class or "DRUID" == class then
             SetCVar("playerStatRightDropdown", "PLAYERSTAT_SPELL_COMBAT")
          elseif "HUNTER" == class then
             SetCVar("playerStatRightDropdown", "PLAYERSTAT_RANGED_COMBAT")
          else
             SetCVar("playerStatRightDropdown", "PLAYERSTAT_MELEE_COMBAT")
          end
       end
       UIDropDownMenu_SetSelectedValue(PlayerStatFrameLeftDropDown, GetCVar("playerStatLeftDropdown"))
       UIDropDownMenu_SetSelectedValue(PlayerStatFrameRightDropDown, GetCVar("playerStatRightDropdown"))
       PaperDollFrame_UpdateStats()
    
       frame_names[self][frame_name] = nil
       frame_indexes[self][frame_index] = nil
    end
    
    --[[-------------------------------------------
    -- Notes:
    --         * Removes all of your stat frames
    --]]
    function StatFrameLib:RemoveAllStatFrames()
       DEFAULT_CHAT_FRAME:AddMessage("removing all frames")
       for frame_name,_ in pairs(frame_names[self]) do
          self:RemoveStatFrame(frame_name)
       end
    end
    
    --[[-------------------------------------------
    -- Notes:
    --         * Lets you know if your stat frame is being displayed
    -- Arguments:
    --         string - name of the frame you're querying
    --]]
    function StatFrameLib:IsShowingStatFrame(frame_name)
       local index = frame_index_from_name(frame_name)
       if not index then
          error("Frame %s does not exist", frame_name)
       end
    
       if GetCVar("playerStatRightDropdown") == index or
          GetCVar("playerStatLeftDropdown")  == index then
          return true
       else
          return false
       end
    end
    
    --[[-------------------------------------------
    -- Notes:
    --          * Method you call to actually set the label and text for lines in the StatBox
    --          * labels and values will be coerced to strings, so don't worry too much about them
    --          * Will automatically show the line. Use the variant call if you don't want to do that.
    --          * See the example for how this is used
    -- Arguments:
    --         object - the line you're drawing to
    --         string - the label
    --         string or number - the value
    --         boolean - if the VALUE is a number show it as a percentage
    --]]
    function StatFrameLib:StatBoxSet(statbox, label, value, percentage)
       if type(value) ~= "number" then
          value = tostring(value)
       end
       PaperDollFrame_SetLabelAndText(statbox, tostring(label), value, percentage)
       statbox:Show()
    end
    
    --[[-------------------------------------------
    -- Notes:
    --         * Same call as StatBoxSet, but does not automatically show the line
    -- Arguments:
    --         object - the line you're drawing to
    --         string - the label
    --         string or number - the value
    --         boolean - if the VALUE is a number show it as a percentage
    --]]
    function StatFrameLib:StatBoxSetWithoutShow(statbox,label,value,percentage)
       if type(value) ~= "number" then
          value = tostring(value)
       end
       PaperDollFrame_SetLabelAndText(statbox,tostring(label),value,percentage)
    end
    
    --[[-------------------------------------------
    -- Notes:
    --         * Orders a repaint of your stat frame
    -- Arguments:
    --         string - the programmatic name of the frame
    --]]
    function StatFrameLib:RepaintStatFrame(frame_name)
       local index = frame_index_from_name(frame_name)
       local painter = self["Paint"..frame_name]
       if not index then
          error("Stat frame %s does not exist",frame_name)
       end
       if GetCVar("playerStatRightDropdown") == index then
          paintRightStatFrame(painter, self)
          repaintTooltips("PlayerStatFrameRight", StatFrameRight)
       end
       if GetCVar("playerStatLeftDropdown") == index then
          paintLeftStatFrame(painter, self)
          repaintTooltips("PlayerStatFrameLeft", StatFrameLeft)
       end
    end
    
    --[[-------------------------------------------
    -- Notes:
    --         * Repaints all of your stat frames
    --]]
    -- TankPoints:RepaintStatFrame("TankPoints")
    function StatFrameLib:RepaintAllStatFrames()
       for frame_name, _ in pairs(frame_names[self]) do
          self:RepaintStatFrame(frame_name)
       end
    end
    --[[-------------------------------------------
      Private Methods
    --]]
    
    StatFrameLeft = {
       _G["PlayerStatFrameLeft1"],
       _G["PlayerStatFrameLeft2"],
       _G["PlayerStatFrameLeft3"],
       _G["PlayerStatFrameLeft4"],
       _G["PlayerStatFrameLeft5"],
       _G["PlayerStatFrameLeft6"]
    }
    StatFrameRight = {
       _G["PlayerStatFrameRight1"],
       _G["PlayerStatFrameRight2"],
       _G["PlayerStatFrameRight3"],
       _G["PlayerStatFrameRight4"],
       _G["PlayerStatFrameRight5"],
       _G["PlayerStatFrameRight6"]
    }
    
    --#NODOC local
    function paintLeftStatFrame(painter,obj)
       for _,line in ipairs(StatFrameLeft) do
          line:Hide()
       end
       painter(obj,StatFrameLeft[1],StatFrameLeft[2],StatFrameLeft[3],
                   StatFrameLeft[4],StatFrameLeft[5],StatFrameLeft[6])
    end
    --#NODOC local
    function paintRightStatFrame(painter, obj)
       for _, line in ipairs(StatFrameRight) do
          line:Hide()
       end
       painter(obj,StatFrameRight[1],StatFrameRight[2],StatFrameRight[3],
                   StatFrameRight[4],StatFrameRight[5],StatFrameRight[6])
    end
    --#NODOC local
    function repaintTooltips(frame,framelist)
       for _,line in ipairs(framelist) do
          if GameTooltip:IsOwned(line) then
             line:GetScript("OnEnter")(frame)
          end
       end
    end
    --#NODOC local
    function setupLeftStatFrame(frame_setup,obj,frame_name)
       frame_setup(obj,StatFrameLeft[1],StatFrameLeft[2],StatFrameLeft[3],
                       StatFrameLeft[4],StatFrameLeft[5],StatFrameLeft[6],
                    frame_name)
    end
    --#NODOC local
    function setupRightStatFrame(frame_setup,obj,frame_name)
       frame_setup(obj,StatFrameRight[1],StatFrameRight[2],StatFrameRight[3],
                       StatFrameRight[4],StatFrameRight[5],StatFrameRight[6],
                    frame_name)
    end
    --#NODOC local
    function default_mouseovers(obj,line1,line2,line3,line4,line5,line6,frame_name)
       local painter = function(line)
                          local p = obj["Paint"..frame_name.."Line"..tostring(line).."Tooltip"]
                          if p then
                             return function(frame,_)
                                       GameTooltip:SetOwner(frame, "ANCHOR_RIGHT")
                                       p(obj)
                                       GameTooltip:Show()
                                    end
                          else
                             return nil
                          end
                       end
       line1:SetScript("OnEnter",painter(1))
       line2:SetScript("OnEnter",painter(2))
       line3:SetScript("OnEnter",painter(3))
       line4:SetScript("OnEnter",painter(4))
       line5:SetScript("OnEnter",painter(5))
       line6:SetScript("OnEnter",painter(6))
    end
    
    --#NODOC local
    function slurpDefaultEventHooks()
       local events = {"OnEnter","OnLeave","OnMouseUp","OnMouseDown"}
       stat_frame_left_default_hooks = {}
       for _, line in ipairs(StatFrameLeft) do
          local line_hooks = {}
          for _, event in ipairs(events) do
             line_hooks[event] = line:GetScript(event)
          end
          tinsert(stat_frame_left_default_hooks,line_hooks)
       end
       stat_frame_right_default_hooks = {}
       for _, line in ipairs(StatFrameRight) do
          local line_hooks = {}
          for _, event in ipairs(events) do
             line_hooks[event] = line:GetScript(event)
          end
          tinsert(stat_frame_right_default_hooks,line_hooks)
       end
    end
    --#NODOC local
    -- this sets things back to Bliz-ish
    function setDefaultEventHooks(frame,defaults,index)
       for i,line in ipairs(frame) do
          for event,func in pairs(defaults[i]) do
             line:SetScript(event,func)
          end
       end
       setBlizEventHooks(frame,index)
    end
    
    --#NODOC local
    -- this is a copy of what PaperDollFrame.lua:function UpdatePaperdollStats
    -- using ONLY the SetScript commands
    function setBlizEventHooks(frame, index)
       local stat1,stat2,stat3,stat4,stat5,stat6 = unpack(frame)
    
       -- reset any OnEnter scripts that may have been changed
       stat1:SetScript("OnEnter", PaperDollStatTooltip);
       stat2:SetScript("OnEnter", PaperDollStatTooltip);
       stat4:SetScript("OnEnter", PaperDollStatTooltip);
    
       if ( index == "PLAYERSTAT_BASE_STATS" ) then
       elseif ( index == "PLAYERSTAT_MELEE_COMBAT" ) then
          stat1:SetScript("OnEnter", CharacterDamageFrame_OnEnter);
       elseif ( index == "PLAYERSTAT_RANGED_COMBAT" ) then
          stat1:SetScript("OnEnter", CharacterRangedDamageFrame_OnEnter);
       elseif ( index == "PLAYERSTAT_SPELL_COMBAT" ) then
          stat1:SetScript("OnEnter", CharacterSpellBonusDamage_OnEnter);
          stat4:SetScript("OnEnter", CharacterSpellCritChance_OnEnter);
       elseif ( index == "PLAYERSTAT_DEFENSES" ) then
       end
    end
    
    --#NODOC local
    function UpdatePaperdollStatsHook(frame, index)
       local custom_paint = false
       for obj, frames in pairs(frame_indexes) do
          for frame_index,frame_name in pairs(frames) do
             if index == frame_index then
                custom_paint = true
                if "PlayerStatFrameLeft" == frame then
                   frame_setup = obj["SetupFrame"..frame_name]
                   if frame_setup then
                      setupLeftStatFrame(frame_setup,obj)
                   else
                      setupLeftStatFrame(default_mouseovers,obj,frame_name)
                   end
                   paintLeftStatFrame(obj["Paint"..frame_name],obj)
                elseif "PlayerStatFrameRight" == frame then
                   frame_setup = obj["SetupFrame"..frame_name]
                   if frame_setup then
                      setupRightStatFrame(frame_setup,obj)
                   else
                      setupRightStatFrame(default_mouseovers,obj,frame_name)
                   end
                   paintRightStatFrame(obj["Paint"..frame_name],obj)
                else
                   error("Unknown frame to paint: %s",frame)
                end
             end
          end
       end
       if not custom_paint then
          if "PlayerStatFrameLeft" == frame then
             setDefaultEventHooks(StatFrameLeft,stat_frame_left_default_hooks,index)
          elseif "PlayerStatFrameRight" == frame then
             setDefaultEventHooks(StatFrameRight,stat_frame_right_default_hooks,index)
          end -- we don't know what to do with it so just leave it alone
       end
    end
    
    --[[--------------------------------------------
      Load/unload and debug help
    --]]
    
    --#NODOC
    function StatFrameLib:StatFrameReport()
       self:Print("List of stat frames added:")
       if not next(frame_names[self]) then
          self:Print("No stat frames have been added")
       end
    
       for index,name in pairs(frame_indexes[self]) do
          self:Print(string.format('"%s" - "%s" (index: %s)', name, frame_names[self][name], index))
       end
    end
    
    --#NODOC
    function StatFrameLib:OnInstanceInit(object)
       -- make sure AceHook is initialized before us
       -- it should be safe to call this multiple times
       --AceHook:OnInstanceInit(object)--Commented out-AB
    
       if not frame_names[object] then
          frame_names[object] = {}
       end
       if not frame_indexes[object] then
          frame_indexes[object] = {}
       end
    
       object:SecureHook("UpdatePaperdollStats",UpdatePaperdollStatsHook)
    end
    
    --#NODOC
    function StatFrameLib:OnEmbedDisable(object)
       -- OnEmbedDisable needs to be in the StatFrameLib table, but it isn't
       -- called in relation to the table. Odd, but there you are.
       object:RemoveAllStatFrames()
    end
    
    -------------------------------
    --#NODOC local
    function activate(self, oldLib, oldDeactivate)
       StatFrameLib = self
    
       self.frame_names = oldLib and oldLib.frame_names or {}
       self.frame_indexes = oldLib and oldLib.frame_indexes or {}
    
       frame_names = self.frame_names
       frame_indexes = self.frame_indexes
    
       slurpDefaultEventHooks()
       self:activate(oldLib, oldDeactivate)
       if oldDeactivate then
          oldDeactivate(oldLib)
       end
    end
    
    --Not even sure i need this but...
    AceLibrary:Register(StatFrameLib, MAJOR_VERSION, MINOR_VERSION, activate)
    Posted in: Libraries
  • 0

    posted a message on Question:
    and this may be the wrong place for but wasn't sure.

    Okay i found http://www.wowace.com/projects/statframelib/ and for a addon still in slight concept stage me and some friends are working on this would be great. One problem. addons going to use the ace3 framework, lib uses ace2. So how does the newbie go about converting it from ace2 to libstub?

    Again if this is the wrong forum for it...I beg forgiveness. *grovels before code gods*
    Posted in: Libraries
  • 0

    posted a message on Seeking Advice/Help:Ace3 comm message methods
    Hello,
    I am just looking to see what people do to split up thier comm messages with
    Ace3, I am trying a callback handler method i was pointed at elsewhere.

    Problem is i am getting an error when i set up my callback calls of "Do not use library:RegisterCommsCall()*<being the register callback set up*, use your own 'self'" error whitch of course is keeping things from fireing.

    I am however generally curious on diffrent methods that can be used.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Question: Going Modular[Solved...almost]
    Okay me and a friend are starting to work on a mod, right now doing some proofs of concepts for some things.

    Eventually the whole addon would be modules of different things.

    Now being the Newbie that i am with this, what is the correct method to do that?
    I did some prodding through some addon that are like this and still wind up short. basically just need the modules to share options with each other (or in the end the 'core') and maybe access things across each other, BESIDES global variables. Globals worked in POC mods i have but the options didn't share/merge with the main ones.
    This is with Ace2 btw.

    Hope someone can help. Thank you.

    edit: Found it by further diging it was AceModuleCore i was missing...though any tidbits anyone could offer is fine.

    Edit2:yeah keep editing my post..so yeah...not sure how to splice in the options from the module to the core (right now its through the slash commands until it goes GUI.)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help if you please: Newbie coder
    So newbie coder walking here.
    ME and my friend came up with the idea for a rp addon (for free form attack rolls..odd to some yes but humor please >.>)
    Anyway right now the code is pretty bare as my partner in rp crime works out some math logistics.
    Basicly its gonna take one stat and put it versus another stat.

    My problem is thus: I hardcoded some data to make sure my logic worked correctly but when i got to send it i get a error on arugmant #4 of the comm message,.
    I will post code here, tell me what i have done wrong(its text based i plan to gui it when i can figure that out.)
    i shall try to keep the code short as i can:
    Main Lua
    INA = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "AceComm-2.0", "AceDebug-2.0", "AceHook-2.1");
    
    INA:RegisterDB("INADB", "INADBPC", "char");
    
    INA:RegisterDefaults(
     "char", {
      stats = {};
      }
    );
    
    INA:RegisterDefaults(
     "profile", {
      -- settings
     }
    );
    
    ---Initilize
    function INA:OnInitialize()
    
    self:SetCommPrefix("INAc");
    
    end
    ---end init
    --mod enabled, register events and comms--
    function INA:OnEnable()
    
    self:RegisterComm(self.commPrefix, "WHISPER");
    
    --self:RegisterEvent("CHAT_MSG_SYSTEM");
    
    
    self:RegisterEvent("INA_ROLL");
    self:RegisterEvent("INA_OPROLL");--oppent roll..its redundent..yes...
    self:RegisterEvent("INA_RESULT");
    self:RegisterEvent("INA_RESFINAL");
    self:RegisterEvent("INA_SETSTATS");
    --self:RegisterEvent("INA_SHOWSTATS");
    
    self:TriggerEvent("INA_SETSTATS");
    --do we want to trigger set stats here or else where?
    end
    --end onenable
    
    function INA:OnDisable()
    end
    
    
    local options = {
    type = "group",
     args = {
      froll = {
      type = "execute",
       name = "Free Roll",
       desc = "Random 100 rolld",
       func = function()
        local rand = math.random(1, 100);
        self:Print(rand);    
       end
      },
      aroll = {
      type = "execute",
       name = "AttackRoll",--set a target name for the roll its called in INA_ROLL
       desc = "Attack roll",
       get = "getTarget",
       set = "setTarget",
       func = function()
       INA:Print(INA.target);
       INA:TriggerEvent("INA_ROLL")--alternativly might be simplier to do with a gui
                      --laying out logic here
       end
      },
    
    }--args
    }--options
    
    INA:RegisterChatCommand({"/ina", "/ia"}, options);
    
    INA.target = ".";
    INA:Print(INA.target);
    function INA:getTarget()
      
      return INA.target;
    end
    
    function INA:setTarget(newValue)
      INA.target = newValue--set target for the roll so it can be inserted
                 --into a UnitName call
    end

    ------------
    Event Lua(alot of pingponging and is bare as i said):
    function INA:INA_SETSTATS()
    ---REMOVED TO SAVE SPACE ON FORM POST--
    end
    resPlyr = 0; --result of player roll
    resPlyr2 = 0;-- result of player roll--for testing purposes
    resOpp = 0;-- result of oppent
    pname = UnitName("player");--get our name
    name = INA.target; --set our targets name
    WL = "";
    
    function INA:INA_ROLL()
    --stat math here with random varible
    --store resPlyr
    --call oppents roll
    resPlyr = 1;
    self:SendCommMessage("WHISPER", UnitName(name), "Roll", resPlyr); --send our roll to oppenent
    end
    
    function INA:INA_OPROLL()--this is the oppents roll, on thier end they are just storeing thier result and storeing thier challangers
    --stat math here with random varible
    --store resPlyr
    --call results roll
    resPlyr = 2;
    self:SendCommMessage("WHISPER", UnitName(name), "Result", resPlyr); 
    end
    
    function INA:INA_RESULT()
    --do math on res plyr and opp
    if resPlyr > resOpp then
    WL = pname.."Wins the roll over "..name..".";
    --else if not over oppennt
    elseif resPlyr < resOpp then
    WL = name.."Wins the roll over "..pname..".";
    end
    self:Print(WL);
    --now send results to oppent so they can see
    self:SendCommMessage("WHISPER", UnitName(name), "Final", WL);--send to oppent 
    --could also just trigger the below from here
    end
    
    function INA:INA_RESFINAL()--print to oppenet so they can see, inefficent but eh
    self:Print(WL);
    
    end

    ------
    Comm Lua(MORE pingponging):
    INA.OnCommReceive = {}
    
    function INA.OnCommReceive:Roll(prefix, sender, distribution, res)
    self.target = sender;--set oppents target to attacker name
    resOpp = res;
    self:TriggerEvent("INA_OPROLL");
    end
    
    
    function INA.OnCommReceive:Result(prefix, sender, distribution, res)
    resOpp = res;--now we store thier roll
    self:TriggerEvent("INA_RESULT");
    end
    
    
    function INA.OnCommReceive:Final(prefix, sender, distribution, res)
    self:Print(res);
    wl = res
    self:TriggerEvent("INA_RESFINAL")
    end



    ...so yeah..bash newbie here *points to her head*
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.