|
| 10 Nov 2015 03:46 AM |
Because I figure someone else might get annoyed at having to make a new bool-randoming function all the time. require(318720512):Install(getfenv()) |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 04:55 AM |
| 1==math.random(1,2) and true or false |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:09 AM |
| true or false always returns true and math.random(1,2)==1 is what the module uses |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:13 AM |
| But it doesn't always return true if you run it 5 times, it i bound to say false at least twice out of the five. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:16 AM |
for i=1, 100 do print(true or false) end
all of them are true |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:19 AM |
No duh, because true is always the first to be valid in that statement....
for i=1, 100 do print(false or true) end
Always prints true also. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:19 AM |
| That has nothing to do with the method math.random. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:21 AM |
| why'd you put 'and true or false' then |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 05:23 AM |
1==math.random(1,2) and true or false
is the same as saying:
if 1==math.random(1,2) then return true else return false end |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 06:29 AM |
| == is a comparison operator and it returns a bool, so what Darth is saying is that 'and true or false' is unnecessary because == does that for you. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 06:35 AM |
| But it doesn't because it is a comparison to two instances which are "randomized". Look at what he said vs what I said, he was not comparing two random values, he was comparing two given values. There in-lies the difference. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 06:44 AM |
| I wish clockwork were here to straighten this out, like the old days |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 06:47 AM |
I prefer this for generating random numbers:
http://www.roblox.com/Random-org-generator-item?id=318598398
http://www.roblox.com/Lots-item?id=307049082http://www.roblox.com/Of-item?id=307039670http://www.roblox.com/Violence-item?id=307039720 http://www.roblox.com/Undertale-OST-Megalovania-item?id=301636384 | You're going to have a bad time. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 09:01 AM |
| Clockwork shall be missed dearly. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Nov 2015 02:36 PM |
"1==math.random(1,2) and true or false" Well first off you should know that it's left-right associative, that line is equiv. to this:
(1==math.random(1,2) and true) or false
If the condition does not fall through (1 is not equal to the random number) then you get false. "false and true" is false. 'and' returns the second operand given the first one is truey, and or returns the first operand given it's truey, else returns the second.
But that whole part is overdoing it, because the equivalence operator already returns a boolean, thus "1 == math.random(1,2)" is enough. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2015 02:47 PM |
This is a bit silly, isn't it? Go learn your relational operands. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Nov 2015 02:50 PM |
| go to hell veer, you sat addict |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Nov 2015 03:21 PM |
^That will return more true than false. Use this: math.random() >= 0.5
Example:
if math.random() >= 0.5 then print("true") else print("false") end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|