random.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. return {
  2. tag = 'random',
  3. summary = 'Get a random number.',
  4. description = [[
  5. Returns a uniformly distributed pseudo-random number. This function has improved randomness
  6. over Lua's `math.random` and also guarantees that the sequence of random numbers will be the
  7. same on all platforms (given the same seed).
  8. ]],
  9. arguments = {
  10. low = {
  11. type = 'number',
  12. description = 'The minimum number to generate.'
  13. },
  14. high = {
  15. type = 'number',
  16. description = 'The maximum number to generate.'
  17. }
  18. },
  19. returns = {
  20. x = {
  21. type = 'number',
  22. description = 'A pseudo-random number.'
  23. }
  24. },
  25. variants = {
  26. {
  27. description = 'Generate a pseudo-random floating point number in the range `[0,1)`',
  28. arguments = {},
  29. returns = { 'x' }
  30. },
  31. {
  32. description = 'Generate a pseudo-random integer in the range `[1,high]`',
  33. arguments = { 'high' },
  34. returns = { 'x' }
  35. },
  36. {
  37. description = 'Generate a pseudo-random integer in the range `[low,high]`',
  38. arguments = { 'low', 'high' },
  39. returns = { 'x' }
  40. }
  41. },
  42. notes = 'You can set the random seed using `lovr.math.setRandomSeed`.',
  43. related = {
  44. 'lovr.math.randomNormal',
  45. 'RandomGenerator',
  46. 'lovr.math.noise'
  47. }
  48. }