I'm working on porting my Dynamic Features (Traits) and Effects scripts to MV.
In Ace I could just do this:
class RPG::BaseItem def features if <features were changed> return <changed features> else return @features end endendbecause $dataXYZ inherited from RPG::BaseItem.Now, in MV, there are no RPG::BaseItem classes - $dataXYZ is just an array of Objects.
So I think I can still do something similar, by creating a getter for effects and traits under Object, that will check a condition and return the modified traits/effects list, or the original one. But I'm not sure how to set a getter for Object, or how to make it refer to the real trait/effect without going into a recursive loop.
Any help appreciated.
The alternative is to override the functions that refer to .effects and .traits and I don't want to do that as I would have to overwrite them rather than alias them, and they're probably used by some of the battle plugins, which would result in incompatibility issues.
Edit: I tried the following just to see if I could get it to work, and a script call of console.log($dataActors[1].name) always prints out Harold. It doesn't even go into the getter.
In Ace I could just do this:
class RPG::BaseItem def features if <features were changed> return <changed features> else return @features end endendbecause $dataXYZ inherited from RPG::BaseItem.Now, in MV, there are no RPG::BaseItem classes - $dataXYZ is just an array of Objects.
So I think I can still do something similar, by creating a getter for effects and traits under Object, that will check a condition and return the modified traits/effects list, or the original one. But I'm not sure how to set a getter for Object, or how to make it refer to the real trait/effect without going into a recursive loop.
Any help appreciated.
The alternative is to override the functions that refer to .effects and .traits and I don't want to do that as I would have to overwrite them rather than alias them, and they're probably used by some of the battle plugins, which would result in incompatibility issues.
Edit: I tried the following just to see if I could get it to work, and a script call of console.log($dataActors[1].name) always prints out Harold. It doesn't even go into the getter.
Code:
(function() { Object.defineProperty(Object, "name", { get: function name() { if ($gameSwitches.value(10)) { return "overridden name"; } else { return this.name; } } });})();
Last edited by a moderator:
