Wow. I didn't expect it to be this easy to create a cFastRandom class for Lua:
local cFastRandom_SeedCounter = 0 function cFastRandom() local self = {} local m_Counter = 0 local m_Seed = cFastRandom_SeedCounter cFastRandom_SeedCounter = cFastRandom_SeedCounter + 1 function self:NextNumber(a_Range) assert(type(a_Range) == "number") assert(a_Range <= 1000000) assert(a_Range > 0) Counter = m_Counter m_Counter = m_Counter + 1 local n = a_Range + Counter * 57 + m_Seed * 57 * 57; n = ((n * (n * n * 15731 + 789221) + 1376312589)) return ((n / 11) % a_Range); end return self end