Thread Tools Display Modes
08-21-10, 02:21 PM   #1
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Making a scale slider in XML

I'm attempting to make a scale slider for my AddOn with XML, right now my slider code is:

Code:
			<Slider name="$parent_sliderScale" inherits="OptionsSliderTemplate" 
					minValue="1" maxValue="100" defaultValue="100" 
					orientation="HORIZONTAL">
				<Size>
					<AbsDimension x="200" y="16"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT"
							relativeTo="$parent_buttonClamp"
							relativePoint="BOTTOMRIGHT">
						<Offset>
							<AbsDimension x="20" y="-60"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						getglobal(self:GetName().."High"):SetText("100");
						getglobal(self:GetName().."Low"):SetText("1");
						getglobal(self:GetName().."Text"):SetText("wMarker Scale");
					</OnLoad>
					<OnValueChanged>
						wMarker_scale(self);
					</OnValueChanged>
				</Scripts>
			</Slider>
and then my Lua is:

Code:
function wMarker_scale(self)
	local wMarkerDB.scale = self:GetValue()/100;
	wMarker_MainFrame:SetScale(wMarkerDB.scale);
end
While the slider looks to be perfect, any time I actually try to slide it my FPS drops like a rock. Also when I have my Lua code enabled (right now it's in comment brackets to disable it) my slash commands no longer work.

Does anyone know how I could go about creating a slider in XML that will scale my AddOn?

Thanks!
  Reply With Quote
08-21-10, 04:24 PM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
The 'local' in your lua function is wrong and will cause an error. You can't have local table entries in Lua, only the whole table can be local.
Just remove it and it should work fine.

Since each move of the slider calls the function and thus causes an error, my guess is that this huge amount of errors cause the huge FPS drop.
If you comment/disable the function, make sure to also remove "wMarker_scale(self);" from the <OnValueChanged>, otherwise Lua will cause an error because it doesn't find the function -> lots of errors, fps loss.

Well, concerning the slashcommands, we would need the complete code for them, but maybe fixing the local already solves the issue.

Aaaand make sure that you have Lua errors enabled, so you can see them!

Apart from that, I can't give you any tips on XML - I've always scripted my frames in Lua :O
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-21-10, 04:33 PM   #3
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Wow, that seems so obvious, I can't check right now but I edited my code. I'll check in a little bit, thanks for the help. Hopefully it works!
  Reply With Quote
08-21-10, 05:41 PM   #4
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
That was the problem exactly, thank you very much!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Making a scale slider in XML


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off