+TheHarvesters Posted March 6, 2010 Share Posted March 6, 2010 ...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. Quote Link to comment
+TheHarvesters Posted March 13, 2010 Author Share Posted March 13, 2010 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) Quote Link to comment
matejcik Posted March 15, 2010 Share Posted March 15, 2010 you could also implement your own RNG. here's three of them (in C, but the first two are easily translated to Lua) : http://www.daniweb.com/code/snippet216329.html then you would get the same results on all devices Quote Link to comment
+Tequila Posted March 15, 2010 Share Posted March 15, 2010 URWIGO has random numbers built into it. Quote Link to comment
+TheHarvesters Posted March 16, 2010 Author Share Posted March 16, 2010 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. Quote Link to comment
Recommended Posts
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.