run a command every X
run a command every X
Is there a way to run a command (console command) every minute (or other frequency)?
Re: run a command every X
Something like this:
Code: Select all
script.on_event(defines.events.on_tick, function(event)
if event.tick % 60*5 == 0 then --every 5 seconds
some_function(event)
end
end)
Re: run a command every X
Great thanks 
I am 100% clear of pollution... actually its not the pollution I care about, its being able to see the map that I want, and now I can
A little surprised the code works, was expecting it to get upset with the "local" variable definition inside a loop.
After I did this, it did occur to me that perhaps there was a way to stop pollution occurring which would be kinder on the old CPU cycles.

I am 100% clear of pollution... actually its not the pollution I care about, its being able to see the map that I want, and now I can

Code: Select all
/c script.on_event(defines.events.on_tick, function(event)
if event.tick % 60*60 == 0 then --every 60 seconds
local surface = game.local_player.surface; for coord in surface.get_chunks() do surface.pollute({coord.x * 32, coord.y * 32}, -10000000) end
end
end)
After I did this, it did occur to me that perhaps there was a way to stop pollution occurring which would be kinder on the old CPU cycles.
Re: run a command every X
Or you just press Alt when in map view? Unless i completely misunderstand what you are after. Removing pollution makes biters kind of pointless since they won't evolve/attackNosajDraw wrote:I am 100% clear of pollution... actually its not the pollution I care about, its being able to see the map that I want, and now I can
Re: run a command every X
I play on peaceful and I think it's a mod I have that totally removes the biters, the pollution is just an annoyance for me.Choumiko wrote:Or you just press Alt when in map view? Unless i completely misunderstand what you are after. Removing pollution makes biters kind of pointless since they won't evolve/attackNosajDraw wrote:I am 100% clear of pollution... actually its not the pollution I care about, its being able to see the map that I want, and now I can
My interest in the game is making things do things, I really dislike the whole biters side of things, it certainly adds nothing to the game for me, quite the opposite.
Re: run a command every X
Oh, and the timer code doesnt work, at least not long term, it seemed to work for a while, but now the pollution is back.
Re: run a command every X
The command will stop working after you reload the save. If you want to have it permanently you'll need to include it as a mod or directly in the control.lua of the savegame.NosajDraw wrote:Oh, and the timer code doesnt work, at least not long term, it seemed to work for a while, but now the pollution is back.
If it's only the pollution on the minimap that's bothering you, just disable Options --> Graphics --> Show pollution on minimap when detailed info is on (doesn't work on the big map)NosajDraw wrote:I am 100% clear of pollution... actually its not the pollution I care about, its being able to see the map that I want, and now I can
Re: run a command every X
Alt+M opens a special big map with pollution disabled. Press Alt+M again to close it. 

Re: run a command every X
Oh cool, thanks, yes for the most part its the pollution on the minimap that annoys me.daniel34 wrote:If it's only the pollution on the minimap that's bothering you, just disable Options --> Graphics --> Show pollution on minimap when detailed info is on (doesn't work on the big map)
Re: run a command every X
OK, will take a look at that when I reload.DaveMcW wrote:Alt+M opens a special big map with pollution disabled. Press Alt+M again to close it.
-
- Burner Inserter
- Posts: 11
- Joined: Sun Feb 28, 2021 10:13 pm
- Contact:
Re: run a command every X
ActuallyKlonan wrote: Sat May 28, 2016 12:37 pm Something like this:
Code: Select all
script.on_event(defines.events.on_tick, function(event) if event.tick % 60*5 == 0 then --every 5 seconds some_function(event) end end)
Code: Select all
% (60*5)
Re: run a command every X
Is this a good use for on_nth_tick?
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Re: run a command every X
i guess, this is a thread from 2016
right now there are ways to solve OPs problem without console commands:
map view has filters that can be toggled on/off(to not display pollution).
map gen settings can be changed to disable pollution on the map with /editor, mapgen settings mod or with a command