Thread Tools Display Modes
01-18-05, 03:23 PM   #1
Eilina
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 4
OnLoad script error (Please help!)

Ok.. I'm writing a script that does a few things when a player/pet enters combat. I've fleshed out the whole .lua/.xml/.toc files, and went to load it for the first time. Here's the error that I get in WoW when the script loads.

Code:
String: Interface\AddOns\BarSwitch\BarSwitch.lua
Line: 14
Count: 1
Error: `=' expected near `BarSwitch_OnLoad'
--------------------------------------------------
String: Frame_BarSwitch:OnLoad
Line: 2
Count: 1
Error: attempt to call global `BarSwitch_OnLoad' (a nil value)
Here's the offending code in the .lua starting at line 14.

Code:
fuction BarSwitch_OnLoad()

	-- Registers Events
	this:RegisterEvent("VARIABLES_LOADED");
	this:RegisterEvent("PLAYER_REGEN_DISABLED");
	this:RegisterEvent("PLAYER_REGEN_ENABLED");
	this:RegisterEvent("PET_ATTACK_START");
	this:RegisterEvent("CHAT_MSG_SYSTEM");
	
	-- Registers Slash Commands
	SLASH_BarSwitch1 = "/BarSwitch";
	SLASH_BarSwitch2 = "/bs";
	SlashCmdList["BarSwitch"] = function(msg)
		BarSwitch_ChatCommandHandler(msg);
	end
	
	ChatMessage("BarSwitch v1.0 by Eilina Loaded");
	
end
and now the .xml file.

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:ProjectsWoWBinInterfaceFrameXMLUI.xsd">
	<Script file="BarSwitch.lua"/>
	<Frame name="Frame_BarSwitch" hidden="true">
		<Scripts>
			<OnLoad>
				BarSwitch_OnLoad();
			</OnLoad>
			<OnEvent>
				BarSwitch_OnEvent(event, arg1);
			</OnEvent>
		</Scripts>
	</Frame>
</Ui>
I'm assuming the error generated from the xml file is because of the error in the lua file, and will go away once the lua is fixed. I however cannot see an error in the lua file to save my life. Any ideas what could be wrong?
  Reply With Quote
01-18-05, 03:28 PM   #2
Freki
A Deviate Faerie Dragon
 
Freki's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 18
fuction BarSwitch_OnLoad()
"fuction" should be "function"
  Reply With Quote
01-18-05, 03:31 PM   #3
Eilina
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 4
DOH! Damn.. I guess looking at it for too long made me miss a stupid spelling error.. Guess I just needed a pair of fresh eyes. Heh. Thanks a bunch.

*bonks self for stupidity*
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » OnLoad script error (Please help!)

Thread Tools
Display Modes

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