Log In  


So, I'm working on a game jam game, and I see speed-running potential in it. I'm trying to make a built in speedrunning overlay, and I need to be able to pause the

time()

function so that in the transition areas the time pauses so you can rest for a bit. However, I haven't been able to find anything that can stop, or emulate stopping the time function. I need an answer by Friday afternoon BST since that's when the jam ends.



Can you do something like create an offset variable initialized to 0, then grab the value of time() before each transition, subtract it from the value of time() post-transition, add that difference to offset, then use time() - offset for your display instead of just time()?


That doesn't seem to work... Here's the code I used to test:

function _init()
	offset=0
	go=false
	display=5
	store=0
end
function _draw()
	if go then
		display=time()-offset
	end
	if btnp(4) then
		if not go then
			offset+=time()-store
			go=true
		end
		if go then
			store=time()
			go=false
		end
	end
	cls()
	print(display)
end

Do you have any idea why it does not work?


Also, the reason I put everything in draw is because i'm just trying it out and it's quicker to put both in the draw function.


Yeah, your if conditionals in the btnp(4) need to be an if/else, because what happens now is that if not go gets triggered and sets go to true, then "if go" also resolves to true since you just set it to true, and sets go back to false. What you need instead is this:

        if not go then
            offset+=time()-store
            go=true
        else
            store=time()
            go=false
        end

Then it should work.



[Please log in to post a comment]