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 Dev

math.random function in lua to position object

From Dev

Lua math.random not working

From Dev

Lua Math.random and if statement

From Dev

Lua math.random returns erratic values

From Dev

Redis Lua Script math.random

From Dev

Lua - math.random () isn't working

From Dev

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

From Dev

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

From Dev

Animation function stops at random position

From Dev

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

From Java

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

From Dev

math.random function with step option?

From Dev

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

From Dev

math.random function with step option?

From Dev

Math.Random in function always the same result

From Dev

Math.random/floor with a function and onclick?

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

Related Related

  1. 1

    math.random function in lua to position object

  2. 2

    Lua math.random not working

  3. 3

    Lua Math.random and if statement

  4. 4

    Lua math.random returns erratic values

  5. 5

    Redis Lua Script math.random

  6. 6

    Lua - math.random () isn't working

  7. 7

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

  8. 8

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

  9. 9

    Animation function stops at random position

  10. 10

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

  11. 11

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

  12. 12

    math.random function with step option?

  13. 13

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

  14. 14

    math.random function with step option?

  15. 15

    Math.Random in function always the same result

  16. 16

    Math.random/floor with a function and onclick?

  17. 17

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

  18. 18

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

  19. 19

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

  20. 20

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

  21. 21

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

  22. 22

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

  23. 23

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

  24. 24

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

  25. 25

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

  26. 26

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

  27. 27

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

  28. 28

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

  29. 29

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

HotTag

Archive