Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

About random...

hey folks!
I'm currently updating my weather script... to make the region and season setup much easier, but now i ran into a problem.
Code:
  def setup_regions_weather_cycle

    for region in @regions

      case region.name

      when "Outside"

        region.weather_transition = 200 # Frames

        region.weather_duration   = x   # Frames

      end

    end
whenever x comes along with rand(whatever) the duration of weather effects is still fix. So i want to call rand() without its seed.

I found a solution by putting the formluar into a string and call it with eval() when it's time to make the calculations.

But is there a better option?

to make it more obvious:
when g = rand(5) i want a random integer (0 to 4) returned whenever I call g, therefore i need to get rid of the seed in rand()
 
sry, but i think you misunderstood my problem, of course rand() is random, but after assigning it to to g it's fix.

Code:
g = rand(5) # => a random number from 0 to 4, this time 2

print g # => 2

print g # => 2

 

you got it now?

i want g, whenever i call it to return an integer from 0-4
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top