help getting info panel plugin to work
I am trying to learn how to do some very basic lua coding. I successfully got one plugin to work(Anymeter= I am still testing it but it seems to work good).
I copied and modified a layout.lua file for my LDB display. It shows my info blocks and does not have any errors. If I create a frame like this. local cp = CreateFrame("Frame","cp_frame") cp:SetFrameStrata("BACKGROUND") cp:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0) cp:SetWidth(900) cp:SetHeight(15) cp:SetScale(1.2) cp:SetBackdropColor(0, 0, 0) cp:SetClampedToScreen(true) cp:EnableMouse(true) cp:Show() Now the problem. When I modify my nUI InfoPanel Plugin.lua code to try and re parent the frame to the info panel it gives an error. Attempt to index global cp_frame (a nil value). Both lua files run fron the same folder\TOC layout.lua plugin.lua My plugin.lua relevent sections plugin.setEnabled = function( enabled ) if plugin.enabled ~= enabled then plugin.enabled = enabled; cp_frame:ClearAllPoints (); cp_frame:SetPoint ("TOPLEFT", plugin.container, "TOPLEFT", 0, 0); end end ------------------------------------------------------------------------------- plugin.setSelected = function( selected ) if selected ~= plugin.selected then plugin.selected = selected; if selected then cp_frame:Show (); else cp_frame:Hide (); end end end I hope I have given enough info here if not just ask. Thanks for trying to help me understand lua. |
If it is all in the same file, then you can use the local variable "cp" instead of the global "cp_frame"
If the frame is being created in one file and accessed in another, you can access it like this... local cp_frame = _G["cp_frame"]; which looks in the global table for the global variable named "cp_frame" |
This got me a little farther
I have been reading wowwiki and looking through other addons. I am still having trouble with this thing.
I get an error saying show is a nil value when the addon creates the panel or when I hit the button and the panel changes I get a hide is a nil value. So it seems to be close. Thank You for your help and patience. |
Why don't you post the code you have at present as an attachment in this thread, then we can look at the code and see where you're going wrong.
|
ok here is the layout and infopanel is in attachment
1 Attachment(s)
layout lua
-- Create the Frame local cp = CreateFrame("Frame","CargoPanel_Frame"); cp:SetPoint("CENTER",UIParent,"CENTER",0,0); cp:SetWidth(250); cp:SetHeight(25); cp:SetAlpha(1.0); local rep = cargoShip("|cffffb366Ara|r Reputations") rep:SetPoint("TOPRIGHT", CargoPanel_Frame, "TOPRIGHT", 0, 0) I get my layout without an issue. I get it to be moved to the infopanel. I get an error message when it trys to show the panel. .UI_InfoPanel_CargoPanel\nUI_InfoPanel_CargoPanel.lua:137: attempt to call method 'show' (a nil value) Thank You again |
Ah, you need to redefine CargoPanel_Frame in each function you want to access it in as they are local to the function unless you set it outside the function.
Code:
plugin.setSelected = function( selected ) |
Thank You. It is now working
1 Attachment(s)
Here is a SS of the infopanel in action. I have moved a few items out of Fortress and into my new LDB display info panel.
I am learning and thanks again for the help. |
All times are GMT -6. The time now is 12:41 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI