Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // ICF-Soft Plugins - Time Utility
- // ICFSoft_TimeUtil.js
- //=============================================================================
- var Imported = Imported || {};
- Imported.ICFSoft_TimeUtil = true;
- var ICF = ICF || {};
- ICF.TimeUtil = ICF.TimeUtil || {};
- //=============================================================================
- /*:
- * @plugindesc v1.00 This plugin stores date and time in game variables
- * for diverse pourposes.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @param Year Var
- * @desc A variable where store year.
- * @default 0
- *
- * @param Month Var
- * @desc A variable where store month from 1 to 12.
- * @default 0
- *
- * @param Day Var
- * @desc A variable where store day from 1 to 31.
- * @default 0
- *
- * @param Hour Var
- * @desc A variable where store hour.
- * @default 0
- *
- * @param Minute Var
- * @desc A variable where store minute.
- * @default 0
- *
- * @param Week Var
- * @desc A variable where store the day of the week.
- * Week starts with Sunday as 0.
- * @default 0
- *
- * @param Month and day
- * @desc A variable where store a month and day combination.
- * @default 0
- *
- * @help
- * ============================================================================
- * Introduction
- * ============================================================================
- *
- * There are games where special things happen on specific day of the week,
- * specific hour, specific day, and so on.
- * There are games where time continues even when off.
- *
- * With this plugin you can do both.
- *
- * Time is stored in game variables and can be used inside events. Automatically
- * updates on map changes, but can also be updated manually.
- *
- * Also you can store time and check how many real time has passed.
- * Time is stored as minutes.
- *
- * ============================================================================
- * Parameters
- * ============================================================================
- *
- * There are six basic params to store current year, day, hour, etc.
- * These params indicate what variables will be used to store that info.
- * To skip a param put 0.
- *
- * Month and day comes in a special format because events can use only one
- * variable per page. So it needs a combined one. Is Month*100 + Day.
- * Some Month-Day Examples:
- * - 101: January 1st
- * - 102: January 2nd
- * - 201: February 1st
- * - 211: February 11th
- * - 1001: October 1st
- * - 1010: October 10th
- *
- * ============================================================================
- * Plugin commands
- * ============================================================================
- *
- * GetTime x
- *
- * - To store a time into variable number 'x'.
- *
- * GetTimeSince x y
- * GetHoursSince x y
- * GetDaysSince x y
- *
- * - To compare how much time passed since 'x' in minutes, hours or days
- * and store result in variable 'y'.
- *
- * UpdateTime
- *
- * - To update time variables manually.
- *
- * ============================================================================
- * Incompatibilities
- * ============================================================================
- *
- * There's no known incompatible plugins yet.
- *
- * ============================================================================
- * Known isues
- * ============================================================================
- *
- * There's no known isues yet.
- *
- * ============================================================================
- *
- * Commercial use avaiable.
- * Credit to ICF-Soft.
- * This entire header must be included with plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- /*:es
- * @plugindesc v1.00 This plugin stores date and time in game variables
- * for diverse pourposes.
- * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
- *
- * @param Year Var
- * @desc La variable donde almacenas el año.
- * @default 0
- *
- * @param Month Var
- * @desc La variable donde almacenas el mes (de 1 a 12).
- * @default 0
- *
- * @param Day Var
- * @desc La variable donde almacenas el día (de 1 a 31).
- * @default 0
- *
- * @param Hour Var
- * @desc La variable donde almacenas la hora.
- * @default 0
- *
- * @param Minute Var
- * @desc La variable donde almacenas los minutos.
- * @default 0
- *
- * @param Week Var
- * @desc La variable donde almacenas el día de la semana.
- * La semana empieza con el domingo como 0.
- * @default 0
- *
- * @param Month and day
- * @desc Una variable especial donde se almacena una combinación de mes y día.
- * @default 0
- *
- * @help
- * ============================================================================
- * Introducción
- * ============================================================================
- *
- * Hay juegos en donde ciertos eventos solo pasan en un día, día de la semana,
- * hora o incluso minuto específico.
- * También los hay en los que el tiempo pasa aunque no estés jugando.
- *
- * Con este complemento puedes hacer ambas cosas.
- *
- * El tiempo se almacena en variables a las que se puede acceder en los eventos.
- * Se actualiza en cada cambio de mapa, pero también con comando.
- *
- * Además puedes guardar una fecha y comparar cuanto tiempo real ha pasado.
- * El tiempo se almacena en minutos.
- *
- * ============================================================================
- * Parámetros
- * ============================================================================
- *
- * Hay seis parámetros básicos donde almacenar el año, mes, día, hora, etc.
- * Indican qué variables se van a utilizar para almacenar esa info.
- * Para saltar un parámetro dejar en 0.
- *
- * Month and day comes usa un formato especial porque los eventos solo pueden
- * usar una variable por página. Así que necesita una combinada.
- * Viene en Mes*100 + Día.
- * Algunos ejemplos:
- * - 101: 1 de Enero
- * - 102: 2 de Enero
- * - 201: 1 de Febrero
- * - 211: 11 de Febrero
- * - 1001: 1 de Octubre
- * - 1010: 10 de Octubre
- *
- * ============================================================================
- * Comandos de complemento
- * ============================================================================
- *
- * GetTime x
- *
- * - Para almacenar el tiempo en la variable número 'x'.
- *
- * GetTimeSince x y
- * GetHoursSince x y
- * GetDaysSince x y
- *
- * - Para comparar cuanto tiempo ha pasado desde 'x' en minutos, horas or días
- * y almacenar el resultado en la variable 'y'.
- *
- * UpdateTime
- *
- * - Para actualizar manualmente las variables.
- *
- * ============================================================================
- * Incompatibilidades
- * ============================================================================
- *
- * No se conocen complementos que sean incompatibles hasta la fecha.
- *
- * ============================================================================
- * Problemas conocidos
- * ============================================================================
- *
- * No hay problemas hasta la fecha.
- *
- * ============================================================================
- *
- * Se permite el uso comercial.
- * Se debe incluir a ICF-Soft en los créditos.
- * Esta cabecera debe incluirse íntegramente con el plugin.
- *
- * ============================================================================
- */
- //=============================================================================
- //=============================================================================
- // Parameter Variables
- //=============================================================================
- ICF.Parameters = PluginManager.parameters('ICFSoft_TimeUtil');
- ICF.Param = ICF.Param || {};
- ICF.Param.TimeVars = [];
- ICF.Param.TimeVars[0] = Number(ICF.Parameters['Year Var']);
- ICF.Param.TimeVars[1] = Number(ICF.Parameters['Month Var']);
- ICF.Param.TimeVars[2] = Number(ICF.Parameters['Day Var']);
- ICF.Param.TimeVars[3] = Number(ICF.Parameters['Hour Var']);
- ICF.Param.TimeVars[4] = Number(ICF.Parameters['Minute Var']);
- ICF.Param.TimeVars[5] = Number(ICF.Parameters['Week Var']);
- ICF.Param.TimeVars[6] = Number(ICF.Parameters['Month and day']);
- //=============================================================================
- // Time Utilities
- //=============================================================================
- ICF.TimeUtil.GetTime = function(varid) {
- var Today = new Date();
- $gameVariables.setValue(varid, parseInt(Today.getTime()/60000));
- }
- ICF.TimeUtil.GetTimeSince = function(varid, resid = 0) {
- var Today = new Date();
- if (resid == 0) {return (parseInt(Today.getTime()/60000) - $gameVariables.value(varid));}
- $gameVariables.setValue(resid, parseInt(Today.getTime()/60000) - $gameVariables.value(varid));
- }
- ICF.TimeUtil.GetHoursSince = function(varid, resid = 0) {
- if (resid == 0) {return (ICF.TimeUtil.GetTimeSince(varid)/60)};
- var Today = new Date();
- $gameVariables.setValue(resid, parseInt((Today.getTime()/60000) - $gameVariables.value(varid))/60);
- }
- ICF.TimeUtil.GetDaysSince = function(varid, resid = 0) {
- if (resid == 0) {return (ICF.TimeUtil.GetTimeSince(varid)/1440)};
- var Today = new Date();
- $gameVariables.setValue(resid, parseInt((Today.getTime()/60000) - $gameVariables.value(varid))/1440);
- }
- ICF.TimeUtil.GetDate = function() {
- var Today = new Date();
- if (ICF.Param.TimeVars[0] > 0) {$gameVariables.setValue(ICF.Param.TimeVars[0], Today.getFullYear());}
- if (ICF.Param.TimeVars[1] > 0) {$gameVariables.setValue(ICF.Param.TimeVars[1], Today.getMonth() + 1);}
- if (ICF.Param.TimeVars[2] > 0) {$gameVariables.setValue(ICF.Param.TimeVars[2], Today.getDate());}
- if (ICF.Param.TimeVars[3] > 0) {$gameVariables.setValue(ICF.Param.TimeVars[3], Today.getHours());}
- if (ICF.Param.TimeVars[4] > 0) {$gameVariables.setValue(ICF.Param.TimeVars[4], Today.getMinutes());}
- if (ICF.Param.TimeVars[5] > 0) {$gameVariables.setValue(ICF.Param.TimeVars[5], Today.getDay());}
- if (ICF.Param.TimeVars[6] > 0) {
- $gameVariables.setValue(ICF.Param.TimeVars[6], Today.getMonth() * 100 + Today.getDate() + 100);
- }
- }
- //=============================================================================
- // Game_Interpreter
- //=============================================================================
- ICF.TimeUtil.pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- ICF.TimeUtil.pluginCommand.call(this, command, args);
- if (command === 'GetTime') {
- ICF.TimeUtil.GetTime(args[0]);
- } else if (command === 'GetTimeSince') {
- ICF.TimeUtil.GetTimeSince(args[0], args[1]);
- } else if (command === 'GetHoursSince') {
- ICF.TimeUtil.GetHoursSince(args[0], args[1]);
- } else if (command === 'GetDaysSince') {
- ICF.TimeUtil.GetDaysSince(args[0], args[1]);
- } else if (command === 'UpdateTime') {
- ICF.TimeUtil.GetDate();
- }
- };
- //=============================================================================
- // Game_Map
- //=============================================================================
- ICF.TimeUtil.mapsetup = Game_Map.prototype.setup;
- Game_Map.prototype.setup = function(mapId) {
- ICF.TimeUtil.GetDate();
- ICF.TimeUtil.mapsetup.call(this, mapId);
- };
- //=============================================================================
- // End of File
- //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement