math.random function in lua to position object

S Khurana
shape:setY(math.random(0, 450 - 50))

math.random function with a minimum and a maximum value is what I understand but what exactly is the meaning of using arithmetic operator in mat.random function, say in above LOC, why is it 450 - 50 and not 400? what is the difference?

similarly,

self:setPosition(540, math.random(160) + 40)
user308323

There is no difference. It is equivalent to shape:setY(math.random(0, 400)).

The second line of code is equivalent to the following:

self:setPosition(540, math.random(1, 160) + 40)

It is most certainly intended to be a clearer and/or simpler way of writing

self:setPosition(540, math.random(41, 200))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Is a function that calls Math.random() pure?

From Dev

Lua math.random not working

From Dev

Lua newbie: Alternate (Knuth) pseudo-random function performance?

From Dev

"interval is empty", Lua math.random isn't working for large numbers?

From Dev

math.random function with step option?

From Dev

Spawn an instance of a library object at a random X position in the stage

From Dev

math.random function in lua to position object

From Dev

Lua - math.random () isn't working

From Dev

Math.random() javascript function *undefined* on Chrome

From Dev

How to shuffle cards within a Card object with Math.random()

From Dev

Lua math.random returns erratic values

From Dev

Is it possible for Math.random() === Math.random()

From Dev

Lua Math.random and if statement

From Dev

javascript TypeError: Math.random is not a function on chrome

From Dev

Redis Lua Script math.random

From Dev

Difference between math.random() and math.randomseed() in Lua

From Dev

Creating an object of Random class or using Math.random() in order to generate random numbers

From Dev

Javascript Math.random() not *that* random…?

From Dev

Lua newbie: Alternate (Knuth) pseudo-random function performance?

From Dev

Animation function stops at random position

From Dev

math.random function with step option?

From Dev

how to create a java function that makes random math problems.

From Dev

Lua development math.sin function and ball moving across the rod

From Dev

Why does Math.floor(Math.random()) function always return "0"?

From Dev

How reliable is it to pick an array position with math floor and random?

From Dev

Math.Random in function always the same result

From Dev

how to find the appropriate math function for series with random numbers in Excel

From Dev

Why Math.random() type is number and Math.random is function?

From Dev

Math.random/floor with a function and onclick?

Related Related

  1. 1

    Is a function that calls Math.random() pure?

  2. 2

    Lua math.random not working

  3. 3

    Lua newbie: Alternate (Knuth) pseudo-random function performance?

  4. 4

    "interval is empty", Lua math.random isn't working for large numbers?

  5. 5

    math.random function with step option?

  6. 6

    Spawn an instance of a library object at a random X position in the stage

  7. 7

    math.random function in lua to position object

  8. 8

    Lua - math.random () isn't working

  9. 9

    Math.random() javascript function *undefined* on Chrome

  10. 10

    How to shuffle cards within a Card object with Math.random()

  11. 11

    Lua math.random returns erratic values

  12. 12

    Is it possible for Math.random() === Math.random()

  13. 13

    Lua Math.random and if statement

  14. 14

    javascript TypeError: Math.random is not a function on chrome

  15. 15

    Redis Lua Script math.random

  16. 16

    Difference between math.random() and math.randomseed() in Lua

  17. 17

    Creating an object of Random class or using Math.random() in order to generate random numbers

  18. 18

    Javascript Math.random() not *that* random…?

  19. 19

    Lua newbie: Alternate (Knuth) pseudo-random function performance?

  20. 20

    Animation function stops at random position

  21. 21

    math.random function with step option?

  22. 22

    how to create a java function that makes random math problems.

  23. 23

    Lua development math.sin function and ball moving across the rod

  24. 24

    Why does Math.floor(Math.random()) function always return "0"?

  25. 25

    How reliable is it to pick an array position with math floor and random?

  26. 26

    Math.Random in function always the same result

  27. 27

    how to find the appropriate math function for series with random numbers in Excel

  28. 28

    Why Math.random() type is number and Math.random is function?

  29. 29

    Math.random/floor with a function and onclick?

HotTag

Archive