Thread Tools Display Modes
07-29-13, 05:24 AM   #1
Wolfind
A Defias Bandit
Join Date: Jul 2013
Posts: 2
Help with SavedVariables

hello everyone, I'm new in this fantastic world, I begin to apologize for my bad English (not English). I hope you can make me clarity on the global variables...I've read various things but I did not understand very well . I created this little addon for fun, I'd like a button that saves the text in the editbox and the other button sends message with text saved even after reload or relog. Thanks for the help!

My .toc:

Code:
## Title: SaveVar
## Version: 1.0
## Author: Prova
## Interface: 50300

Frame.xml
My .lua:

Code:
local SaveMex

function Save_OnClick()
	SaveMex=EdTex:GetText();
end

function Send_OnClick()
	SendChatMessage(SaveMex, "SAY");
end
My .xml:

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="Frame1" parent="UIParent" toplevel="true" movable="true" enableMouse="true">
		<Size x="200" y="200" />
		<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>
			<EditBox name="EdTex" inherits="InputBoxTemplate" enableKeyboard="true" autoFocus="false">
				<Size x="100" y="32" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="45" y="-48" />
					</Anchor>
				</Anchors>
			</EditBox>
			<Button name="Send" inherits="UIPanelButtonTemplate" enableMouse="true" text="Send">
				<Size x="75" y="23" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="108" y="-118" />
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						Send_OnClick()
					</OnClick>
				</Scripts>
			</Button>
			<Button name="Save" inherits="UIPanelButtonTemplate" text="Save">
				<Size x="75" y="23" />
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset x="23" y="-118" />
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						Save_OnClick()
					</OnClick>
				</Scripts>
			</Button>
		</Frames>
		<Scripts>
			<OnLoad>
				self:RegisterForDrag("LeftButton");
			</OnLoad>
			<OnDragStart>
				self:StartMoving();
			</OnDragStart>
			<OnDragStop>
				self:StopMovingOrSizing();
			</OnDragStop>
		</Scripts>
	</Frame>
</Ui>
  Reply With Quote
07-29-13, 07:17 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Assuming you have "Show Lua Errors" checked in game options and your code runs without error.

Saving your message to saved variables so it remains after a logout is as simple as adding this to your .toc file.

## SavedVariablesPerCharacter: SaveMex

and removing this line from your .lua

local SaveMex

This page has more information about the TOC Format.
  Reply With Quote
07-29-13, 09:06 AM   #3
Wolfind
A Defias Bandit
Join Date: Jul 2013
Posts: 2
ooooh i'm a very noob...it was too easy that I have not imagined! Thank you very much for reply...now i'm happy!!!!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Help with SavedVariables


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