generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Triple random

Previous Thread :: Next Thread 
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:24 PM
I got seriously bored and made this. xD It takes in 2 numbers and makes random numbers in-between them, then randomizes those. (Probably less random than math.random(), but still, I got bored, so it must be great) *Lol?*

function Bigger(a, b) if a > b then return a else return b end end;
function Smaller(a, b) if a > b then return b else return a end end;
function _G.TrippleRandom(last, last2)
big = Bigger(last, last2)
small = Smaller(last, last2)
while big ~= small do
a = math.random(1, 2)
b = math.random(small, big)
if a == 1 then
big = b
else
small = b
end
print("Small: "..small..". Big: "..big..".")
end
if last ~= last2 then
print("Last: "..last..". Before that: "..last2..".")
last2 = last
last = big
math.random2(last, last2)
else
print("The number is: "..last)
end
return last
end;
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
08 Feb 2010 04:26 PM
1. It's 'Triple'
2. I ran it and got this in the output:

Brain Damage v1.2
Programmed by Sean Connelly, [Web adress]
Brain Damage uses Lua v5.1.2 and Scintilla v1.75
Please see the About menu option for more information
______________________
Executing Untitled...

Small: 18. Big: 23.
Small: 18. Big: 20.
Small: 18. Big: 20.
Small: 19. Big: 20.
Small: 19. Big: 19.
Last: 18. Before that: 25.

ERROR: line 20, attempt to call field 'random2' (a nil value)
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:27 PM
Whoops... Fixed:

function _G.math.random2(last, last2)
big = Bigger(last, last2)
small = Smaller(last, last2)
while big ~= small do
a = math.random(1, 2)
b = math.random(small, big)
if a == 1 then
big = b
else
small = b
end
print("Small: "..small..". Big: "..big..".")
end
if last ~= last2 then
print("Last: "..last..". Before that: "..last2..".")
last2 = last
last = big
math.random2(last, last2)
else
print("The number is: "..last)
end
return last
end;
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:29 PM
Forgot the other 2 functions. ROBLOX really needs an "Edit" button.

function Bigger(a, b) if a > b then return a else return b end end;
function Smaller(a, b) if a > b then return b else return a end end;
function _G.math.random2(last, last2)
big = Bigger(last, last2)
small = Smaller(last, last2)
while big ~= small do
a = math.random(1, 2)
b = math.random(small, big)
if a == 1 then
big = b
else
small = b
end
print("Small: "..small..". Big: "..big..".")
end
if last ~= last2 then
print("Last: "..last..". Before that: "..last2..".")
last2 = last
last = big
math.random2(last, last2)
else
print("The number is: "..last)
end
return last
end;
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
08 Feb 2010 04:29 PM
Yai, it works now.

Small: 18. Big: 23.
Small: 18. Big: 20.
Small: 18. Big: 20.
Small: 19. Big: 20.
Small: 19. Big: 19.
Last: 18. Before that: 25.
Small: 18. Big: 18.
Last: 19. Before that: 18.
Small: 18. Big: 19.
Small: 18. Big: 19.
Small: 18. Big: 19.
Small: 19. Big: 19.
Last: 18. Before that: 19.
Small: 18. Big: 18.
Last: 19. Before that: 18.
Small: 18. Big: 19.
Small: 19. Big: 19.
Last: 18. Before that: 19.
Small: 18. Big: 19.
Small: 18. Big: 19.
Small: 19. Big: 19.
Last: 19. Before that: 18.
The number is: 19
19

(OT: Title fixed =P)
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:31 PM
It seriously gives a huge output. xD

math.random2(0, 1000)

Small: 394. Big: 1000.
Small: 878. Big: 1000.
Small: 902. Big: 1000.
Small: 902. Big: 978.
Small: 902. Big: 944.
Small: 902. Big: 929.
Small: 902. Big: 916.
Small: 915. Big: 916.
Small: 916. Big: 916.
Last: 0. Before that: 1000.
Small: 0. Big: 556.
Small: 0. Big: 135.
Small: 0. Big: 109.
Small: 0. Big: 44.
Small: 0. Big: 4.
Small: 1. Big: 4.
Small: 4. Big: 4.
Last: 916. Before that: 0.
Small: 274. Big: 916.
Small: 611. Big: 916.
Small: 611. Big: 908.
Small: 611. Big: 840.
Small: 788. Big: 840.
Small: 788. Big: 835.
Small: 788. Big: 804.
Small: 803. Big: 804.
Small: 803. Big: 804.
Small: 803. Big: 804.
Small: 803. Big: 804.
Small: 803. Big: 804.
Small: 803. Big: 803.
Last: 4. Before that: 916.
Small: 4. Big: 54.
Small: 4. Big: 53.
Small: 46. Big: 53.
Small: 46. Big: 50.
Small: 46. Big: 49.
Small: 48. Big: 49.
Small: 48. Big: 49.
Small: 48. Big: 49.
Small: 49. Big: 49.
Last: 803. Before that: 4.
Small: 49. Big: 606.
Small: 246. Big: 606.
Small: 305. Big: 606.
Small: 305. Big: 570.
Small: 392. Big: 570.
Small: 392. Big: 551.
Small: 392. Big: 501.
Small: 456. Big: 501.
Small: 495. Big: 501.
Small: 495. Big: 501.
Small: 495. Big: 500.
Small: 500. Big: 500.
Last: 49. Before that: 803.
Small: 49. Big: 146.
Small: 139. Big: 146.
Small: 139. Big: 146.
Small: 142. Big: 146.
Small: 143. Big: 146.
Small: 144. Big: 146.
Small: 144. Big: 144.
Last: 500. Before that: 49.
Small: 144. Big: 242.
Small: 185. Big: 242.
Small: 185. Big: 237.
Small: 185. Big: 191.
Small: 185. Big: 190.
Small: 190. Big: 190.
Last: 144. Before that: 500.
Small: 162. Big: 190.
Small: 172. Big: 190.
Small: 172. Big: 176.
Small: 173. Big: 176.
Small: 173. Big: 175.
Small: 173. Big: 175.
Small: 173. Big: 175.
Small: 173. Big: 175.
Small: 173. Big: 174.
Small: 173. Big: 173.
Last: 190. Before that: 144.
Small: 186. Big: 190.
Small: 190. Big: 190.
Last: 173. Before that: 190.
Small: 186. Big: 190.
Small: 186. Big: 186.
Last: 190. Before that: 173.
Small: 186. Big: 190.
Small: 186. Big: 187.
Small: 186. Big: 187.
Small: 187. Big: 187.
Last: 186. Before that: 190.
Small: 186. Big: 186.
Last: 187. Before that: 186.
Small: 186. Big: 187.
Small: 186. Big: 187.
Small: 186. Big: 187.
Small: 186. Big: 187.
Small: 186. Big: 187.
Small: 186. Big: 187.
Small: 186. Big: 186.
Last: 186. Before that: 187.
The number is: 186

(Hopefully I can't get hurt for spamming with an output. Lol.)
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
08 Feb 2010 04:33 PM
math.random2(-math.huge, math.huge)

Anybody wish to try?
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:35 PM
Eh... I'll do it on the Lua.org demo site..... xD
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
08 Feb 2010 04:35 PM
Lul win. I'll try it on Brain Damage.
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:36 PM
Suprisingly, it didn't lag at all!

Small: 0. Big: inf.
Small: 0. Big: inf.
Small: 0. Big: inf.
Small: 0. Big: 0.
Last: -inf. Before that: inf.
Small: -inf. Big: 0.
Small: -inf. Big: 0.
Small: -inf. Big: 0.
Small: 0. Big: 0.
Last: 0. Before that: -inf.
The number is: 0

Exactly what I expected it to say. Lol.
Report Abuse
Userdata is not online. Userdata
Joined: 31 Jan 2010
Total Posts: 133
08 Feb 2010 04:37 PM
Hmm... That's, interesting, but can't you use math.max(n,n2) and math.min(n,n2) instead of Bigger and Smaller functions?
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:39 PM
DOH. Well, here's math.random2(-math.huge, -1)
input:8: bad argument #2 to 'random' (interval is empty)

IT LIEZ!
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:41 PM
Shortened code:

function _G.math.random2(last, last2)
big = math.max(last, last2)
small = math.min(last, last2)
while big ~= small do
a = math.random(1, 2)
b = math.random(small, big)
if a == 1 then
big = b
else
small = b
end
print("Small: "..small..". Big: "..big..".")
end
if last ~= last2 then
print("Last: "..last..". Before that: "..last2..".")
last2 = last
last = big
math.random2(last, last2)
else
print("The number is: "..last)
end
return last
end;
Report Abuse
Anaminus is not online. Anaminus
Top 100 Poster
Joined: 29 Nov 2006
Total Posts: 5945
08 Feb 2010 04:45 PM
Try using the same randomseed each time you run it. It's not going to get any more random more matter how many calculations you perform not it.
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 04:47 PM
I just got bored. Didn't know it could get this popular. I should get bored more often! Wait...









I'm bored.
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
08 Feb 2010 09:04 PM
I take that back. Lol.
Report Abuse
Rapidude is not online. Rapidude
Joined: 06 Jan 2010
Total Posts: 330
09 Feb 2010 01:59 AM
most crazy forum ever
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
09 Feb 2010 02:11 AM
I think RT is crazier. Theres probably a post every second.
Report Abuse
Paint1541 is not online. Paint1541
Joined: 02 Jan 2010
Total Posts: 89
09 Feb 2010 03:56 AM
idk how script lol
Report Abuse
Brandonhare is not online. Brandonhare
Joined: 02 May 2007
Total Posts: 11005
09 Feb 2010 04:06 AM
Then why post?
Report Abuse
FoobyZeeky is not online. FoobyZeeky
Joined: 31 Dec 2008
Total Posts: 12429
09 Feb 2010 12:33 PM
Non-scripters don't post here >_>
Report Abuse
MrBlockson is not online. MrBlockson
Joined: 31 Aug 2008
Total Posts: 14276
09 Feb 2010 12:56 PM
You didn't need the ; after end...
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
09 Feb 2010 03:04 PM
@ MB: I know. Just a habit. I usually put a ';' after every ended block of code.
Report Abuse
zac352 is not online. zac352
Joined: 20 Feb 2009
Total Posts: 4657
09 Feb 2010 04:14 PM
[ Content Deleted ]
Report Abuse
Paint1541 is not online. Paint1541
Joined: 02 Jan 2010
Total Posts: 89
10 Feb 2010 06:06 PM
how script????????
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image