Why is this code make my scrip hang?

Place to get help with not working mods / modding interface.
Bizz Keryear
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Thu Oct 22, 2015 5:08 am
Contact:

Why is this code make my scrip hang?

Post 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.
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Why is this code make my scrip hang?

Post by prg »

game.tick doesn't advance while that code runs.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Bizz Keryear
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Thu Oct 22, 2015 5:08 am
Contact:

Re: Why is this code make my scrip hang?

Post by Bizz Keryear »

that explains a lot
Helfima
Fast Inserter
Fast Inserter
Posts: 202
Joined: Tue Jun 28, 2016 11:40 am
Contact:

Re: Why is this code make my scrip hang?

Post 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)
Post Reply

Return to “Modding help”