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