The Wayback Machine - https://web.archive.org/web/20201216093730/https://github.com/xforce/anno1800-mod-loader/issues/28
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddIfNotThere ModOp #28

Open
taubenangriff opened this issue Aug 3, 2019 · 4 comments
Open

AddIfNotThere ModOp #28

taubenangriff opened this issue Aug 3, 2019 · 4 comments

Comments

@taubenangriff
Copy link
Contributor

@taubenangriff taubenangriff commented Aug 3, 2019

should exactly work like an add, but with a precheck if the added content is already there on the same level, in which case it does not add it.

Useful for making mods modular with building menu.

Example:
Mod A and Mod B should insert Buildings into the modded category 9000.
For no dependency between both mods the building category 9000 needs to be created and set up, and also added to the construction menu in both.
Problem is, if I add the category to the construction menu in both mods, it appears twice. But I only want to add it once even though both mods add buildings to the category 9000.

@taubenangriff
Copy link
Contributor Author

@taubenangriff taubenangriff commented Aug 4, 2020

This old issue has become relevant again today - as we found out, mods from different creators are incompatible because of doubled nodes which Anno expects to be unique.

The problem is adding the same unique node with different Child Nodes from two mods. In our case <BuildingReplacements> is non-existent in the original assets and both mods do the following ModOp:

<ModOp Type = "add" GUID = '167' Path = "/Values/ConstructionAi">
    <BuildingReplacements>
        <Item />
        <Item />
    </BuildingReplacements>
</ModOp>

Which in the end results in:

<ConstructionAi>
    <BuildingReplacements>
        <Item />
        <Item />
    </BuildingReplacements>
    <BuildingReplacements>
        <Item />
        <Item />
    </BuildingReplacements>
</ConstructionAi>

Anno always uses the last one, which means only BuildingReplacements from the mod that was loaded last will be applied ingame, which can result in serious trouble with the Ai.
There is no temporary workaround for this except for an external mod which just adds this node, which is kinda iffy and not very user-friendly (i.e. people could deactivate it because they do not know what this mod does).

What I would prefer for full manual control is having a CheckPath seperate from Path. If CheckPath returns null, the content of the ModOp gets added in the specified Path. That way, all mods adding BuildingReplacements could use this structure:

<ModOp Type = "addIfNotThere" GUID = '167' CheckPath = "/Values/ConstructionAi/BuildingReplacements" Path = "/Values/ConstructionAi">
    <BuildingReplacements />
</ModOp>

<ModOp Type = "add" GUID = '167' Path = "/Values/ConstructionAi/BuildingReplacements">
     <Item />
     <Item />
</ModOp>

Optional: We could have an Argument to negate CheckPath Results to not add stuff if CheckPath returns zero.

@xforce
Copy link
Owner

@xforce xforce commented Aug 4, 2020

Yea, I am currently looking into adding this.
The extra path to check was also something I was thinking about, because otherwise trying to determine that just by the child nodes would be buggy mess I fear.

As for having certain setup steps separate, I am currently also investigating a mod description format where you can specify dependencies, that will also ensure a certain load order without having to rely on the name with the alphabetical loading like it is right now (that should have been something from the start, but oh well)

@taubenangriff
Copy link
Contributor Author

@taubenangriff taubenangriff commented Aug 4, 2020

https://github.com/taubenangriff/Modinfo

I am planning to include ModDependencies in the modinfo files that will be added in the next spice it up update, in case you want to use those.

@xforce xforce added this to To Do in 0.8 Aug 5, 2020
@Serpens66
Copy link

@Serpens66 Serpens66 commented Oct 4, 2020

ah, this request is similiar to mine, while my suggested "merge_add" is superior, if it is possible to implement:
#65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.