semlar gave you the best way but if you still wanted to see your original method shrunk a bit for educational purposes:
Code:
/run local f,p=IsFlyableArea(),"MOUNT"
for i=1,GetNumCompanions(p) do
local _,v=GetCompanionInfo(p,i)
if f and v=="Obsidian Nightwing" or v=="Vicious Skeletal Warhorse" then
CallCompanion(p,i)
end
end