I was thinking of adding a damage type - Venom, but wanted to make all buildings immune to it.
Is there a way to mass update all entities? Like cycle thought them and update?
I know that some buildings already have the 75% fire resistance.
Maybe something like "If Resistance = {} or Resistance = Fire 75%, then Resistance = Fire 75% and Venom 100%"
(Not actual code)
Thanks.
Another Resistance Question
Re: Another Resistance Question
Well, I don't see this much different from usual entity alteration by mod.
You iterate over in your data.lua, data-upgrades.lua (or the third one) or whatever file that is required by those, you iterate over data.raw selecting the categories you need, and selecting desired entities from those categories and update those.
In the example I've went with explicit list of vulnerable unit names and not with the listing of vulnerable categories because some mods might put there entities which shouldn't be vulnerable. For example mocombat adds mechanic units for which poison damage would be just silly.
You iterate over in your data.lua, data-upgrades.lua (or the third one) or whatever file that is required by those, you iterate over data.raw selecting the categories you need, and selecting desired entities from those categories and update those.
Code: Select all
new_resist={type = "venom", decrease = 15, percent = 50};
exclude={"player"=true, "behemoth-biter"=true, "behemoth-spitter"=true};--you got the idea of how this list should be filled
for category_name, category in pairs(data.raw) do
if category_name~='projectile' then --first filter, purely demonstrational
for prot_name, prot in pairs(category) do
if prot.resistances and not exclude[prot_name] then --second filter
table.insert(prot.resistances,new_resist);
end
end
end
end
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: Another Resistance Question
Thanks Adil,
So I have just started with the code and have a few follow-up questions so I better understand things.
This is the current code.
Is there a way to use wild cards for the biters? Like "*-biter" and "*-spitter"
Is there an easy way to get all "Categories"?
Am I correct in saying that currently it will only add the new resist to items that already have some sort of resistance? (If it meets the filter criteria)
- So the current code, all categories not Projectile and not in the exclusion list, that has a resistance, will get the Venom added.
Lastly, I'm new to Lua, is there a good tutorial, especially on the whole "in pairs" thing....
Thanks.
So I have just started with the code and have a few follow-up questions so I better understand things.
This is the current code.
Code: Select all
local new_resist = {type = "Venom", decrease = 50, percent = 100}
local exclude = {["player"]=true, ["behemoth-biter"]=true, ["behemoth-spitter"]=true}--you got the idea of how this list should be filled
for category_name, category in pairs(data.raw) do
if category_name~='projectile' then --first filter, purely demonstrational
for prot_name, prot in pairs(category) do
if prot.resistances and not exclude[prot_name] then --second filter
table.insert(prot.resistances,new_resist)
end
end
end
end
Is there an easy way to get all "Categories"?
Am I correct in saying that currently it will only add the new resist to items that already have some sort of resistance? (If it meets the filter criteria)
- So the current code, all categories not Projectile and not in the exclusion list, that has a resistance, will get the Venom added.
Lastly, I'm new to Lua, is there a good tutorial, especially on the whole "in pairs" thing....
Thanks.
Re: Another Resistance Question
There's a really good book available online on the lua.org page: Programming in Lua (first edition)TheSAguy wrote:Lastly, I'm new to Lua, is there a good tutorial, especially on the whole "in pairs" thing...
For pairs, look at http://www.lua.org/pil/4.3.5.html