Thread Tools Display Modes
04-05-09, 11:55 PM   #1
Mysticell
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 5
Question Non-working code, not sure where I went wrong, please review.

Hello, I've completed my addon, which does some very simple tasks of basically adding raid warnings for guilds, whispers, battlegrounds, etc. However, the slash commands are not working and when I manually send an addon message, it does not register the event and execute the script. I was hoping someone would be able to help me correct my code, which I have linked below.

http://antonidas.net/UIAnnounce.lua

Thanks,
Mysticell @ Antonidas
  Reply With Quote
04-06-09, 01:10 AM   #2
Aezay
A Theradrim Guardian
 
Aezay's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 66
GAnnounce_OnLoad is never called.

You should consider making all the functions local, there is no need for you to have them global.
  Reply With Quote
04-12-09, 12:10 PM   #3
Exawatt
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 36
Lines 106 - 150 need to be redone. Your if-then-else-end syntax is off (see Programming in Lua 4.3.1). Too many ends. Essentially you're ending the if statements before they encounter the else(if)s.

Try this instead:
Code:
if event == "CHAT_MSG_ADDON" then
  if prefix == "GAnnounce" then
    if channel == "GUILD" then
      UIErrorsFrame:AddMessage("[Guild Announcement]:  " .. text, 0.3, 1, 0)
      DEFAULT_CHAT_FRAME:AddMessage("[Guild Announcement] [" .. sender .. "]: " .. text, 0.3, 1, 0)

    elseif channel == "PARTY" then
      UIErrorsFrame:AddMessage("[Party Announcement]:  " .. text, 0.4, 0.5, 0.9)
      DEFAULT_CHAT_FRAME:AddMessage("[Party Announcement] [" .. sender .. "]: " .. text, 0.4, 0.5, 0.9)

    elseif channel == "RAID" then
      UIErrorsFrame:AddMessage("[Raid Announcement]:  " .. text, 1.0, 0.5, 0.0)
      DEFAULT_CHAT_FRAME:AddMessage("[Raid Announcement] [" .. sender .. "]: " .. text, 1.0, 0.5, 0.0)

    elseif channel == "BATTLEGROUND" then
      UIErrorsFrame:AddMessage("[Battleground Announcement]:  " .. text, 1.0, 0.5, 0.0)
      DEFAULT_CHAT_FRAME:AddMessage("[Battleground Announcement] [" .. sender .. "]: " .. text, 1.0, 0.5, 0.0)

    elseif channel == "WHISPER" then
      UIErrorsFrame:AddMessage("[" .. sender .. "]:  " .. text, 1.0, 0.0, 1.0)
      DEFAULT_CHAT_FRAME:AddMessage("[" .. sender .. "]:  " .. text, 1.0, 0.0, 1.0)
    end

  elseif prefix == "GAnnounceRW" then
    if channel == "GUILD" then
      RaidNotice_AddMessage(RaidWarningFrame, text, gcolor)
      DEFAULT_CHAT_FRAME:AddMessage("[Guild Announcement] [" .. sender .. "]: " .. text, 0.3, 1, 0)

    elseif channel == "BATTLEGROUND" then
      RaidNotice_AddMessage(RaidWarningFrame, text, bcolor)
      DEFAULT_CHAT_FRAME:AddMessage("[Battleground Announcement] [" .. sender .. "]: " .. text, 1.0, 0.5, 0.0)

    elseif channel == "WHISPER" then
      RaidNotice_AddMessage(RaidWarningFrame, text, wcolor)
      DEFAULT_CHAT_FRAME:AddMessage("[" .. sender .. "]:  " .. text, 1.0, 0.0, 1.0)
    end
  end
end
Here's what you had, properly indented:
Code:
if event == "CHAT_MSG_ADDON" then
  if prefix == "GAnnounce" then
    if channel == "GUILD" then
      UIErrorsFrame:AddMessage("[Guild Announcement]:  " .. text, 0.3, 1, 0)
      DEFAULT_CHAT_FRAME:AddMessage("[Guild Announcement] [" .. sender .. "]: " .. text, 0.3, 1, 0)
    end

  elseif channel == "PARTY" then
    UIErrorsFrame:AddMessage("[Party Announcement]:  " .. text, 0.4, 0.5, 0.9)
    DEFAULT_CHAT_FRAME:AddMessage("[Party Announcement] [" .. sender .. "]: " .. text, 0.4, 0.5, 0.9)
  end

elseif channel == "RAID" then
  UIErrorsFrame:AddMessage("[Raid Announcement]:  " .. text, 1.0, 0.5, 0.0)
  DEFAULT_CHAT_FRAME:AddMessage("[Raid Announcement] [" .. sender .. "]: " .. text, 1.0, 0.5, 0.0)
end

--ERROR: '<eof>' expected near 'elseif'

    elseif channel == "BATTLEGROUND" then --else(if) with no if!
See what's wrong?

Last edited by Exawatt : 04-12-09 at 12:18 PM. Reason: Show error in previous code
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Non-working code, not sure where I went wrong, please review.


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