Page 1 of 1
data, data-updates and data-final-fixes
Posted: Wed Jan 03, 2018 11:11 pm
by darkfrei
Here is a lot of mods, that can't working with another mods while they are have wrong access order to data.raw
Here is a very good example.
The whole mod has only data.lua with this code:
Code: Select all
for k, v in pairs(data.raw.resource) do
data.raw.resource[k].infinite = true
data.raw.resource[k].minimum = 100
data.raw.resource[k].normal = 100
end
Do you know why it doesn't work with
bob ores,
angel ores and
5dim ores?
Re: data, data-updates and data-final-fixes
Posted: Wed Jan 03, 2018 11:53 pm
by Sunnova
Make sure to place those mods in your dependencies list in your mods info.json file, so they get loaded before your mod does.
darkfrei wrote:
Do you know why it doesn't work with
bob ores,
angel ores and
5dim ores?
Re: data, data-updates and data-final-fixes
Posted: Thu Jan 04, 2018 1:26 am
by orzelek
It's a very generic question.
If you use dependencies and data-final-fixes it should work correctly.
In most cases final fixes are enough - but then you get more and more mods doing stuff in final fixes.
Dependencies are better choice but you need to know beforehand that other mods will modify same things you did.
A lot depends on how mods are written - main difference is if mod is only modifying base game stuff or it has full definitions copied inside it.
Looking at the example mod I'd say you should use final fixes. Aim of the mod is to overwrite ore settings for all ores.
You still might need to add dependencies if other mods modify ores in their final fixes - it should be rare but might happen.
Re: data, data-updates and data-final-fixes
Posted: Thu Jan 04, 2018 4:01 am
by DaveMcW
data.lua - Add new resources.
data-updates.lua - Modify another mod's new resources.
data-final-fixes.lua - Last chance to change things, avoid this if you can to minimize conflicts.
Re: data, data-updates and data-final-fixes
Posted: Thu Jan 04, 2018 4:11 am
by eradicator
DaveMcW wrote:data.lua - Add new resources.
data-updates.lua - Modify another mod's new resources.
data-final-fixes.lua - Last chance to change things, avoid this if you can to minimize conflicts.
Exactly this. You should use optional dependencies AND data-updates.lua to change ores.
Unless your aim is to change every ore even in mods you don't know anything about, in which case final-fixes gives you higher chances of succeeding. But changing ores of mods that you don't even know is a very bad idea in the first place. Especially if you're messing with the amounts. You might
completely destroy the balance of a mod by making slow-to-extract resources extremely fast/common or fast-to-extract resources extremely slow/rare. (I know this because i can already see how this would mess up one of my WIP mods that uses highly variable infinite resources. Also another part of that mod uses "resource" prototypes to simulate some stuff which would also completely break if someone messed with the amount values.)
Re: data, data-updates and data-final-fixes
Posted: Thu Jan 04, 2018 11:36 am
by darkfrei
eradicator wrote:Also another part of that mod uses "resource" prototypes to simulate some stuff which would also completely break if someone messed with the amount values.)
How are you using this prototypes? To send some information from data to control?
viewtopic.php?f=28&t=53615
Re: data, data-updates and data-final-fixes
Posted: Thu Jan 04, 2018 2:43 pm
by eradicator
darkfrei wrote:eradicator wrote:Also another part of that mod uses "resource" prototypes to simulate some stuff which would also completely break if someone messed with the amount values.)
How are you using this prototypes? To send some information from data to control?
viewtopic.php?f=28&t=53615
No. It's nothing like that. Its part of an environment simulation that uses unminable resources to determine some values for the surrounding area. And it relies (amongst others) on the resource amount to get decent random properties.
Re: data, data-updates and data-final-fixes
Posted: Mon Jan 08, 2018 11:28 am
by bobingabout
darkfrei wrote:Here is a lot of mods, that can't working with another mods while they are have wrong access order to data.raw
Here is a very good example.
The whole mod has only data.lua with this code:
Code: Select all
for k, v in pairs(data.raw.resource) do
data.raw.resource[k].infinite = true
data.raw.resource[k].minimum = 100
data.raw.resource[k].normal = 100
end
Do you know why it doesn't work with
bob ores,
angel ores and
5dim ores?
Basically, the ores in my mod do not FULLY exist until the end of the data-updates phase...
The item and resource is added in the data phase.
the autoplace controls are added in the data-updates phase
what you're doing in that loop will only work after my data.lua has been run, so, to do that, you either need to add bob's ores as a (optional) dependency to force it to load first, or the easy solution (and the reason why it exists) is to put that in the data-updates.lua instead (because then it will run in the data-updates phase, AFTER the data phase, after my mods have added ores).
Anyway, what you're doing there already exists in bob's ores mod. one of the options in the ingame menu is to turn all ores infinite. and, the script is basically the same as yours.
Code: Select all
if settings.startup["bobmods-ores-infiniteore"].value == true then
for index, resource in pairs(data.raw.resource) do
if not resource.infinite then resource.infinite = true end
if not resource.minimum then resource.minimum = 35 end
if not resource.normal then resource.normal = 350 end
end
end
note the use of the if not in there, that means it isn't going to overwrite stuff that already has this tag set, like oil.