Tweaking the biters

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Taehl
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Sun Jan 18, 2015 2:23 am
Contact:

Tweaking the biters

Post by Taehl »

Hello again. I'm starting to poke around the files a little, see what's available to tinker with. I found there's apparently a "spawning_cooldown" table in the biter-spawner which looks promising. Now, if I understand correctly, one cannot simply change such variables directly, I have to use "data:extend()", right? Could someone please explain that method to me? Would I do something like this?

Code: Select all

data:extend( {
	{
		type = "unit-spawner",
		name = "biter-spawner",
		max_health = 700,			-- double health
		healing_per_tick = 0.04,		-- double healing
		spawning_cooldown = { {3600, 1500} },		-- 1/10 spawn rate
	},
} )
Also, any ideas on how I can increase the number of biters spawned per spawning? I mainly want to slow down the spawn rate (spawning waves every 2.5 seconds is ludicrous!), but know that I need to compensate for it. Any ideas besides simply spawning larger groups?

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

Re: Tweaking the biters

Post by FreeER »

Taehl wrote:if I understand correctly, one cannot simply change such variables directly
Actually... You use data:extend(table) to add new data. To modify data that exists in the base game (or another mod) you don't use extend but instead actually do so 'directly' via data.raw (which of course means that what you are modifying needs to be loaded before your mod using the dependencies in info.json, though it defaults to requiring base if you don't specify it at all in the info.json) ex:
--note apologies if this is a bit detailed/obvious for some, I try to provide such explanations for when people use the search feature and find the threads later

Code: Select all

data.raw.type_of_what_you_are_modifying.name_of_what_you_are_modifying.property_of_what_you_are_modifying = new_value
when one of the indexes (the names preceeded by a '.' in the line above) have '-' or spaces in them you have to use the table["name"] format instead of the table.name format so that lua doesn't get confused about what you want (trying to subtract or causing illegal syntax errors).
to modify the spawner you'd use

Code: Select all

data.raw["unit-spawner"]["biter-spawner"] = new_table_with_ALL_info_including_things_you_did_not_change
or

Code: Select all

data.raw["unit-spawner"]["biter-spawner"].max_health = 700
data.raw["unit-spawner"]["biter-spawner"].healing_per_tick = 0.04
-- note you had a nested table for spawning_cooldown, that's not how it is in base!
data.raw["unit-spawner"]["biter-spawner"].spawning_cooldown = {3600, 1500}
that last can be shortened a bit to

Code: Select all

local spawner = data.raw["unit-spawner"]["biter-spawner"]
spawner.max_health = 700
spawner.healing_per_tick = 0.04
spawner.spawning_cooldown = {3600, 1500}
The second/third is the preferred method since you won't overwrite data that some other mod may have modified (including when Factorio updates) when you didn't explicitly intend to.

note: the code would either go in data.lua or a file required by data.lua

Let me know if I didn't make that clear enough :D
For more examples download a mod that modifies the base game and see how they do it (here's a link to DyTech Core's base edits on github)
Also feel free to look at Factorio/data/core/lualib/dataloader.lua :)
<I'm really not active any more so these may not be up to date>
~FreeER=Factorio Modding
- Factorio Wiki
- My Factorio Modding Guide
- Wiki Modding Guide
Feel free to pm me :)
Or drop into #factorio on irc.esper.net

User avatar
Taehl
Long Handed Inserter
Long Handed Inserter
Posts: 50
Joined: Sun Jan 18, 2015 2:23 am
Contact:

Re: Tweaking the biters

Post by Taehl »

That's exactly the info I needed! Thanks, FreeER. I'm also going to play with "max_count_of_owned_units" and "max_friends_around_to_spawn". That sounds like it should control the amount of biters spawned, right?

Also, why is "result_units" a function that immediately gets executed to return a table? Couldn't it just be a table? Speaking of "result_units", why is "res[1]" a table with named indexes, but "res[2]" and "res[3]" only have numbered indexes?

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

Re: Tweaking the biters

Post by FreeER »

Sorry for delay in responding, distracted by python + sockets (sentdex tut on YT)...
Taehl wrote:That sounds like it should control the amount of biters spawned, right?
Sounds like :)
Taehl wrote:why is "result_units" a function
So that data.isdemo can be checked (including non-demo defined enemies in the demo == error lol).
Taehl wrote:why is "res[1]" a table with named indexes, but "res[2]" and "res[3]" only have numbered indexes?
Um... this one I have NO idea... it's changed from what I remember pre v11.

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

Re: Tweaking the biters

Post by Choumiko »

Taehl wrote:I'm also going to play with "max_count_of_owned_units" and "max_friends_around_to_spawn". That sounds like it should control the amount of biters spawned, right?
Look at https://forums.factorio.com/forum/vie ... =25&t=7974 and maybe https://forums.factorio.com/forum/vie ... =14&t=7935
Some useful info there ;)

Post Reply

Return to “Modding help”