Dodgy code or me!

Monkey Forums/Monkey Programming/Dodgy code or me!

therevills(Posted 2011) [#1]
Can someone please tell me what wrong with this code:



Why doesnt it display "DONE!"?

Thanks!


muddy_shoes(Posted 2011) [#2]
I'd guess because it's taking longer than a second to get between your OnCreate() startTime recording and where you test in OnUpdate() with this:

If Millisecs() - startTime >= 1000
    preCache = 1
End


Which means that preCache is never '2' and so you are never 'done'.


therevills(Posted 2011) [#3]
The strange thing is that if you run the code, it actually displays "2" on screen!?!?!

And if you add a Print statement:

	Method OnRender:Int()
		Cls 
		If preCache = 1
			preCache = 2
			Print preCache
		End


It always prints out 2.... forever, even though the check is preCache = 1!?!?!??!?!


muddy_shoes(Posted 2011) [#4]
Yeah, but that's in the OnRender just after you set it to 2. You're setting "done" in the OnUpdate and it's never 2 at that point because it always falls into the check I quoted above and sets preCache to 1.


therevills(Posted 2011) [#5]
DUUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRR!!!

Dont mind me.................... nothing to see here!!!!

Thanks Muddy Shoes!