Any variable to control biter spawn rate

Place to get help with not working mods / modding interface.
Post Reply
Lumikins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Sat Sep 13, 2014 4:22 am
Contact:

Any variable to control biter spawn rate

Post by Lumikins »

I've run into an issue lately in which the game has run so long the enemy spawn rate has become instantaneous. Are there any variables that can be changed to control the biter spawn rate?

I've tried following in the game tick event loop:

Code: Select all

-- keep resetting monster evolution factors for now every minute
if (game.tick % (60 * 60) == 0) then
    	game.mapsettings.enemy_evolution.time_factor = 0
    	game.mapsettings.enemy_evolution.pollution_factor = 0
	game.mapsettings.enemy_evolution.destroy_factor = 0
end
and it has a very tiny effect if anything at all. Any help appreciated - thanks!

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Any variable to control biter spawn rate

Post by FreeER »

Have you tried lowering the game.evolutionfactor (max of 1, min of 0)? Changing the mapsettings would really only be beneficial at the start of a game (they control how much those actions should increase the game.evolutionfactor), since after you've been playing for a while the evolutionfactor pretty quickly maxes out they'll have little effect.
If you have then the best suggestion I have would be to modify (with mod+data.raw statements/commands) the actual spawner prototype (specifically spawning_cooldown and/or max_count_of_owned_units, max_friends_around_to_spawn, ...perhaps the pollution_cooldown. I can't remember exactly how that last one works)

Lumikins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Sat Sep 13, 2014 4:22 am
Contact:

Re: Any variable to control biter spawn rate

Post by Lumikins »

Thanks - I'll try all of those.

I'm fairly new to Lua so what's the best way of poking around in the data.raw table? I'm still trying to get a grasp of how exactly the game stores it's data. I'm thinking of using this recursive lua table printout linked below but is there a way to output this to a file instead of a painful in game console dump?

Code googled up for simple recursive lua table dump: https://gist.github.com/hashmal/874792

PS: game.evolutionfactor = 0 did the trick. Spawns are back to early game rates with only small biters present. Thanks! Was using DyTech mod earlier and the killing fields of the new biter corpses were creating lag spikes in addition to the crawl of infinite spawns.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: Any variable to control biter spawn rate

Post by FreeER »

Lumikins wrote:I'm fairly new to Lua so what's the best way of poking around in the data.raw table?
data.raw's layout is data.raw[type][name] = prototype_table_passed_to_data_extend. If you'd like a slightly more graphical view (a text dump of data.raw listed by type and name, no actual prototype data though) of it then you can look at the wiki here.

As for a recursive table print out you can use serpent.block(data) to get a string form of it, Serpent is a Lua serializer that is automatically loaded for you by Factorio. As for a method other than console dump.. not from the data loading stage (on Win 7 I don't even have a console to print to during loading so I end up using error(string_data), oh and error(not_a_string) crashes Factorio lol). From control.lua you can use makefile but it's fairly limited in itself (and no, there's not a readfile).

In-game you have (limited) access to the prototypes via game.itemprototypes, game.entityprototypes, game.player.force.recipes, and game.player.force.technologies, (they're not normal Lua tables, most of what you'll get from the API calls won't be normal tables either, so serpent won't help you, but you can call the help method on any of those in game prototypes (now) and it'll return a string of what you can access through it. try game.player.print(game.itemprototypes["iron-ore"].help()) in the console for example).

If you'd like to know anything else, feel free to ask :)

Post Reply

Return to “Modding help”