WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Personal Addon Not Loading... (https://www.wowinterface.com/forums/showthread.php?t=39288)

Kenshone 03-15-11 09:31 AM

Personal Addon Not Loading...
 
Hello. I'm having a simple problem which I hope has a simple solution. My addon is not loading.
  • I have even tried putting
    Code:

    print("hi")
    at line 1 of the addon, and it won't even run that bit of code.
  • I have tested the code by putting it in another (Ace3-based) addon's lua and just running my module out of it. But when I isolate the module into its own (non-Ace3) addon, it does not seem to respond. I took care to ensure there aren't any references/embeds/dependences on Ace3.
  • My isolated module shows up in my AddOns list in-game, and I am able to click the "enable" box.
  • I've noticed that ever since I made this addon, the load times on the launcher and the loading of wow.exe in general has slowed considerably. Whereas it was a second before, it takes about 10 seconds now.
  • I have run the code through an lua debugger, and I'm confident the grammar and logic are both sound, so I think this has to be something syntactical.
  • I have followed the basic wowwiki guides to creating one's own addon, as far as the naming of files as well as the .toc


Any help with this would be greatly appreciated! Thank you.

Grimsin 03-15-11 09:44 AM

Mind posting the code? without seeing whats going on i cant tell you why its not working.

Kenshone 03-15-11 09:47 AM

The code is almost 1200 lines long. Is there any particular chunk you'd be interested in?

Grimsin 03-15-11 09:52 AM

well what does your addon do exactly? Since you cant get it to even print lets start with the .toc file you have setup and go from there.

Kenshone 03-15-11 09:56 AM

Here is the TOC

Code:

## Interface: 40000
## Title: Kenshone Quant Frames
## Notes: Ohai
## Author: Kenshone / Quantark US-Blackrock
## Version: Release 1.0
## DefaultState: Enabled
## SavedVariables: kenshoneEX,kenshoneWHY

KenshoneQuantFrames.lua

My addon has several functions. It will:
  • Parse the combat log and give certain notifications on certain combat log events
  • Create statusbars frame which will track the hp of NPC enemies of my raid.
  • Create another statusbars frame which will track innervates available within my raid.


I have to talk to a customer for a bit so I'll be back in about 20 minutes. Thanks!

Grimsin 03-15-11 10:02 AM

For starters remove the DefaultState part unless you intended it to be a Load on demand addon? Normally you only use that DefaultState part if your addon is going to be load on demand and normally it would be set to disabled so that the addon only loads when its information is requested by another addon. You want it to load up and do its thing all the time though correct? If so start with removing that and then see if your print function works when you log into wow. Then well move on to the rest of the code. to post a large chunk of code like that i use www.pastey.net if you want to go there and post your code and come back and post the link to it. very easy to use site.

edit - i would also remove the word release from the version entry. although that should work and will display in places as you intended it to... for other things you may do later it is a better practice to use only numbers and decimals there. Should you later decide to use that version number for some reason it will be easier to compare it to another value or string if it is all numerical.

another edit - if you are deadset on having the version mark release/alpha/beta i would use just a single letter r/a/b. Again for easier comparison later.

Rilgamon 03-15-11 10:33 AM

When your addon does not show the "hi" it is not loaded.
Check that your AddOn-Folder and the basepart of your AddOn have the same name.

Interface\AddOns\MyAddOn\MyAddOn.toc

Try to have it casesensitiv.
See WoW\Logs\FrameXML.log for problems related to loading your files.

Kenshone 03-15-11 10:34 AM

Well, I modified the TOC file, but unfortunately I can't log into WoW until I get home from work in about 9 hours. In the meanwhile, here is the link to the pastey:

http://www.pastey.net/147540-47x4

Grimsin 03-15-11 10:44 AM

I dont see any immediate problems. Wow is still down for maintenance so even if you could get on now it would do you no good lol. When it comes up i will do a quick check and see what happens and if the code fires errors or not.

Kenshone 03-15-11 10:49 AM

Grim I'd greatly appreciate that. Thank you.

I was contemplating adding an ADDON_LOADED eventhandler, but it doesn't seem necessary in some of the other addons I've seen.

Torhal 03-15-11 10:50 AM

Your "hi" print is executing - it's doing so before you're even in-game and before the ChatFrame is even loaded.

Nothing is happening because your "events" table doesn't exist, so the iteration over it to register the events does nothing. I'm assuming you meant to use your "eventsK" table, which is empty so would behave identically.

Grimsin 03-15-11 11:01 AM

Indeed, i didnt notice there was no actual events anywhere. EventsK should be populated at some point with the events you want to have it respond to. all of the print("hi") functions are happening but as Torhal said they are happening before the game loads you into it. Those print functions need to come after the event ADDON_LOADED maybe even after the event PLAYER_ENTERING_WORLD

Grimsin 03-15-11 11:12 AM

Here is my event handling from the core file of my UI and then a few examples of how it is used in other parts of the UI.

Core File Function -
Code:

--[[-----------------------------------------------------------------------------
Event handling - Use one frame to process multiple individual OnEvent needs
-------------------------------------------------------------------------------]]
do
        local frame, select, next, events = CreateFrame('Frame'), select, pairs({ })
        local register, unregister = frame.RegisterEvent, frame.UnregisterEvent
        frame:Hide()

        frame:SetScript('OnEvent', function(self, event, ...)
                for reference, func in next, events[event], nil do
                        func(reference, event, ...)
                end
        end)

        function addon.RegisterEvent(reference, event, func)
                if not events[event] then
                        events[event] = { }
                        register(frame, event)
                end
                events[event][reference] = func
        end

        function addon.RegisterEvents(reference, func, ...)
                local event
                for index = 1, select('#', ...) do
                        event = select(index, ...)
                        if not events[event] then
                                events[event] = { }
                                register(frame, event)
                        end
                        events[event][reference] = func
                end
        end

        function addon.UnregisterEvent(reference, event)
                if events[event] then
                        events[event][reference] = nil
                        if not next(events[event]) then
                                events[event] = nil
                                unregister(frame, event)
                        end
                end
        end

        function addon.UnregisterAllEvents(reference)
                for event, registry in next, events, nil do
                        registry[reference] = nil
                        if not next(registry) then
                                events[event] = nil
                                unregister(frame, event)
                        end
                end
        end
end

These are some examples of it being used.

On Show function that registers events to the party frames -
Code:

--[[-----------------------------------------------------------------------------
Register/Unregister events on Show/Hide
-------------------------------------------------------------------------------]]
local function OnShow(self)
        local register = addon.RegisterEvents
        register(self, UpdateDeadOffline, 'PARTY_MEMBER_DISABLE', 'PARTY_MEMBER_ENABLE')
        register(self, UpdateLeader, 'PARTY_LEADER_CHANGED', 'ZONE_CHANGED_NEW_AREA')
        register(self, UpdateName, 'UNIT_COMBAT', 'UNIT_FLAGS', 'UNIT_NAME_UPDATE', 'UNIT_THREAT_LIST_UPDATE', 'UNIT_THREAT_SITUATION_UPDATE')
        register(self, UpdatePower, 'UNIT_DISPLAYPOWER', 'UNIT_ENERGY', 'UNIT_MANA', 'UNIT_MAXENERGY', 'UNIT_MAXMANA', 'UNIT_MAXRUNICPOWER', 'UNIT_RAGE', 'UNIT_RUNIC_POWER')
        register(self, UpdatePvp, 'UNIT_DYNAMIC_FLAGS', 'UNIT_FACTION')
        register(self, UpdateQType, 'PARTY_MEMBERS_CHANGED', 'LFG_ROLE_CHECK_UPDATE', 'LFG_ROLE_UPDATE', 'PLAYER_ROLES_ASSIGNED', 'LFG_ROLE_CHECK_ROLE_CHOSEN', 'LFG_UPDATE_RANDOM_INFO', 'PLAYER_ENTERING_WORLD')
        register(self, UpdateUnit, 'PARTY_MEMBERS_CHANGED', 'UNIT_AURA', 'UNIT_HEALTH', 'UNIT_LEVEL')
        addon.RegisterEvent(self, 'UNIT_MAXHEALTH', UpdateHealth)
        if UnitFactionGroup(self.unit) == "Alliance" then   
                self.pvpIconFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-PVP-Alliance.blp")
        elseif UnitFactionGroup(self.unit) == "Horde" then
                self.pvpIconFrame.texture:SetTexture("Interface\\GroupFrame\\UI-Group-PVP-Horde.blp")
        end
        UpdateUnit(self, "")
        if not addon.settings.movedFrames.GrimUIPartyFrame1 then
                addon:ResetPartyFrames()
        else
                local position = addon.settings.movedFrames[self:GetName()]
        if position then
                addon:UnlockFrame(self)
                self:ClearAllPoints()
                self:SetPoint(unpack(position))
                addon:LockFrame(self)
        end
        end
       
end

A more generic PLAYER_ENTERING_WORLD event registration to fire a slew of functions -
Code:

addon.RegisterEvent("PlayerFrame-Initialize", 'PLAYER_ENTERING_WORLD', function(self, event)
        addon.UnregisterEvent(self, event)
        addon:ConfigureBlizPlayerFrame()
        addon:ConfigurePlayerFrame()
    addon:PlayerFrameSetScale()
end)


Kenshone 03-15-11 11:13 AM

fixed event registration

Code:

line 1185:        for eventname in pairs(eventsK) do KenshoneMagic:RegisterEvent(eventname) end
It was my understanding that writing lines such as:

eventsK:ADDON_LOADED

or

eventsK:VARIABLES_LOADED

followed by line 1185 would populate the "eventsK" table appropriately.

Grimsin 03-15-11 11:18 AM

just adding that wont fix it i dont think. You still need to make it populate EventsK with the events to respond to im not seeing anywhere that it does that.

eventsK:ADDON_LOADED i do not think will add ADDON_LOADED to the table if it will thats a new method to me :)

