View Single Post
Old 11-14-12, 03:46 PM   #5
gmarco
Premium Member
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 97
Hi,

It seems to works (almost) everything.

If I create a simple macro like this:

/mrc [btn:1] ground
/mrc [btn:2] flying
... etc etc ...

It works like expected ... button1 cast a ground mount, button2 cast a flying mount but I got an error in bugrabber.

Code:
MountRndCat-0.4\core.lua:11: bad argument #1 to "lower" (string expected, got nil)
<in C code>
MountRndCat-0.4\core.lua:11: in function "?"
FrameXML\ChatFrame.lua:4358: in function "ChatEdit_ParseText"
FrameXML\ChatFrame.lua:4052: in function "ChatEdit_SendText"
FrameXML\ChatFrame.lua:2727: in function <FrameXML\ChatFrame.lua:2720>
<in C code>
FrameXML\SecureTemplates.lua:275: in function "handler"
FrameXML\SecureTemplates.lua:560: in function <FrameXML\SecureTemplates.lua:508>
<in C code>
FrameXML\SecureHandlers.lua:264: in function <FrameXML\SecureHandlers.lua:261>
<in C code>
FrameXML\SecureHandlers.lua:294: in function <FrameXML\SecureHandlers.lua:277>
(tail call): ?

Locals:
args = "[btn:2] flying"
category = nil
The code is this one:

Code:
SLASH_MOUNTRNDCAT1 = "/mntrndcat";
SLASH_MOUNTRNDCAT2 = "/mrc";
SlashCmdList["MOUNTRNDCAT"] = function(args) 
	
	local category=SecureCmdOptionParse(args);
	category = string.lower(category)
	
	if (category == "" ) then 	
		
		print ("MountRandomCategory (mrc for friends)");
		print ("Usage: /mrc your_category\n");	
			
	else	
		
		if(IsMounted()) then
			Dismount();
		end	
		
		local number=random(1,#mounts[category]);
		local picked=mounts[category][number];
	
		print ("mrc is summoning for you: " .. "[" .. category .. "] " .. picked);
		
		-- Protected code
		-- CastSpellByName(mounts[category][number])
		
		-- Non protected code
		for index=1,GetNumCompanions("MOUNT") do
			local _,name=GetCompanionInfo("MOUNT",index);
			if name==picked then 
				CallCompanion("MOUNT",index);
			end
		end
		-- End non protected code
		
	end
	
end
Thanks for your attention.
gmarco is offline   Reply With Quote