Page 1 of 1

[Done] Adding a resistance to Everything

Posted: Fri Jun 22, 2018 11:52 pm
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

Re: Adding a resistance to Everything

Posted: Sat Jun 23, 2018 2:31 pm
by darkfrei

Re: Adding a resistance to Everything

Posted: Sat Jun 23, 2018 3:22 pm
by Bilka

Re: Adding a resistance to Everything

Posted: Sat Jun 23, 2018 3:24 pm
by eradicator
Or the ingame source LuaGameScript.entity_prototypes.

Re: Adding a resistance to Everything

Posted: Sat Jun 23, 2018 3:29 pm
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.)

Re: Adding a resistance to Everything

Posted: Sat Jun 23, 2018 3:33 pm
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. :=)

Re: Adding a resistance to Everything

Posted: Tue Jun 26, 2018 5:51 pm
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.