The Daily Click ::. Forums ::. Klik Coding Help ::. Random number generation
 

Post Reply  Post Oekaki 
 

Posted By Message

vuzzupp



Registered
  22/01/2005
Points
  72
22nd January, 2005 at 12:18:25 -

hi, im quite new to tgf. I know how to generate a random number between 0 and 10 using "random(10)" but how do you make it so its between say 5 and 15?

 
Website: Http://www.sharemygames.com

solonmonkey



Registered
  12/05/2004
Points
  165
22nd January, 2005 at 12:20:08 -

Do the "random(10)" then add "+ 5" so it will look like this: "random(10) + 5" thats it.

 
n/a

vuzzupp



Registered
  22/01/2005
Points
  72
22nd January, 2005 at 12:23:46 -

would it working if i used it to work out the amount of damage from one of my chracters?

 
Website: Http://www.sharemygames.com

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
22nd January, 2005 at 12:29:25 -

Yes, it will, if you do something like set the Health of an object to Health - (random(10) + 5).

Remember, though, that random(10) doesn't generate a number between 0 and 10, but instead 0 to 9 (therefore a range of ten numbers).

 
http://www.davidn.co.nr - Games, music, living in America

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
22nd January, 2005 at 15:14:32 -

Generally, random numbers are generated using random(max-min) + min.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
22nd January, 2005 at 16:18:28 -

if you wanted between 5 and 15 it'd be random(10)+6

 
My signature is never too big!!!

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
22nd January, 2005 at 19:06:33 -

same thing

 
My signature is never too big!!!

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
22nd January, 2005 at 19:37:22 -

but it'll still result in a number between 5 and 15

 
My signature is never too big!!!

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
23rd January, 2005 at 08:19:34 -

ah shut up you smelly hippy

 
My signature is never too big!!!

vuzzupp



Registered
  22/01/2005
Points
  72
11th February, 2005 at 11:22:26 -

Thnx you guys

 
Website: Http://www.sharemygames.com
   

Post Reply



 



Advertisement

Worth A Click