RealMillisecs request for therevills

Monkey Forums/Monkey Programming/RealMillisecs request for therevills

erebel55(Posted 2014) [#1]
In this post http://www.monkeycoder.co.nz/Community/posts.php?topic=5785

therevills said..

Realmillisecs was one of the first things in Diddy, due to the lack of date functions in Monkey at the time... to create a "proper" seed.

I really should change it to wrap the newish date functions to remove the external code.


Have you done this yet? Or do you plan on doing it?

I am interested in what this would look like without external code. I am hoping to use RealMillisecs as a seed for my random numbers without including diddy. I could just take the external code, but was hoping for something a little cleaner.

Thank you!


Gerry Quinn(Posted 2014) [#2]
I don't know if it is still the same, but in my version of Diddy you just need to import diddy.externfunctions.


erebel55(Posted 2014) [#3]
Right, I went through the diddy code and the externfunctions and understand what is going on there. I just was hoping for a cleaner solution than grabbing all of that. I am not using diddy in my project. Although I think it is a great framework and I have taken a handful of things from it.


therevills(Posted 2014) [#4]
Nope not yet, but thanks for reminding me :)

As for a "cleaner" solution to generate a random seed you could do the following:
Strict

Import mojo

Function Main:Int()
	New MyApp()
	Return True
End

Class MyApp Extends App
	Field rndNo:Int
	
	Method OnCreate:Int()
		Local date:Int[] = GetDate()
		Print date[5] + "." + date[6]
		Seed = date[5] + date[6]
		rndNo = Rnd(1000)
		SetUpdateRate(60)
		Return True
	End
	
	Method OnRender:Int()
		Cls
		DrawText Seed, 10, 10
		DrawText rndNo, 10, 20
		Return True
	End
	
	Method OnUpdate:Int()
		Return True
	End
End



erebel55(Posted 2014) [#5]
Thank you!! Love all of your code :)