Thread Tools Display Modes
11-11-08, 09:45 PM   #1
roggaro
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Nov 2008
Posts: 2
Question New into the whole Lua programming

i've just started playing with Lua Programming now, and making a addon for wow, but can't get it to work properly.

i have getting the box to work and the close button to hide the frame, BUT i can't get the code to work so i get the slashcommand to open the box again, someone that can help me figure it out?

here is the Lua coding:
Code:
function Followup_OnEscapePressed()
	Followup:Hide();
end

function Button1_OnClick()
	Followup:Hide();
end

function Followup_OnLoad()
	SlashCmdList["FOLLOWUP"] = FunctionToCall;
	SLASH_FOLLOWUP1 = "/followup";
	SLASH_FOLLOWUP2 = "/fu";
	end

	function Folloup_SlashCmdHandler()
	-- to do stuff
end
here is the xml coding if you need it:
Code:
<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="Followup" parent="UIParent" toplevel="true" movable="true" enableMouse="true">
		<Size>
			<AbsDimension x="284" y="301" />
		</Size>
		<Anchors>
			<Anchor point="TOPLEFT">
				<Offset>
					<AbsDimension x="268" y="-183" />
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnMouseDown>self:StartMoving();</OnMouseDown>
			<OnMouseUp>self:StopMovingOrSizing();</OnMouseUp>
			<OnEscapePressed>Frame1_OnEscapePressed();</OnEscapePressed>
			<OnTextSet>Frame1_OnTextSet();</OnTextSet>
		</Scripts>
		<Layers>
			<Layer>
				<FontString name="FontString1" inherits="GameFontNormalSmall" text="FollowUp">
					<Size x="100" y="20" />
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="92" y="-15" />
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<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>
			<Button name="Button1" inherits="UIPanelButtonTemplate" text="Close">
				<Size x="100" y="20" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="169" y="-266" />
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>Button1_OnClick();</OnClick>
				</Scripts>
			</Button>
		</Frames>
	</Frame>
	<OnLoad>
		AddonName_OnLoad();
	</OnLoad>

</Ui>
and yes, i have googled my ass off to find a solution
  Reply With Quote
11-11-08, 10:16 PM   #2
thenaz
A Murloc Raider
Join Date: Nov 2008
Posts: 4
This could help

This will enable slash commands and hide or show your frame

function Followup_Toggle()
if not Followup:IsVisible() then
Followup:Show();
else
Followup:Hide();
end
end

function Followup_OnLoad()
SlashCmdList["FOLLOWUP"] = function() Followup_Toggle() end;
end
SLASH_FOLLOWUP1 = "/followup";
SLASH_FOLLOWUP2 = "/fu";










This is for in you xml file


<OnLoad>
Followup_OnLoad();
</OnLoad>

Last edited by thenaz : 11-11-08 at 10:18 PM. Reason: Forgot to label
  Reply With Quote
11-11-08, 10:19 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by roggaro View Post
Code:
function Followup_OnLoad()
	SlashCmdList["FOLLOWUP"] = FunctionToCall;
	SLASH_FOLLOWUP1 = "/followup";
	SLASH_FOLLOWUP2 = "/fu";
	end

	function Folloup_SlashCmdHandler()
	-- to do stuff
end
First, FunctionToCall is supposed to be replaced with the name of your function that opens the frame and does stuff. The SlashCmdHandler() function needs code in it to do stuff, and it needs to exist before you want to assign it to the slash commands.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-11-08, 10:37 PM   #4
roggaro
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Nov 2008
Posts: 2
Originally Posted by thenaz View Post
This will enable slash commands and hide or show your frame

function Followup_Toggle()
if not Followup:IsVisible() then
Followup:Show();
else
Followup:Hide();
end
end

function Followup_OnLoad()
SlashCmdList["FOLLOWUP"] = function() Followup_Toggle() end;
end
SLASH_FOLLOWUP1 = "/followup";
SLASH_FOLLOWUP2 = "/fu";










This is for in you xml file


<OnLoad>
Followup_OnLoad();
</OnLoad>
SLASH_FOLLOWUP2 = "/fu";
don't you need to end?

anyway, thank you for the help, i will test it when the servers are up again, or is it a possibility to test the addon without starting wow?
  Reply With Quote
11-12-08, 01:44 AM   #5
thenaz
A Murloc Raider
Join Date: Nov 2008
Posts: 4
Nope I use that code as is and works everytime. You can use an Lua editor to check the lua code but I dont know any way to actually test the addon out of wow.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » New into the whole Lua programming


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