Sign in to follow this  

WOW Hello World lua help request - no XML

This topic is 3456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to make a basic Hello World mod for world of warcraft as my first attempt... I'm trying to stay away from XML as much as possible b/c my end goal doesn't involve graphical interface as much as it does control (maybe i'm mislead about XML and LUA purposes). I do not have an XML file and I'd like to avoid getting into graphics. Anyhow, here is my code that I cannot get to function properly in the game. I have run a few tests to verify that it is loaded, but when i use the slash command...i get nothin... Thanks in advance. function Hello_OnLoad() SLASH_hello1 = "/sendhello"; SlashCmdList["HELLO"] = Hello_Command; end function Hello_Command(cmd) SendChatMessage("Hello", SAY, COMMON, SAY); --verified that this works end

Share this post


Link to post
Share on other sites
I'm sure a lot of tutorials have been made and a lot of people have made code that you can look through. I do know this in a .lua file prints it: message("Hello World!");

I would guess your problem is that the function never gets called, where do you tell it to actually call the function? WoW comes with a hello world tutorial, it uses an .xml file to tell it to call the function when the game loads:

HelloWorld.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/
..\..\FrameXML\UI.xsd">
<Frame name="HelloWorldFrame">
<Scripts>
<OnLoad>
HelloWorld();
</OnLoad>
</Scripts>
</Frame>
</Ui>



HelloWorld.lua

function HelloWorld()
message("Hello World!");
end



and just include the 2 files in your .toc file.

Share this post


Link to post
Share on other sites
Basically if you want to avoid XML(which I recommend) you want to do something like this:


local helloaddon = CreateFrame("frame")
helloaddon:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
helloaddon:RegisterEvent("ADDON_LOADED")

function helloaddon:ADDON_LOADED(event, addon)
SlashCmdList.HELLOADDON = function(msg) self:OnSlash(msg) end
SLASH_HELLOADDON1 = "/helloaddon"
end

function helloaddon:OnSlash(msg)
DEFAULT_CHAT_FRAME:AddMessage("This is a test")
end




Drycoded but it should work.

Share this post


Link to post
Share on other sites
Quote:
Original post by phantom
Quote:
Original post by Milki
(maybe i'm mislead about XML and LUA purposes).


It's "Lua" not "LUA".

You have real issues with that, don't you? Something happened in your childhood? [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by WanMaster
Quote:
Original post by phantom
Quote:
Original post by Milki
(maybe i'm mislead about XML and LUA purposes).


It's "Lua" not "LUA".

You have real issues with that, don't you? Something happened in your childhood? [grin]


Its very irritating to read though. On occasion I've seen people post "JAVA" too. You shouldn't really use an acronym unless you know what it stands for. The acronym "LUA" already has a bunch of uses.

Its OK for languages like BASIC.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
Quote:
Original post by WanMaster
Quote:
Original post by phantom
Quote:
Original post by Milki
(maybe i'm mislead about XML and LUA purposes).


It's "Lua" not "LUA".

You have real issues with that, don't you? Something happened in your childhood? [grin]


Its very irritating to read though. On occasion I've seen people post "JAVA" too. You shouldn't really use an acronym unless you know what it stands for. The acronym "LUA" already has a bunch of uses.

Its OK for languages like BASIC.


It's not very constructive. If either of you had offered a solution to his question and added that as an aside it might have been alright.

Anyway Milki if that doesn't work post here again and I'll fire up WOW :) and test what I wrote above.

Share this post


Link to post
Share on other sites

This topic is 3456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this