game state checks (updating) question

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
callmewoof
Inserter
Inserter
Posts: 27
Joined: Fri Apr 24, 2015 3:46 am
Contact:

game state checks (updating) question

Post by callmewoof »

I've been looking into mods more closely lately, having done only minor tweaks to mods or the game in the past. I had always heard that Treefarm slows the game down, and I just read a thread that says once you get a lot of them it's because the game has to do a status check a whole bunch. In other words, I guess a mod can be "too busy" and clog up the game.

Thus I was wondering, how often is too often? If I wanted an item to check for the state of other things, what's a good balance? For example, if I wanted something to check if something has an item in it, or perhaps if turrets have fired, or if an enemy has entered an area. Checking too often is obviously bad, but checking too rarely would be dumb too. I hope this makes sense, because I'm not amazing at this, obviously. :-)

Edit: This is the post I was referring to: https://forums.factorio.com/forum/vie ... 34&t=19258 and this specifically:
The problem is, when you have LOTS of treefarms, each one has that 60 tick delay. So with 60 treefarms you would at best get one updating every tick. And this REALLY lags the game.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: game state checks (updating) question

Post by DaveMcW »

Press F6 and look at the processing time of your mod. Anything above 17 ms is really bad, as it drops the game below 60 FPS with nothing else running. But the smaller you can get, the better. The ultimate goal is to keep the sum of your mod + the base game + every other mod below 17.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: game state checks (updating) question

Post by Choumiko »

callmewoof wrote:Thus I was wondering, how often is too often? If I wanted an item to check for the state of other things, what's a good balance? For example, if I wanted something to check if something has an item in it, or perhaps if turrets have fired, or if an enemy has entered an area. Checking too often is obviously bad, but checking too rarely would be dumb too. I hope this makes sense, because I'm not amazing at this, obviously. :-)
It highly depends on what the code is doing (searching entities in a big area: lot of work, changing some number: not much work) as well as the number of these items in the world, e.g. 1 "Enemy scanner" that searches enemies in an area probably isn't noticeable, no matter how often it updates, make that 10 and it may affect UPS, make it 1000 and your on a slideshow.

callmewoof
Inserter
Inserter
Posts: 27
Joined: Fri Apr 24, 2015 3:46 am
Contact:

Re: game state checks (updating) question

Post by callmewoof »

Thanks for the replies. I didn't know I could check in-game how much a mod is doing. Also thanks for the timing tips.

Post Reply

Return to “Modding discussion”