-
Posted by storkbite on Fri, 10 Jul 2009 22:27:02
Hello!
I have tried for a couple of days to figure out my error, but cannot. All I want to do is populate a PlayerModel with the player character. I'd appreciate any pointers in the right direction.
This is what I've done. It fails at 'PlayerModel1:SetUnit("player");':
frame.lua
function myFrame_OnLoad(self) self:RegisterEvent("UNIT_MODEL_CHANGED"); end function myFrame_OnEvent(self, event, ...) local unit = ...; if ( event == "UNIT_MODEL_CHANGED" and unit == "player" ) then myPlayerModel_Update(); return; end end function myPlayerModel_Update() -- Message: Attempt to call method 'SetUnit'(a nil value) PlayerModel1:SetUnit("player"); end
frame.xml
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/"> <Script file="Frame.lua" /> <Frame name="Frame1" parent="UIParent" toplevel="true" enableMouse="true"> <Size> <AbsDimension x="200" y="200" /> </Size> <Anchors> <Anchor point="CENTER" /> </Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> </BackgroundInsets> <TileSize> <AbsValue val="32" /> </TileSize> <EdgeSize> <AbsValue val="32" /> </EdgeSize> </Backdrop> <Frames> <Model xsi:type="PlayerModel" name="PlayerModel1"> <Size> <AbsDimension x="157" y="155" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="22" y="-24" /> </Anchor> </Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> </BackgroundInsets> <TileSize> <AbsValue val="32" /> </TileSize> <EdgeSize> <AbsValue val="32" /> </EdgeSize> </Backdrop> </Model> </Frames> <Scripts> <OnLoad>myFrame_OnLoad(self)</OnLoad> <OnEvent>myFrame_OnEvent(self, event, ...)</OnEvent> </Scripts> </Frame> </Ui>
-
Posted by jnwhiteh on Sat, 11 Jul 2009 22:57:14
You are creating a model and using xsi:type="PlayerModel". That's not how you instantiate a PlayerModel. Use the
<PlayerModel>
tag in order to accomplish this, instead of<Model>
. -
Posted by storkbite on Sun, 12 Jul 2009 15:48:18
Thank you, James. That was indeed the problem and the correction that you listed worked perfectly.
The syntax that I used was generated automatically using AddOn Studio. Even after I made the correction, it changed the correction back to its original syntax once I hit the save button. So, I opted to make the change in Notepad instead and bypass AddoOn Studio.
I just became interested in WOW programming and ordered your book after finding this website. I look forward to its arrival. Thanks again for sharing your talents with me and the community-at-large.
-
Posted by jnwhiteh on Mon, 13 Jul 2009 02:52:33
Glad I could help, please let me know if I can be of further assistance.