If you're saying you want to implement macro option parsing for your addon, you can use SecureCmdOptionParse() for this.

Code:

SlashCmdList["MOUNTRNDCAT"] = function(args)
local category=SecureCmdOptionParse(args);
if not category then return; end
category=category:lower();
if category=="" then
print("MountRandomCategory v.0.2");
print("Usage: /mrc category");
elseif mounts[category] then
if IsMounted() then
Dismount();
end
local number=random(1,#mounts[category]);
local picked=mounts[category][number]:lower();
print("casting ...",picked);
for index=1,GetNumCompanions("MOUNT") do
local _,name=GetCompanionInfo("MOUNT",index);
if name:lower()==picked then
CallCompanion("MOUNT",index);
end
end
else
print("MountRandomCategory v.0.2");
print("Unable to find category",category);
end
end

I've corrected a few issues, mainly values leaking out into the global namespace that didn't need to be out there. This is controlled by using the local keyword when defining a variable for the first time. I also had the random mount name cached so the CPU wouldn't be used up so much with repetitive indexing of the mounts table.

On a side note, the usage of the underscore as a variable has no special meaning. It's just another valid variable name and is often used as such to shove unwanted values into to fetch values further down the list.

__________________

"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."

I fixed the code I posted earlier. It appears when none of the conditions match for SecureCmdOptionParse(), it returns nil. At this point, the command should not be run. I added the check for this and have it exit immediately. I also fixed a potential error if the user were to call for a category that doesn't exist. The code is also more robust in the way that both the names in the table and the category name given through the arguments are case-insensitive.

__________________

"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."

Then the two lines highlighted in yellow will both run when you left-click. This is expected. Each slash command is separate, and calls its handler function separately, so the condition provided with each is evaluated independently of any other slash commands the macro may be calling before or after the current one.

If you want everything to be evaluated at the same time, you need to change it to only one slash command, so that all of the arguments are passed to the handler function at the same time:

Code:

/mrc [btn:2] flying; [btn:3] repair; [mod:shift] funny; ground

This is just like writing a "real" macro. If you wrote this "real" macro: