- 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
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]
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,
});
}
}
}
Variable 1 = $skillCount[5].total
Value is: \v[1]


