[Done] Adding a resistance to Everything

Place to get help with not working mods / modding interface.
Post Reply
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

[Done] Adding a resistance to Everything

Post by TheSAguy »

Hi,

How would i add a resistance to very entity in the game?


How do I finish the code below?

Code: Select all

	local function add_immunity(entities)
	  if not entities.resistances then entities.resistances = {} end
	  table.insert(entities.resistances, {type = "fire", percent = 25})
	  end

	for _,entities in pairs(data.raw[?]) do
		add_immunity(entities)
	end

end
Would I have to call out every entity type?
Thanks
Last edited by TheSAguy on Sat Jul 14, 2018 2:29 pm, edited 1 time in total.


Bilka
Factorio Staff
Factorio Staff
Posts: 3133
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Adding a resistance to Everything

Post by Bilka »

I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Adding a resistance to Everything

Post by eradicator »

Or the ingame source LuaGameScript.entity_prototypes.

Bilka
Factorio Staff
Factorio Staff
Posts: 3133
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Adding a resistance to Everything

Post by Bilka »

eradicator wrote:Or the ingame source LuaGameScript.entity_prototypes.
(Which is about the control stage, and not the data stage. Also, looping through all of that just for the types seems more tedious than just looking at the wiki.)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Adding a resistance to Everything

Post by eradicator »

Bilka wrote:
eradicator wrote:Or the ingame source LuaGameScript.entity_prototypes.
(Which is about the control stage, and not the data stage. Also, looping through all of that just for the types seems more tedious than just looking at the wiki.)
Yea. But the control stage "knows" more about the internal layout of the game. So it's easy to extract static info out of it like the types, which do not change. And the wiki does not offer a copy/pastable lua table, which is easy to generate in control stage. In any case OP will have to manually edit the list, because stuff like flying-text, item-entity, or legacy-decorative probably don't do resistances. :=)

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Adding a resistance to Everything

Post by TheSAguy »

What will happen in an entity has the same resistance twice, may or may not be the same amount.
Does it get added together?


In the example below. What will the pole end up with for "poison"? 100, -25 or 75

data.raw["electric-pole"]["small-electric-pole"].resistances[1].type = "poison"
data.raw["electric-pole"]["small-electric-pole"].resistances[1].percent = 100
data.raw["electric-pole"]["small-electric-pole"].resistances[2].type = "poison"
data.raw["electric-pole"]["small-electric-pole"].resistances[2].percent = -25

Thanks.

Post Reply

Return to “Modding help”