Jump to content

Random (again...)


TheHarvesters

Recommended Posts

...still can't get this work satisfactorily on my Oregon.

 

I have the following in the Author script section:

 

require "math"

math.randomseed( os.time() )

math.random(); math.random(); math.random()

-- note these extra random calls are supposed to 'clear' the not-so-very-random first few calls that happen.

 

and a function called randomroll with the following lua script:

 

dieroll=mat.random(6)

 

On the emulator this works just fine, giving me (seemingly) very realistic random 'rolls' between 1 and 6.

 

However when tested 'in the field' I just get 5, 6, 5, 6... etc.

 

Can someone explain/help please?

 

many thanks,

 

Paul.

Link to comment

Okay, I have now thankfully solved this...

 

In my RandomDieRoll function I now have BOTH the following lines

 

math.randomseed( os.time() )

DieRoll=math.random(6)

 

previously I was just setting the seed for randomisation once in the author script - it seems this is less effective on the Oregon than in the PC emulator, just giving me a skew to the upper numbers.

 

By resetting the seed each time the virtual die is rolled I get a good variation.

 

Woo hoo! one step closer to finishing this thing...

 

oh, and ... Hi Bernie! 8)

Link to comment

URWIGO has random numbers built into it.

 

Thanks for your responses - I'll consider the better solutions you offer above, but I'm just delighted that I'm getting a working solution now, so I'm in no rush - other things to sort out.

 

re: Urwigo - I took a look at that. It looks pretty!, and those features would be good, but I was so far into using Earwigo, I didn't want to have to learn another tool. Earwigo has its advantages too of course.

 

When I get to look at building another cartridge (I can't stop having ideas!) then I'll re-consider Urwigo for that.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...