Advertisement
crabb

Untitled

Aug 15th, 2020
1,361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. -- wandom
  2. -- > suwacrab
  3.  
  4. local rand_index = 0
  5. local rand_lut = {}
  6. for i = 0,1023 do rand_lut[i] = 1 - (math.random()*2) end
  7.  
  8. local rand = function() -- returns float between 0 and 1
  9.  rand_index = (rand_index+1)%1024
  10.  return rand_lut[rand_index]
  11. end
  12.  
  13. local rand_float = function(a,b) -- returns float between a and b
  14.  local n = a + (b - a) * rand()
  15.  return n
  16. end
  17.  
  18. local rand_int = function(a,b) -- returns integer between a and b
  19.  return math.floor( rand_float(a,b) )
  20. end
  21.  
  22. return {
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement