MODDERS PLEASE READ, Abstracts and how they should be used.

Started by 1000101, April 25, 2016, 05:10:45 PM

Previous topic - Next topic

1000101

milon:
So it looks like you *can* inherit Abstracts from other mods (see quote from Ison below).  I'm locking this thread now, but I'm leaving it intact.  I'll leave it stickied for now so hopefully everyone will see the update.  If there are any problems/concerns, PM a moderator and we'll take the appropriate action. 

Quote from: ison on January 26, 2017, 09:46:50 AM
I've just tested it and it seems that it is possible to inherit XML nodes like BuildingBase from other mods, so I'm not sure if this thread is still valid.





To all modders

Apparently there is bad information regarding xml inheritance.  Specifically regarding abstract definitions.

The prevailing thought pattern is that abstracts are inheritable across mods.  This is not true.  An abstract can only be inherited across files within the mod that defines it.  This is known as scope and trying to inherit from another mods abstract will result in it being "out of scope".  This is similar to the "using" statement in assembly sources which defines a namespace as "in scope" allowing referencing to classes in the namespace defined without explicitly referencing the namespace.

The big offender is "BuildingBase" which many modders are not defining thinking that they can inherit.  While none of the abstracts are inheritable, "BuildingBase" is used most often.

Please check your output_log.txt/Player.log and resolve any errors before releasing your mods.  Don't rely on the debug window popping up!

The issue with abstracts and errors, however, is that they do not show an error or even a warning directly.  Trying to inherit from an abstract which doesn't exist will result in the fields in the def which are not set by the def to be set to the default for the class (eg, ThingDef).  This can cause subtle errors which may not show as a direct link to the missing abstract.

While the game may "work," these errors can cause problems with other mods.  The Community Core Library is especially sensitive to xml errors and many users are experiencing problems and reporting bogus/junk bugs due to this.

Thank-you for reading this,
1000101

Edited 12/08/2016:  Fixed some typographical errors and added information regarding the lack of errors when trying to use undefined abstracts.

Edit 15/11/2016:

TL;DR

If you don't define an abstract, don't use it.  No errors will be thrown by the game about missing abstracts but they can and will cause subtle errors which may not detectable at first or without other mods installed.

Bogus error reports and disgruntled users can be avoided by simply defining abstracts.

Guarantee the success of your own mods and others by defining every abstract you use.


Skullywag also posted this boiled-down information as PSAs:
[Mods Subforum]
[Help Subforum]
[Releases Subforum]
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

skullywag

Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

cuproPanda

There should be a way to have a bases file, where all bases are defined for the mod - possibly within <ThingDef>, <TerrainDef>, <HediffDef>, etc. blocks for parsing. I have extracted all the thingDef bases into a file I use for copying the blocks when I need them, but I feel it would help a lot of modders keep track of the bases they are using if it was possible to have a single file that contained all the ones they needed.
cuproPanda's Mods: Survivalist's Additions, Additional Joy Objects, Cupro's Drinks, Quarry, Cupro's Stones, Zen Garden, Cupro's Alloys, Preset Filtered Zones, & more!

skullywag

you cant have a file with nothing but abstracts in, you must have 1 complete def i believe.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

cuproPanda

Quote from: skullywag on April 25, 2016, 07:08:20 PM
you cant have a file with nothing but abstracts in, you must have 1 complete def i believe.
This is true.
cuproPanda's Mods: Survivalist's Additions, Additional Joy Objects, Cupro's Drinks, Quarry, Cupro's Stones, Zen Garden, Cupro's Alloys, Preset Filtered Zones, & more!

Kirid

So I'm not the only one making this mistake?
You can't rollerskate in a muffalo herd

Shinzy

Quote from: Kirid on April 26, 2016, 12:27:44 AM
So I'm not the only one making this mistake?

Oh god no
Youre not

*I* didnt ofcourse fall for this trap at all but
Skully did, what a lightweight numbnut! (Stupido!)





skullywag

Quote from: Shinzy on April 26, 2016, 03:27:59 AM
Quote from: Kirid on April 26, 2016, 12:27:44 AM
So I'm not the only one making this mistake?

Oh god no
Youre not

*I* didnt ofcourse fall for this trap at all but
Skully did, what a lightweight numbnut! (Stupido!)

OI my mods have been doing it right since day 2 of testing so shush! I did explain this in the A13 modders thread, however perhaps i didnt explain it well enough, or Tynan didnt, someone didnt.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Mightyrick1

So the gist of it is that if you're planning to add a building in your mod you should always start off defining the BuildingBase? Seems simple enough, thanks for the heads up. I've only done one building mod thus far and as much as I'd like to claim that I totally did it right because I had the know-how, it was pure dumb luck. Good thing to keep in mind for the future.
Amateur modder / YT LPer at www.tiny.cc/DDYoutube
mods : Elysian Flags - Mscarsonelle's theme

skullywag

and only define it once in your whole mod.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Rock5

I made the mistake when I updated my MoreSunLamps mod. I saw that BuildingBase is not defined in most of the core defs so I left it out and it seemed to work. After I released it I noticed that I could now uninstall my sun pillar. I did eventually figure out I needed the base def.

Correct me if I'm wrong but you don't strictly need to define the base def. You can define everything from the base def in your main object def and leave out the ParentName attribute. You only need to use and define a base def if you have multiple defs sharing attributes such as multiple wall type.
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

1000101

Confirmation from Tynan,

Rikiki and I have talked to Tynan (private messages) and got an "offical" response on this issue basically confirming the information presented here.

The abstracts are not intended to be scoped across mods and therefore if you use an abstract parent, you must define it.

Good luck modding, mods are what makes a game live beyond it's support life cycle,
1000101
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

Rikiki

Yep, confirming what 1000101 says! :)

The rule is: "Do not re-use Core abstract definitions in your mod!"
Just re-define it! ;)

Britnoth

Quote from: 1000101 on April 27, 2016, 03:08:59 PM
The abstracts are not intended to be scoped across mods and therefore if you use an abstract parent, you must define it.

Hmm, does that include using an abstract that is used in a definition you are replacing, not a new one?

I originally had all abstracts defined in my mods, but have intentionally removed them to duplicate the new xml I saw. :/

1000101

It doesn't matter if you are overriding an existing def or creating a new one, you must define the abstracts you are referencing.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By