Hello everyone.
I was making an action farm simulation RPG.
Since I am a beginner, I had a hard time creating a plugin.
I created a time system plugin with the help of ChatGPT.
Can you take a look at the contents of this plugin?
Please let me know if anything is missing.
I was making an action farm simulation RPG.
Since I am a beginner, I had a hard time creating a plugin.
I created a time system plugin with the help of ChatGPT.
Can you take a look at the contents of this plugin?
Please let me know if anything is missing.
//=============================================================================
// MyTimeSystem.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Simple Time System Plugin
* @Author Your Name
*
* ----------------------------------------------------------------------------
* This plugin provides a simple time system for your game.
* ----------------------------------------------------------------------------
*
* @param GameSpeed
* @text Game Speed (minutes per frame)
* @desc The speed at which time progresses in the game. Lower values make time pass more slowly.
* @type number
* @Default 1
*
* @param DayStartHour
* @text Day Start Hour
* @desc The hour at which each day starts.
* @type number
* @Default 6
*
* @param DayEndHour
* @text Day End Hour
* @desc The hour at which each day ends.
* @type number
* @Default 12
*
* @param SleepHour
* @text Sleep Hour
* @desc The hour at which the character goes to sleep and advances to the next day.
* @type number
* @Default 12
*
* @param DaysInWeek
* @text Days In Week
* @desc The number of days in a week.
* @type number
* @Default 7
*
* @param SeasonsInYear
* @text Seasons In Year
* @desc The number of seasons in a year.
* @type number
* @Default 4
*/
(function() {
var parameters = PluginManager.parameters('MyTimeSystem');
var gameSpeed = Number(parameters['GameSpeed'] || 1);
var dayStartHour = Number(parameters['DayStartHour'] || 6);
var dayEndHour = Number(parameters['DayEndHour'] || 12);
var sleepHour = Number(parameters['SleepHour'] || 12);
var daysInWeek = Number(parameters['DaysInWeek'] || 7);
var seasonsInYear = Number(parameters['SeasonsInYear'] || 4);
var seasonNames = ['Spring', 'Summer', 'Fall', 'Winter'];
var weekDayNames = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
var currentSeasonIndex = 0;
var dayCount = 0;
function Window_TimeDisplay() {
this.initialize.apply(this, arguments);
}
Window_TimeDisplay.prototype = Object.create(Window_Base.prototype);
Window_TimeDisplay.prototype.constructor = Window_TimeDisplay;
Window_TimeDisplay.prototype.initialize = function(rect) {
Window_Base.prototype.initialize.call(this, rect);
this.refresh();
};
Window_TimeDisplay.prototype.refresh = function() {
this.contents.clear();
this.drawText($gameSystem.getFormattedSeason(), 0, 0, this.contents.width, 'center');
};
Window_TimeDisplay.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (this.needsRefresh()) {
this.refresh();
}
};
Window_TimeDisplay.prototype.needsRefresh = function() {
return $gameSystem._minute !== $gameSystem._lastMinute;
};
Game_System.prototype.initializeTimeVariables = function() {
this._minute = 0;
this._hour = dayStartHour;
this._day = 1;
this._weekDay = 1;
this._month = 1;
this._year = 1;
this._season = seasonNames[currentSeasonIndex];
};
Game_System.prototype.advanceToNextDay = function() {
this._day++;
this._weekDay = (this._weekDay % daysInWeek) + 1;
if (this._day > seasonsInYear * 28) {
this._day = 1;
this._month++;
if (this._month > seasonsInYear) {
this._month = 1;
this._year++;
currentSeasonIndex = (currentSeasonIndex + 1) % seasonNames.length;
this._season = seasonNames[currentSeasonIndex];
}
}
dayCount++;
this._hour = dayStartHour;
};
Game_System.prototype.getFormattedSeason = function() {
return this._season;
};
Game_System.prototype.getFormattedDate = function() {
var month = this._month !== undefined ? this._month : 1;
var day = this._day !== undefined ? this._day : 1;
var year = this._year !== undefined ? this._year : 1;
return month.padZero(2) + '/' + day.padZero(2) + '/' + year.padZero(4);
};
Game_System.prototype.getFormattedWeekDay = function() {
return weekDayNames[this._weekDay - 1];
};
Game_System.prototype.getFormattedTime = function() {
var hour = this._hour !== undefined ? this._hour : 0;
var minute = this._minute !== undefined ? this._minute : 0;
return hour.padZero(2) + ':' + minute.padZero(2);
};
var _Game_System_update = Game_System.prototype.update;
Game_System.prototype.update = function(sceneActive) {
_Game_System_update.call(this, sceneActive);
this.updateTime();
};
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command.toLowerCase() === 'initializetimevariables') {
$gameSystem.initializeTimeVariables();
}
};
})();
// MyTimeSystem.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Simple Time System Plugin
* @Author Your Name
*
* ----------------------------------------------------------------------------
* This plugin provides a simple time system for your game.
* ----------------------------------------------------------------------------
*
* @param GameSpeed
* @text Game Speed (minutes per frame)
* @desc The speed at which time progresses in the game. Lower values make time pass more slowly.
* @type number
* @Default 1
*
* @param DayStartHour
* @text Day Start Hour
* @desc The hour at which each day starts.
* @type number
* @Default 6
*
* @param DayEndHour
* @text Day End Hour
* @desc The hour at which each day ends.
* @type number
* @Default 12
*
* @param SleepHour
* @text Sleep Hour
* @desc The hour at which the character goes to sleep and advances to the next day.
* @type number
* @Default 12
*
* @param DaysInWeek
* @text Days In Week
* @desc The number of days in a week.
* @type number
* @Default 7
*
* @param SeasonsInYear
* @text Seasons In Year
* @desc The number of seasons in a year.
* @type number
* @Default 4
*/
(function() {
var parameters = PluginManager.parameters('MyTimeSystem');
var gameSpeed = Number(parameters['GameSpeed'] || 1);
var dayStartHour = Number(parameters['DayStartHour'] || 6);
var dayEndHour = Number(parameters['DayEndHour'] || 12);
var sleepHour = Number(parameters['SleepHour'] || 12);
var daysInWeek = Number(parameters['DaysInWeek'] || 7);
var seasonsInYear = Number(parameters['SeasonsInYear'] || 4);
var seasonNames = ['Spring', 'Summer', 'Fall', 'Winter'];
var weekDayNames = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
var currentSeasonIndex = 0;
var dayCount = 0;
function Window_TimeDisplay() {
this.initialize.apply(this, arguments);
}
Window_TimeDisplay.prototype = Object.create(Window_Base.prototype);
Window_TimeDisplay.prototype.constructor = Window_TimeDisplay;
Window_TimeDisplay.prototype.initialize = function(rect) {
Window_Base.prototype.initialize.call(this, rect);
this.refresh();
};
Window_TimeDisplay.prototype.refresh = function() {
this.contents.clear();
this.drawText($gameSystem.getFormattedSeason(), 0, 0, this.contents.width, 'center');
};
Window_TimeDisplay.prototype.update = function() {
Window_Base.prototype.update.call(this);
if (this.needsRefresh()) {
this.refresh();
}
};
Window_TimeDisplay.prototype.needsRefresh = function() {
return $gameSystem._minute !== $gameSystem._lastMinute;
};
Game_System.prototype.initializeTimeVariables = function() {
this._minute = 0;
this._hour = dayStartHour;
this._day = 1;
this._weekDay = 1;
this._month = 1;
this._year = 1;
this._season = seasonNames[currentSeasonIndex];
};
Game_System.prototype.advanceToNextDay = function() {
this._day++;
this._weekDay = (this._weekDay % daysInWeek) + 1;
if (this._day > seasonsInYear * 28) {
this._day = 1;
this._month++;
if (this._month > seasonsInYear) {
this._month = 1;
this._year++;
currentSeasonIndex = (currentSeasonIndex + 1) % seasonNames.length;
this._season = seasonNames[currentSeasonIndex];
}
}
dayCount++;
this._hour = dayStartHour;
};
Game_System.prototype.getFormattedSeason = function() {
return this._season;
};
Game_System.prototype.getFormattedDate = function() {
var month = this._month !== undefined ? this._month : 1;
var day = this._day !== undefined ? this._day : 1;
var year = this._year !== undefined ? this._year : 1;
return month.padZero(2) + '/' + day.padZero(2) + '/' + year.padZero(4);
};
Game_System.prototype.getFormattedWeekDay = function() {
return weekDayNames[this._weekDay - 1];
};
Game_System.prototype.getFormattedTime = function() {
var hour = this._hour !== undefined ? this._hour : 0;
var minute = this._minute !== undefined ? this._minute : 0;
return hour.padZero(2) + ':' + minute.padZero(2);
};
var _Game_System_update = Game_System.prototype.update;
Game_System.prototype.update = function(sceneActive) {
_Game_System_update.call(this, sceneActive);
this.updateTime();
};
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if (command.toLowerCase() === 'initializetimevariables') {
$gameSystem.initializeTimeVariables();
}
};
})();