View Single Post
  #11  
Old 12-20-2012, 05:15 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
Those are some of the most weirdly complicated ways of doing this I've seen.

PHP Code:
function pickRandomNumber() {
  if (
random(01) < 0.5) {
    return 
5;
  } else {
    return 
10;
  }

Usually the simplest solution is best. Code readability > tricky math. It's a lot easier to look at mine and see what it does than it is to stop and mentally parse out int(random(1,2.9))*5.
Bah, this is elementry level math. Nothing tricky about it.. Had it been more complicated, yes I would have done like chris showed however I prefer doing it as BlueMelon showed at that point. It was just kinda the first thing that poped into my head to help, without adding a bunch of lines to his script.
Reply With Quote