Jump to content

how to extend a function that uses private class variables?


davidlallen

Recommended Posts

A lot of the uc classes use private variables, and then a class function refers to the variable. It seems that this coding style makes it impossible to replace the function. Is there some other approach we can use?

 

Suppose the original file W.uc is:

 

class W extends X;

var private Y;

function Z { ... something with Y }

 

This attempted new code fails to compile because a subclass cannot refer to a private variable:

 

class myW extends W;

function Z { ... something new with Y }

 

I could try replacing the entire class:

 

class myW extends X;

var private Y;

function Z { ... something new with Y }

 

This compiles OK. Then I add this line into XcomEngine.ini:

+ModClassOverrides=(BaseGameClass="W", ModClass="myW")

 

But, when I run this, myW is ignored, and the original unmodified W is used.

 

I have run around this circle a few times without getting anywhere. Are these functions unmoddable?

 

The details of my actual mod replacement are here:

 

http://forums.nexusmods.com/index.php?/topic/3802360-better-implementation-of-all-armor-options/&do=findComment&comment=34606180

 

Any help would be greatly appreciated.

Edited by davidlallen
Link to comment
Share on other sites

If it's private, you'll have to override the class.

 

There are two things to check if the override isn't working.

 

One is any class dependencies need to be declared in your override. So if the original class has a dependson(SomeOtherThing), your override needs to also have a dependson(SomeOtherThing). If it has a config(SomeIni), then yours also needs to have that config(SomeIni).

 

Two is the .ini needs to have a [Engine.Engine] header over it in the XComEngine.ini entry.

 

If you can override it, it's as simple as adding a getter function (or make that variable not private, that will work, too).

 

Scratch that line, it's untrue. Har har, confusing myself. If you can override it, you can re-declare your own private y and use it in your functions.

 

What class are you looking at trying to override? I can try to take a look if these two things still aren't working.

Edited by hairlessorphan
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...