RPG Maker Forums

I'm trying to port the RGSS3 script I made (a script that changes the color of the HP bar depending on the remaining HP). I have wrote most of the logic, but for some reason, it gives me a ReferenceError "actor is not defined".


The code:


hpTextColorPicker = function() {
if (actor.hp < actor.mhp * CriticalHPLimit) return this.textColor(CriticalHPText);
else if (actor.hp > actor.mhp * CriticalHPLimit && actor.hp < actor.mhp * LowHPLimit) return this.textColor(HPLowText);
else return systemColor();
};

hpbarColorPicker1 = function() {
if (actor.hp < actor.mhp * CriticalHPLimit) return this.textColor(CriticalHPBar1);
else if (actor.hp > actor.mhp * CritialHPLimit && actor.hp < actor.mhp * LowHPLimit) return this.textColor(HPBarLow1);
else if (CompatMode == true) hpGaugeColor1();
else return this.textColor(HPNormalBar1);
};

hpbarColorPicker2 = function() {
if (actor.hp < actor.mhp * CriticalHPLimit) return this.textColor(CriticalHPBar2);
else if (actor.hp > actor.mhp * CritialHPLimit && actor.hp < actor.mhp * LowHPLimit) return this.textColor(HPBarLow2);
else if (CompatMode == true) hpGaugeColor2();
else return this.textColor(HPNormalBar2);
};

Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
width = width || 186;
var color1 = this.hpGaugeColor1();
var color2 = this.hpGaugeColor2();
this.drawGauge(x, y, width, actor.hpRate(), hpbarColorPicker1(), hpbarColorPicker2());
this.changeTextColor(this.hpTextColorPicker());
this.drawText(TextManager.hpA, x, y, 44);
this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
this.hpColor(actor), this.normalColor());
};




This is the error I'm getting:


ReferenceError: actor is not defined
    at hpbarColorPicker1 (<assume game folder>/js/plugins/HPColor.js:76)
    at Window_MenuStatus.Window_Base.drawActorHp (<assume game folder>/js/plugins/HPColor.js:93)
    at Window_MenuStatus.Window_Base.drawActorSimpleStatus (rpg_windows.js:592)
    at Window_MenuStatus.drawItemStatus (rpg_windows.js:1763)
    at Window_MenuStatus.drawItem (rpg_windows.js:1736)
    at Window_MenuStatus.Window_Selectable.drawAllItems (rpg_windows.js:1250)
    at Window_MenuStatus.Window_Selectable.refresh (rpg_windows.js:1277)
    at Window_MenuStatus.initialize (rpg_windows.js:1703)
    at new Window_MenuStatus (rpg_windows.js:1690)
    at Scene_Menu.createStatusWindow (rpg_scenes.js:808)rpg_managers.js:1756 SceneManager.catchException

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,578
Members
137,843
Latest member
Betwixt000
Top