Page 1 of 1

Why is this code make my scrip hang?

Posted: Wed Jul 06, 2016 2:17 pm
by Bizz Keryear
Why is this code make my scrip hang when executed twice in a row

Code: Select all

	if lastfloat ~= nil and lastfloat+60 < game.tick then
		while lastfloat+60 < game.tick do
		end
	end
I mean my game will hang forever ...but the way this is written it should stop for 1 second at worst.

Re: Why is this code make my scrip hang?

Posted: Wed Jul 06, 2016 2:54 pm
by prg
game.tick doesn't advance while that code runs.

Re: Why is this code make my scrip hang?

Posted: Wed Jul 06, 2016 4:15 pm
by Bizz Keryear
that explains a lot

Re: Why is this code make my scrip hang?

Posted: Thu Jul 07, 2016 12:03 pm
by Helfima
if u want run something at interval u can use this

Code: Select all

function proxy_tick(event)
	if game.tick % 60 == 0 then
		--TODO something
	end
end

script.on_event(defines.events.on_tick, proxy_tick)