Hi Boroda. First of all, what a wonderful plugin. Very useful.
Anyway, I tried to use the $Random function and I noticed that it generates a lot of duplicate numbers, so I took the liberty to look at your source code and found how you implemented that.
Your code looks like this
public string CustomFunc_Random(string max_number)
{
return (new Random()).Next(int.Parse(max_number) - 1).ToString("D" + (int)Math.Log10(float.Parse(max_number) + 0.5));
}
The problem with this is that a Random instance probably works by generating a seed from the current system tick counts or something like that, so if you do a "new Random()" you end up restarting the sequence until the tick count changes.
What I suggest is to store the Random instance in a static field and calling Next on it, like this
static readonly Random randomGen = new Random();
public string CustomFunc_Random(string max_number)
{
return randomGen.Next(int.Parse(max_number) - 1).ToString("D" + (int)Math.Log10(float.Parse(max_number) + 0.5));
}
This way the seed gets generated only once and the sequence behaves randomly.
Also I'm not sure why you do "-1" on the max number, because that makes the generator generate numbers between 0 and max_number-1, so if I put "10" in the function it goes from 0 to 8. Not sure that's what you want but maybe there's a reason I don't know.