needs to look more like...
Code:

eventsK = {
"ADDON_LOADED",
"PLAYER_ENTERING_WORLD",
"SO_ON_AND_SO_FORTH",
}


Grimsin 03-15-11 11:37 AM

Hmm so your wrong torhal. I just loaded up print("hi") at the top of a file and it loaded it right up at the very top of the chatframe. as i thought the bliz stuff including chat frames are infact loaded and running when other addons get loaded.

Grimsin 03-15-11 11:40 AM

Line 8? local editbox = CreateFrame("EditBox", "MyAddOnEditBox", UIParent, "MyAddOnEditBoxTemplate")

"MyAddOnEditBoxTemplate" is not valid. EditBoxTemplate by itself may be though. Check and its not. I removed the template entry entirely and got it to fire up with out errors. If its working or not though im not sure.

Kenshone 03-15-11 11:42 AM

Quote:

Originally Posted by Grimsin (Post 231849)
Line 8? local editbox = CreateFrame("EditBox", "MyAddOnEditBox", UIParent, "MyAddOnEditBoxTemplate")

"MyAddOnEditBoxTemplate" is not valid. EditBoxTemplate by itself may be though.

I have no immediate use for that EditBox so that can be deleted.

Grimsin 03-15-11 11:53 AM

Okay so after messing with it for a few... there are some problems. One is that what ever you did with the edit box stuff breaks the chat edit box.

remove the local editbox = this that and the other as well as these two lines
editbox:SetText("/bwlcb 5 Life Grip Shadow Inf Target")
ChatEdit_SendText(editbox)

i see what you are trying to do with that and its not done quite right.

Kenshone 03-15-11 12:00 PM

Quote:

Code:

eventsK = {
"ADDON_LOADED",
"PLAYER_ENTERING_WORLD",
"SO_ON_AND_SO_FORTH",
}


Hm, it'd be nifty if I could get the editbox to work...

But more importantly, event registration, does adding that chunk of code fix the Event Handling?


All times are GMT -6. The time now is 01:49 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI