Ludeon Forums

Ludeon Forums

  • July 13, 2020, 01:37:52 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4

Author Topic: MODDERS PLEASE READ, Abstracts and how they should be used.  (Read 19678 times)

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
MODDERS PLEASE READ, Abstracts and how they should be used.
« on: April 25, 2016, 05:10:45 PM »

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. 

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]
« Last Edit: February 10, 2017, 06:56:17 PM by milon »
Logged
(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

  • Global Moderator
  • Transcendent
  • ***
  • Posts: 5857
  • Engineer
    • View Profile
Re: A note to modders about xml definitions
« Reply #1 on: April 25, 2016, 05:36:06 PM »

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

cuproPanda

  • Colonist
  • ***
  • Posts: 644
  • Caffeine addiction
    • View Profile
    • GitHub
Re: A note to modders about xml definitions
« Reply #2 on: April 25, 2016, 07:04:43 PM »

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.
Logged
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

  • Global Moderator
  • Transcendent
  • ***
  • Posts: 5857
  • Engineer
    • View Profile
Re: A note to modders about xml definitions
« Reply #3 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.
Logged
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

cuproPanda

  • Colonist
  • ***
  • Posts: 644
  • Caffeine addiction
    • View Profile
    • GitHub
Re: A note to modders about xml definitions
« Reply #4 on: April 25, 2016, 08:03:56 PM »

you cant have a file with nothing but abstracts in, you must have 1 complete def i believe.
This is true.
Logged
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

  • Colonist
  • ***
  • Posts: 372
  • Resident Polemicist
    • View Profile
Re: A note to modders about xml definitions
« Reply #5 on: April 26, 2016, 12:27:44 AM »

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

Shinzy

  • Battering ram
  • Global Moderator
  • Transcendent
  • ****
  • Posts: 3060
  • Ramming speeed!
    • View Profile
    • My mods, all of them!
Re: A note to modders about xml definitions
« Reply #6 on: April 26, 2016, 03:27:59 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!)




Logged

skullywag

  • Global Moderator
  • Transcendent
  • ***
  • Posts: 5857
  • Engineer
    • View Profile
Re: A note to modders about xml definitions
« Reply #7 on: April 26, 2016, 05:07:05 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.
Logged
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Mightyrick1

  • Drifter
  • **
  • Posts: 54
  • A YouTuber that dabbles in Rimworld modding
    • View Profile
    • My Youtube Channel
Re: A note to modders about xml definitions
« Reply #8 on: April 26, 2016, 08:00:56 AM »

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.
Logged
Amateur modder / YT LPer at www.tiny.cc/DDYoutube
mods : Elysian Flags - Mscarsonelle's theme

skullywag

  • Global Moderator
  • Transcendent
  • ***
  • Posts: 5857
  • Engineer
    • View Profile
Re: A note to modders about xml definitions
« Reply #9 on: April 26, 2016, 08:12:16 AM »

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

Rock5

  • Colonist
  • ***
  • Posts: 748
  • Schizoid
    • View Profile
Re: A note to modders about xml definitions
« Reply #10 on: April 27, 2016, 05:39:10 AM »

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.
Logged
Rock5 [B18] Mods
- Butchers Can Count Meat
- Sun Lamp Planner
- JTZoneButtons
- RimSearch
- JTExport

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
Re: A note to modders about xml definitions
« Reply #11 on: April 27, 2016, 03:08:59 PM »

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
Logged
(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

  • Colonist
  • ***
  • Posts: 966
    • View Profile
Re: A note to modders about xml definitions
« Reply #12 on: April 27, 2016, 04:46:34 PM »

Yep, confirming what 1000101 says! :)

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

Britnoth

  • Colonist
  • ***
  • Posts: 357
  • Refugee
    • View Profile
Re: A note to modders about xml definitions
« Reply #13 on: April 28, 2016, 09:43:11 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. :/
Logged

1000101

  • Planetologist
  • ****
  • Posts: 1344
  • RimFortress Builder
    • View Profile
Re: A note to modders about xml definitions
« Reply #14 on: April 29, 2016, 11:57:31 AM »

It doesn't matter if you are overriding an existing def or creating a new one, you must define the abstracts you are referencing.
Logged
(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
Pages: [1] 2 3 4