Thread: random()
View Single Post
06-06-13, 03:08 PM   #7
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Originally Posted by p3lim View Post
Nope, that's the point of the function, it's random, and still unlikely you might get the same number over and over again.

Mind if I ask what you need this for?
A little addon that summon a random mount.
The problem is that I press the key and summon mount A, I don't want it and repress A (got same mount :-), again ... again until it changes :-) Ok, it is intended to be random, but what I'd like to remove is the effect to have a lot of times the same number picked ...

The relevant part of code is this:
Lua Code:
  1. local number=random(1,#MyCatMount_mrc[category]);
  2.         local picked=MyCatMount_mrc[category][number]:lower();
  3.         local msg=prgname .. " error: unable to summon \"" .. picked .. "\" from \"" .. category .. "\" category.";
  4.        
  5.         for index=1,GetNumCompanions("MOUNT") do
  6.             local _,name=GetCompanionInfo("MOUNT",index);
  7.             if name:lower()==picked then
  8.                 msg = prgname .. " is summoning... " .. picked;
  9.                 CallCompanion("MOUNT",index);
  10.                 break;
  11.             end
  12.         end

Thanks for your answer anyway.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote