View Single Post
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