06-08-05, 04:19 PM | #1 |
What am I missing?
OK. I am trying to make a configurable texture in game.
When I paint this frame: Code:
<Frame name="DiivSkins_Hbar1" frameStrata="BACKGROUND" inherits="DiivSkins_hbarTemplate" parent="UIParent"> <Size> <AbsDimension x="512" y="46"/> </Size> <Layers> <Layer level="ARTWORK"> <Texture name="DiivSkins_hbar1Texture" file="Interface\AddOns\DiivSkins\Skins\diivskins_01"> <TexCoords left="0.0019531" right="1.0" top="0.0" bottom="0.0898437"/> </Texture> </Layer> </Layers> <Anchors> <Anchor point="BOTTOM"> <Offset> <AbsDimension x="215" y="550"/> </Offset> </Anchor> </Anchors> </Frame> Now, I set up the following lua functions to alter that texture via a slider, and (hopefully) save it across sessions (most of this is hacked up and taken from the SquidMod code): Code:
function DS_OnLoad() DiivSkins_LoadVariables(); this:RegisterEvent("VARIABLES_LOADED"); end function DiivSkins_LoadVariables() if not DiivSkinSettings then DiivSkinSettings = { }; end end function DS_OnEvent() if event=="VARIABLES_LOADED" then if not DS_UsedBefore then -- do one-time stuff for first use here -- display the primary game menu without a keypress GameMenuFrame:Show(); -- display an attatched text frame to this menu DS_Init:Show(); -- Swap in the placeholder DiivSkins button on the game menu DS_GameMenuButton:Hide(); DS_GameMenuButton_Init:Show(); --register the variable as true, so the above never happens again. DS_UsedBefore = true --update my slider variables else if not (DiivSkinSettings) then DiivSkinSettings.hbar1 = {} end end end function DiivSkins_hbar1Update() if(DiivSkinsSettings) then elseif(DiivSkinSettings.hbar1 == 2) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.8984375, 0.9882812); elseif(DiivSkinSettings.hbar1 == 3) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.8085937, 0.8984375); elseif(DiivSkinSettings.hbar1 == 4) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.71875, 0.8085937); elseif(DiivSkinSettings.hbar1 == 5) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.6289062, 0.71875); elseif(DiivSkinSettings.hbar1 == 6) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.5390625, 0.6289062); elseif(DiivSkinSettings.hbar1 == 7) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.4492187, 0.5390625); elseif(DiivSkinSettings.hbar1 == 8) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.359375, 0.4492187); elseif(DiivSkinSettings.hbar1 == 9) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.2695312, 0.359375); elseif(DiivSkinSettings.hbar1 == 10) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.1796875, 0.2695312); elseif(DiivSkinSettings.hbar1 == 11) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.0898437, 0.1796875); elseif(DiivSkinSettings.hbar1 == 12) then DiivSkins_hbar1Texture:SetTexCoord(0.0, 1.0, 0.0, 0.0898437); end end end Code:
<Slider name="DiivSkins_hbar1Slider" inherits="OptionsSliderTemplate"> <Size> <AbsDimension x="160" y="17"/> </Size> <Anchors> <Anchor point="CENTER"/> </Anchors> <Scripts> <OnLoad> getglobal(this:GetName().."Text"):SetText("Horizontal Bar 1"); getglobal(this:GetName().."High"):SetText("12 slots"); getglobal(this:GetName().."Low"):SetText("2 slot"); this:SetMinMaxValues(2, 12); this:SetValueStep(1); </OnLoad> <OnShow> if (DiivSkinSettings.hbar1) then this:SetValue(DiivSkinSettings.hbar1); end </OnShow> <OnValueChanged> DiivSkinSettings.hbar1 = this:GetValue(); DiivSkins_hbar1Update(); </OnValueChanged> </Scripts> </Slider> Now, here's where it gets odd. Here's another image: CLICKY (for reference) The variable, DiivSkinSettings.hbar, is saved in my savedvariables, and it does save the textCoord's of whatever the slider was last on, but It only refreshes them after I open up that page of my configuration doohickey. Until that point, the full 12 slot bar is displayed. After the config page is opened and then closed, the correct "slot" confguration will persist. The above code produces no errors, but has the mentioned issues. I tried just about everything I could think of to check for the value of the slider, but nothing worked. Almost every variant produced errors mostly pointing at the "DiivSkins_hbar1Update()" function. Either the reference in the slider XML was "referencing a nil value", or the lua broke alltogether, disabling all the other functions for buttons toggles and such that are present in the lua. This include trying to call the Update function from anywhere other than the <OnShow> in the slider XML. From there, its fine. Anywhere else, I get "an attempt to call a nil value" or it flat out tells me the function is broken. I hope I explained that well enough. I'm sure I'm making some pretty elementary mistakes, but I feel like I'm getting close anyway. Any help? |
|
WoWInterface » Developer Discussions » Lua/XML Help » What am I missing? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|