WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Learning LUA (https://www.wowinterface.com/forums/showthread.php?t=3892)

Mr_Vonhelding 02-28-06 12:23 PM

Learning LUA
 
Im trying to get into the addon game so to speak.

For starters im skipping the interface design. It jsut takes more brain power than i have to devote right now to go through reams and ream and reams of code that si far to similar to html tables than I like.

What I would like to do for a starter. To get my feet wet. Is take some macros I made up in game that i use alot and turn them into / commands via an addon.

So lets take something real simple

/say Stop laying down on the job %T
/cast Ressurection(Rank 1)

This obviously says the line then casts ressurection on my target.

So what I'd like to do is turn something like this into a / command

For example

/rt

and Poof it access the lua which in turns sends the message and then rezes my current target.

Ive got some basic Idea. But Im wondering if anyone can provide a little lesson or a link to a tutorial that might detail how to go about this?

Thank in advance

JoshBorke 02-28-06 12:27 PM

http://www.wowwiki.com/Interface_Customization

Has a tutorial section where you should start because you really should create a xml file if only to hold a single frame.

http://www.wowwiki.com/Category:HOWTOs

Should show you how to add a slash command.

HTH

Mr_Vonhelding 02-28-06 12:47 PM

Just curious why would I want a frame if my first intention is only to put these macros into slash commands?

JoshBorke 02-28-06 01:00 PM

ah, it's my mistake (still a newb :]). You need the XML if you want to listen to events. But for just slash commands, you can dispense with the XML and go straight to LUA.

Mr_Vonhelding 02-28-06 07:04 PM

Well its not working

heres what I have so far

myaddon.toc
## Interface: 1800
## Title: My Addon
## Notes: Testing Slash Commands
myaddon.xml

myaddon.xml
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">
<!-- Load Script file -->
<Script file="myaddon.lua"/>
<Frame name="myaddon">
<Scripts>
<OnLoad>
myaddon_OnLoad();
SLASH_MYADDON1 = "/myaddonmessage";
SLASH_MYADDON2 = "/mam";
SlashCmdList["MYADDON"] = myaddon_message();
</OnLoad>
</Scripts>
</Frame>

</Ui>

myaddon.lua
function myaddon_OnLoad()
message("My Addon Loaded!");
end

function myaddon_message()
message("Yay! It Works!");
end

And problem is when i type /myaddonmessage or /mam I get the type /help for a list of commands message
So its not loading or creating my slash command list.

What I see is
My Addon Loaded!
Yay! It Works!

as soon as I log in. so its like both events are firing and the list isnt being generated.

Can someone advise?
Please?

JoshBorke 03-01-06 07:48 AM

Code:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">
<!-- Load Script file -->
<Script file="myaddon.lua"/>
<Frame name="myaddon">
<Scripts>
<OnLoad>
myaddon_OnLoad();
</OnLoad>
</Scripts>
</Frame>

</Ui>

myaddon.lua
Code:

function myaddon_OnLoad()
SLASH_MYADDON1 = "/myaddonmessage";
SLASH_MYADDON2 = "/mam";
SlashCmdList["MYADDON"] = myaddon_message;
message("My Addon Loaded!");
end

function myaddon_message()
message("Yay! It Works!");
end

try that


All times are GMT -6. The time now is 02:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI