Arbritrary External Mod Prototype Script
- Ranakastrasz
- Smart Inserter
- Posts: 2173
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Arbritrary External Mod Prototype Script
In my mod, I have increased the energy values of all modular armor equipment by 50x so it can interact with fuel and the energy network in a sane manner. I want to be able to allow full compatability with all other mods that add new modules. Other mods don't have this multiplier however, meaning I would have to write some kind of interface script for each and every mod that is added. Is it possible/how can I write a script that runs after all mods load their prototypes, and then loop through and alter them as needed?
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Arbritrary External Mod Prototype Script
Put the code that multiplies the value in data-final-fixes.lua This file is run after all data.lua and data-updates are done for every mod. Running it in data-updates could be enough (Not sure if there's a best practice yet)
Re: Arbritrary External Mod Prototype Script
Like Choumiko said a data-updates or data-final-fixes can search by prototype and replace/alter properties of all items added by all mods. I suggest you look at the following prototypes:
"energy-shield-equipment","battery-equipment","solar-panel-equipment","generator-equipment","active-defense-equipment" and possibly "night-vision-equipment", and "movement-bonus-equipment"
the code would search for all items with type = ""(as above) and replace energy_... with whatever values or multipliers you wished.
"energy-shield-equipment","battery-equipment","solar-panel-equipment","generator-equipment","active-defense-equipment" and possibly "night-vision-equipment", and "movement-bonus-equipment"
the code would search for all items with type = ""(as above) and replace energy_... with whatever values or multipliers you wished.
- Ranakastrasz
- Smart Inserter
- Posts: 2173
- Joined: Thu Jun 12, 2014 3:05 am
- Contact:
Re: Arbritrary External Mod Prototype Script
This is the code I attempted. I didn't finish it yet due to compilation error. I am trying to get it to loop through all prototypes at the same time. This seems to not be cooperating.
Code: Select all
function modValue(str) -- Multiply power values by powerCoef
--str = "101kw"
pos = string.find(str,"%a")-1
--io.write(pos.."\n")
subPre = string.sub(str,1,pos)
subSuf = string.sub(str,(pos)-string.len(str))
--io.write(string.len(str).."\n")
val = tonumber(subPre)
val = val*50
subPre = tostring(val)
str = subPre..subSuf
--io.write(subPre.."\n")
--io.write(subSuf.."\n")
--io.write(str.."\n")
return str
end
for i, equipment in pairs (data.raw) do
if string.find(equipment[1].type, "equipment") then
end
end
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Re: Arbritrary External Mod Prototype Script
Data.raw subtables are indexed by names not by numbers. Have a look at this page.
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.