Reference error - not defined

Desbrina

Warper
Member
Joined
Sep 2, 2013
Messages
3
Reaction score
0
First Language
English
Primarily Uses
I'm trying to use a script that was done a while ago but I'm getting a reference error with it.
The script is supposed to count how many times a skill has been used in battle and keep a record of it.
Theres no errors in the battle itself, only when referencing from an event.

The script is
Code:
//=============================================================================
//LudoSkillCount.js
//=============================================================================

/*:
 * @plugindesc Counts the amount of times a skill has been used in a single battle, and over the course of the game.
 * @author Alessio De Santis
 *
 *
 * @help
 * Access the values by using script commands.
 * $skillCount[skillId].battle for the amounts of times used in a battle (value is saved until next battle)
 * $skillCount[skillId].total for the total amounts of times used in all battles.
 */  


 //-----------------------------------------------------------------------------

$skillCount = [];


 Scene_Battle.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    this.startFadeIn(this.fadeSpeed(), false);
    BattleManager.playBattleBgm();
    BattleManager.startBattle();
 };



BattleManager.startBattle = function() {
    this._phase = 'start';
   

    $gameSystem.onBattleStart();
    $gameParty.onBattleStart();
    $gameTroop.onBattleStart();
    this.displayStartMessages();
};

BattleManager.startAction = function() {
    var subject = this._subject;
    var action = subject.currentAction();
    var targets = action.makeTargets();
    this._phase = 'action';
    this._action = action;
    this._targets = targets;
    subject.useItem(action.item());
   
    this.increment(action.item().id);

    this._action.applyGlobal();
    this.refreshStatus();
    this._logWindow.startAction(subject, action, targets);
};

Scene_Title.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this.createBackground();
    this.createForeground();
    this.createWindowLayer();
    this.createCommandWindow();

    this.initSC();
};

BattleManager.increment = function(id) {
    if(id != 0){
        $skillCount[id-1].battle++;
        $skillCount[id-1].total++;
    }
}

BattleManager.resetSC = function() {
    for(i of $skillCount){
        i.battle = 0;
    }
}

Scene_Title.prototype.initSC = function(){
    var temp = $dataSkills;
    for(i of temp){
        for(j in i){
            if (j == "name") {
                for(k of $skillCount) {
                    if(k.name == i[j]){
                        return console.log($skillCount);
                    }
                }
                $skillCount.push({
                    name : i[j],
                    battle : 0,
                    total : 0,
                });
            }
        }
       
    }
In the event, I'm simply trying to assign to a variable and print the value.
Variable 1 = $skillCount[5].total
Value is: \v[1]
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
How many skills does your game have?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
it would help to get a screenshot of the console output of the error you're getting, because that error can have dozens of different causes.
Play the game until you get the error, then press F8 and give us a screenshot of the console output.
Note: make sure that it's the console because some browsers open the developer functions on the elements instead of the console, and we need the console output.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
As an aside, I don't see anything in there that supports the claim that it keeps track over the entire game. There is nothing that saves the figures or loads them, and in fact from what I can tell, as soon as you return to the title screen, everything will be reset to 0.

If you want to track the number of times skills were used over the entire game, you're going to need a different plugin, or a rewrite of this one.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top