查看: 6928|回复: 6

[已经解决] 关于变量设置

[复制链接]
梦石
0
星屑
72
在线时间
14 小时
注册时间
2016-5-28
回帖
9
发表于 2016-5-28 03:41:59 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
关于变量有两个问题想要请教大神们。
1.变量的表示可否带入非数字?就是 \V[n] 的表示方法,我希望让变量的数字为1时对话时表示为A,2时为B以此类推,虽然使用条件分歧也可以,但是无法直接表示吗?

2.是否能够做出关闭游戏之后也不会变化的变量?类似二周目那种,通关之后再开游戏也依然不会重置的变量?
梦石
2
星屑
34507
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

发表于 2016-5-28 12:13:33 | 显示全部楼层
1不能
2只要还是一个存档,变量就不会变
回复

使用道具 举报

梦石
0
星屑
6963
在线时间
1557 小时
注册时间
2011-6-14
回帖
425
发表于 2016-5-29 00:41:02 来自手机 | 显示全部楼层
YEP.104 – New Game+ – RPG Maker MV
Introduction
This plugin requires YEP_SaveCore. Make sure this plugin is located under YEP_SaveCore in the plugin list.

这个插件需要YEP_SaveCore,确保它放在YEP_SaveCore下面

New Game+ is a great way to provide replay value for your game. It lets the player re-experience the game in a different way with either carried over items, to carried over party members, to carried over skills, switches, and variables even. There exists many options to change how New Game+ will work for your game.

新游戏拓展是一个很好的方式来提供游戏重玩的初始值。它可以让玩家重新体验游戏,但是可以携带之前的物品,角色,技能,甚至开关或者变量。这里有很多游戏来设置你的二周目游戏。

Notetags
There are some notetags you can utilize with a few database objects.

这里是一些你可以设置的标签

Actor, Item, Weapon, Armor Notetag
复制代码
– This will prevent the item, weapon, or armor from being carried over to New Game+. If this is used on an actor, the actor will be in its default state as if a new game started.

这可以阻止特定的物品,武器,护甲被携带到二周目。如果用于角色,则这个角色将会在游戏开始时初始化。
回复

使用道具 举报

梦石
0
星屑
72
在线时间
14 小时
注册时间
2016-5-28
回帖
9
 楼主| 发表于 2016-5-29 11:32:22 | 显示全部楼层
347780682 发表于 2016-5-29 00:41
YEP.104 – New Game+ – RPG Maker MV
Introduction
This plugin requires YEP_SaveCore. Make sure this  ...

这个插件似乎正是我所需要的,
请问大神能够提供一下详细的用法吗?
我希望的只是将某个特定的变量或开关带到二周目。
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2016-5-29 12:21:14 | 显示全部楼层
http://utakata-no-yume.net/gallery/plugin/tkmv/cmn_save/
共有セーブデータ
CU32P.png
CommonSave load         共有セーブデータからスイッチ・変数を読み込み反映させます。
任意のタイミングで共有セーブデータのロードを行いたい場合に使用します。
CommonSave save         共有セーブデータにスイッチ・変数の状態を記録します。
共有セーブデータが存在しない場合は新規に生成します。
任意のタイミングで共有セーブデータのセーブを行いたい場合に使用します。
CommonSave remove         共有セーブデータを削除します。
共有セーブデータの状態をリセットしたい場合に使用します。
CommonSave setTrace [true|false]         (ver1.20にて実装)
コンソールにトレースを出力するかを設定します。
ゲーム実行中にトレース状態を切り替えたい場合に使用します。
(例) CommonSave setTrace true
=> コンソールにトレースを出力するように。
CommonSave check         (ver1.20にて実装)
共有状態になっているスイッチ・変数番号をコンソールに表示し確認します。




UTA_CommonSave.js
  1. //=============================================================================
  2. // UTA_CommonSave.js
  3. //=============================================================================
  4. // Version    : 1.20
  5. // LastUpdate : 2016.05.11
  6. // Author     : T.Akatsuki
  7. // Website    : [url]http://utakata-no-yume.net/[/url]
  8. // License    : MIT License([url]http://opensource.org/licenses/mit-license.php[/url])
  9. //=============================================================================

  10. //=============================================================================
  11. /*:
  12. * @plugindesc Create a share save data. Share state of game switch and variables between each save data.
  13. * @author T.Akatsuki
  14. *
  15. * @param Target Switches
  16. * @desc Set target switch index number.
  17. * If you want to set multiple, put comma between indexes.
  18. * Using "-", the range can be specified.
  19. * (ex) 1-3,11,12,13,20,21
  20. * @default
  21. *
  22. * @param Target Variables
  23. * @desc Set target variable index number.
  24. * If you want to set multiple, put comma between indexes.
  25. * Using "-", the range can be specified.
  26. * (ex) 1-5,11,12,13,23,24
  27. * @default
  28. *
  29. * @param Is Auto
  30. * @desc Automatically to set save / load common save data on save / load timing.
  31. * true  : Automatically common save data is saved/loaded on save / load timing.
  32. * false : Save and load of common save data you do manually.
  33. * @default true
  34. *
  35. * @param Auto on Gameover
  36. * @desc If auto saving common save data is enabled , it automatically saves common save data on gameover.
  37. * true  : It save common save data on game over.
  38. * false : It do nothing on game over.
  39. * @default false
  40. *
  41. * @param Show Trace
  42. * @desc Set state traces display.
  43. * true  : Show trace., false : Don't show trace.
  44. * @default false
  45. *
  46. * @help # Overview
  47. * Create a share save data. Share state of game switch and variables between each save data.
  48. * If you use plugin command, you can operate common save data at any time.
  49. *
  50. * Common save data will be saved with a name "common.rpgsave" below save directory.
  51. *
  52. * # Parameters
  53. *   Target Switches [Switch No, ...]
  54. *     Set target switch index number.
  55. *     If you want to set multiple, put comma between indexes.
  56. *     Using "-", the range can be specified.
  57. *     (Ex) 1-3,11,12,13,20,21
  58. *            => number 1,2,3,11,12,13,20,21 switches are target.
  59. *
  60. *   Target Variables [Valiable No, ...]
  61. *     Set target variable index number.
  62. *     If you want to set multiple, put comma between indexes.
  63. *     Using "-", the range can be specified.
  64. *     (Ex) 1-3,11,12,13,14,15
  65. *            => number 1,2,3,11,12,13,14,15 variables are target.
  66. *
  67. *   Is Auto [true|false]
  68. *     Automatically to set save / load common save data on save / load timing.
  69. *
  70. *   Auto on Gameover [true|false]
  71. *     If auto saving common save data is enabled , it automatically saves common save data on gameover.
  72. *
  73. *   Show Trace [true|false]
  74. *     Set whether the issue a trace for debugging.
  75. *
  76. * # Plugin Command
  77. *   CommonSave load                  # Read GameSwitches and GameVariables from common save data and apply game data.
  78. *                                    # This command is used when you want to load common save data at any time.
  79. *   CommonSave save                  # Save target GameSwitches and GameVariables common save data.
  80. *                                    # This command is used when you want to save in common save data at any time.
  81. *   CommonSave remove                # Remove common save data file.
  82. *
  83. *   CommonSave setTrace [true|false] # Setting to enabled trace on console.
  84. *
  85. *   CommonSave check                 # Show sharing target switches and variables to console.
  86. *
  87. * # Change Log
  88. *   ver 1.20 (2016.05.11)
  89. *     Using "-", the range can be specified.
  90. *     Add setTrace plugin command.
  91. *     Add check plugin command.
  92. *
  93. *   ver 1.10 (Fed 17, 2016)
  94. *     Rename to UTA_CommonSave.js.
  95. *     To be able to set trace in the parameter.
  96. *
  97. *   ver1.01 (Jan 14, 2016)
  98. *     Fixed bug where could not share variables.
  99. *
  100. *   ver1.00 (Dec 31, 2015)
  101. *     To ver1.00 according to the Japanese version of RPG Maker MV.
  102. *
  103. *   ver0.01 (Nov 05, 2015)
  104. *     Initial release.
  105. */

  106. /*:ja
  107. * @plugindesc 共有のセーブデータを作成し、指定したスイッチ・変数の状態をセーブデータ間で共有します。
  108. * @author 赤月 智平
  109. *
  110. * @param Target Switches
  111. * @desc 対象となるスイッチの番号を指定します。
  112. * カンマ区切りで複数指定、ハイフンで範囲指定が可能です。
  113. * (例) 1-3,11,12,13,20,21
  114. * @default
  115. *
  116. * @param Target Variables
  117. * @desc 対象となる変数の番号を指定します。
  118. * カンマ区切りで複数指定、ハイフンで範囲指定が可能です。
  119. * (例) 1-5,11,12,13,23,24
  120. * @default
  121. *
  122. * @param Is Auto
  123. * @desc セーブ・ロード時に自動的に共通セーブデータのセーブ・ロードを行うかを設定します。
  124. *       true  : セーブ・ロード時に自動的に共有セーブデータにデータのセーブ・ロードを行う。
  125. *       false : 共通セーブデータのセーブ・ロードは手動で行う。
  126. * @default true
  127. *
  128. * @param Auto on Gameover
  129. * @desc 自動セーブ設定がONの時にゲームオーバー時に共有セーブデータの自動セーブを行うかを設定します。
  130. *       true  : ゲームオーバー時に自動共有セーブを行う。
  131. *       false : ゲームオーバー時は自動共有セーブを行わない。
  132. * @default false
  133. *
  134. * @param Show Trace
  135. * @desc デバッグ用のトレースを出すかを設定します。
  136. * true: トレースを表示, false: トレースを表示しない
  137. * @default false
  138. *
  139. * @help ■概要
  140. * CommonSaveプラグインは共有セーブデータを作成し、指定したスイッチ・変数の状態をセーブデータ間で共有する事ができます。
  141. * 基本的にはセーブ・ロード時に設定に応じて自動的に処理してくれます。
  142. * プラグインコマンドを利用すると、任意のタイミングで共有セーブデータの操作を行う事ができます。
  143. *
  144. * 共有セーブデータはsaveディレクトリ以下に「common.rpgsave」という名前で保存されます。
  145. *
  146. * ■パラメータの説明
  147. *   Target Switches [スイッチ番号, ...]
  148. *     共有したいスイッチの番号を指定します。「,」で区切り複数の値を指定する事ができます。
  149. *     「-」で数値の範囲を指定する事も可能です。
  150. *     (例) 1-3,11,12,13,20,21
  151. *            => 1,2,3,11,12,13,20,21番のスイッチが対象になる。
  152. *
  153. *   Target Variables [変数番号, ...]
  154. *     共有したい変数の番号を指定します。「,」で区切り複数の値を指定する事ができます。
  155. *     「-」で数値の範囲を指定する事も可能です。
  156. *     (例) 1-3,11,12,13,14,15
  157. *            => 1,2,3,11,12,13,14,15番の変数が対象になる。
  158. *
  159. *   Is Auto [true|false]
  160. *     セーブ・ロード時に自動的に共通セーブデータのセーブ・ロードを行うかを設定します。
  161. *     デフォルトではtrue(セーブ・ロード時に自動的に共有セーブ・ロードを行う)になっています。
  162. *
  163. *   Auto on Gameover [true|false]
  164. *     自動セーブ設定がONの時にゲームオーバー時に共有セーブデータの自動セーブを行うかを設定します。
  165. *     デフォルトではfalse(ゲームオーバー時に自動共有セーブを行わない)になっています。
  166. *
  167. *   Show Trace [true|false]
  168. *     デバッグ用のトレースを出すかを設定します。
  169. *
  170. * ■プラグインコマンド
  171. *   CommonSave load                  # 共有セーブデータからスイッチ・変数を読み込み反映させます。
  172. *                                    # 任意のタイミングで共有セーブデータのロードを行いたい場合に使用します。
  173. *   CommonSave save                  # 共有セーブデータにスイッチ・変数の状態を記録します。
  174. *                                    # 任意のタイミングで共有セーブデータのセーブを行いたい場合に使用します。
  175. *   CommonSave remove                # 共有セーブデータを削除します。
  176. *                                    # 共有セーブデータをリセットしたい場合に使用します。
  177. *   CommonSave setTrace [true|false] # コンソールにトレースを出力するかを設定します。
  178. *                                    # ゲーム実行中にトレース状態を切り替えたい場合に使用します。
  179. *   CommonSave check                 # 共有状態になっているスイッチ・変数番号をコンソールに表示し確認します。
  180. *
  181. * ■更新履歴
  182. *   ver 1.20 (2016.05.11)
  183. *     スイッチ・変数の指定の際に「-」を使う事で範囲指定を可能に。
  184. *     トレース状態を動的に変えられるように setTrace プラグインコマンドを追加。
  185. *     共有対象になっているスイッチ・変数を確認できる check プラグインコマンドを追加。
  186. *
  187. *   ver 1.10 (2016.02.17)
  188. *     ファイル名をUTA_CommonSave.jsに変更。
  189. *     トレース出力の有無をパラメータで設定できるように。
  190. *
  191. *   ver 1.01 (2016.01.14)
  192. *     変数の共有が上手くできていないバグの修正。
  193. *
  194. *   ver 1.00 (2015.12.31)
  195. *     日本語版RPGツクールMVの発売に合わせver1.00に。
  196. *
  197. *   ver 0.01 (2015.11.05)
  198. *     初版。
  199. */
  200. //=============================================================================

  201. //name space
  202. var utakata = utakata || (utakata = {});

  203. //-----------------------------------------------------------------------------
  204. // class CommonSaveManager
  205. //-----------------------------------------------------------------------------
  206. (function(utakata){
  207.     var CommonSaveManager = (function(){
  208.         //constructor
  209.         function CommonSaveManager(){
  210.             //member variables
  211.             this._targetSwitchList = [];
  212.             this._targetVariableList = [];

  213.             this._showTrace = false;
  214.             this._tr = null;

  215.             this.initialize();
  216.         }

  217.         //private methods
  218.         CommonSaveManager.prototype.initialize = function(){
  219.             this.parameters = PluginManager.parameters('UTA_CommonSave');

  220.             this._showTrace = (String(this.parameters['Show Trace']) === "true");

  221.             this._tr = function(s){
  222.                         if(!this._showTrace){ return; }
  223.                         var str = "CommonSaveManager: " + s; console.log(str);
  224.             };

  225.             var targetSwitchStr = String(this.parameters['Target Switches']);
  226.             var targetVariableStr = String(this.parameters['Target Variables']);

  227.             this._targetSwitchList = this._parseTargetNumber(targetSwitchStr);
  228.             this._targetVariableList = this._parseTargetNumber(targetVariableStr);
  229.         };

  230.         CommonSaveManager.prototype._parseTargetNumber = function(str){
  231.             if(typeof str === "undefined" || str === "undefined"){ return []; }

  232.             str = str.replace(/\s+/g, "");

  233.             var split_str = ',';
  234.             var rgn_split_str = '-';

  235.             var indexes = str.split(split_str, -1);
  236.             var ret = [];

  237.             var parseTargetNumbersFromRegion = function(rgn_target){
  238.                 var ret = [];
  239.                 var target_number = rgn_target.split(rgn_split_str, -1);
  240.                 if(typeof target_number[0] === "undefined" || typeof target_number[1] === "undefined"){ return []; }

  241.                 var s_number = parseInt(target_number[0]);
  242.                 if(s_number !== s_number){
  243.                     this._tr("_parseTargetNumber getTargetNumbersFromRegion: Setting parameter is invalid.");
  244.                     return [];
  245.                 }

  246.                 var e_number = parseInt(target_number[1]);
  247.                 if(e_number !== e_number){
  248.                     this._tr("_parseTargetNumber getTargetNumbersFromRegion: Setting parameter is invalid.");
  249.                     return [];
  250.                 }

  251.                 for(var i = s_number; i <= e_number; i++){
  252.                     ret.push(i);
  253.                 }

  254.                 return ret;
  255.             };

  256.             for(var i = 0; i < indexes.length; i++){
  257.                 var rgn_target = indexes[i].match(/\d+-\d+/g);
  258.                 if(!!rgn_target){
  259.                     var parseIndexes = parseTargetNumbersFromRegion(rgn_target[0]);
  260.                     if(parseIndexes.length <= 0){ continue; }

  261.                     ret = ret.concat(parseIndexes);
  262.                 }else{
  263.                     var parseIndex = parseInt(indexes[i]);
  264.                     if(parseIndex !== parseIndex){
  265.                         this._tr("_parseTargetNumber: Setting parameter is invalid.");
  266.                         continue;
  267.                     }
  268.                     ret.push(parseIndex);
  269.                 }
  270.             }
  271.             return ret;
  272.         };

  273.         CommonSaveManager.prototype._getTargetSwitchJson = function(){
  274.             var json = { };

  275.             for(var i = 0; i < this._targetSwitchList.length; i++){
  276.                 var idx = this._targetSwitchList[i].toString();
  277.                 var value = $gameSwitches.value(idx);
  278.                 json[idx] = value;
  279.             }

  280.             return json;
  281.         };

  282.         CommonSaveManager.prototype._getTargetVariableJson = function(){
  283.             var json = { };

  284.             for(var i = 0; i < this._targetVariableList.length; i++){
  285.                 var idx = this._targetVariableList[i].toString();
  286.                 var value = $gameVariables.value(idx);
  287.                 json[idx] = value;
  288.             }

  289.             return json;
  290.         };

  291.         CommonSaveManager.prototype.setLoadSwitches = function(switches){
  292.             for(var key in switches){
  293.                 var idx = parseInt(key);
  294.                 var value = switches[key];
  295.                 $gameSwitches.setValue(idx, value);
  296.             }
  297.         };

  298.         CommonSaveManager.prototype.setLoadVariables = function(variables){
  299.             for(var key in variables){
  300.                 var idx = parseInt(key);
  301.                 var value = variables[key];
  302.                 $gameVariables.setValue(idx, value);
  303.             }
  304.         };

  305.         //public methods
  306.         CommonSaveManager.prototype.load = function(){
  307.             this._tr("load common save data.");

  308.             if(!this.exists()){ return false; }

  309.             var loadData = DataManager.loadCommonSave();

  310.             if("gameSwitches" in loadData){
  311.                 this.setLoadSwitches(loadData["gameSwitches"]);
  312.             }
  313.             if("gameVariables" in loadData){
  314.                 this.setLoadVariables(loadData["gameVariables"]);
  315.             }
  316.         };

  317.         CommonSaveManager.prototype.save = function(){
  318.             this._tr("save common save data.");

  319.             var switchesJson = this._getTargetSwitchJson();
  320.             var variablesJson = this._getTargetVariableJson();

  321.             var json = { "gameSwitches": switchesJson,
  322.                          "gameVariables": variablesJson };

  323.             DataManager.saveCommonSave(json);
  324.         };

  325.         CommonSaveManager.prototype.exists = function(){
  326.             this._tr("check exists common save data.");
  327.             return StorageManager.existsCommonSave();
  328.         };

  329.         CommonSaveManager.prototype.remove = function(){
  330.             this._tr("remove common save data.");
  331.             StorageManager.removeCommonSave();
  332.         };

  333.         CommonSaveManager.prototype.setShowTrace = function(args){
  334.             if(!args){ return; }
  335.             var enabled = String(args[1]) === "true" ? true : false;
  336.             this._tr("setShowTrace: " + this._showTrace);
  337.             this._showTrace = enabled;
  338.         };

  339.         CommonSaveManager.prototype.check = function(){
  340.             var str = "CommonSaveManager: \n";
  341.             str += " # Share switch targets : \n";
  342.             str += JSON.stringify(this._targetSwitchList);

  343.             str += "\n # Share variable targets : \n";
  344.             str += JSON.stringify(this._targetVariableList);

  345.             console.log(str);
  346.         };

  347.         CommonSaveManager.prototype.isAuto = function(){
  348.             return String(this.parameters['Is Auto']) === "true";
  349.         };

  350.         CommonSaveManager.prototype.isAutoOnGameOver = function(){
  351.             return String(this.parameters['Auto on Gameover']) === "true";
  352.         };

  353.         return CommonSaveManager;
  354.     })();
  355.     utakata.CommonSaveManager = new CommonSaveManager();

  356. })(utakata || (utakata = {}));

  357. (function(){
  358.     //parse and dispatch plugin command
  359.     var _Game_Interpreter_pluginCommand =
  360.             Game_Interpreter.prototype.pluginCommand;
  361.     Game_Interpreter.prototype.pluginCommand = function(command, args){
  362.         _Game_Interpreter_pluginCommand.call(this, command, args);
  363.         if(command === 'CommonSave'){
  364.             switch(args[0]){
  365.                 case 'load':
  366.                     utakata.CommonSaveManager.load();
  367.                     break;
  368.                 case 'save':
  369.                     utakata.CommonSaveManager.save();
  370.                     break;
  371.                 case 'exists':
  372.                     utakata.CommonSaveManager.exists();
  373.                     break;
  374.                 case 'remove':
  375.                     utakata.CommonSaveManager.remove();
  376.                     break;
  377.                 case 'setTrace':
  378.                     utakata.CommonSaveManager.setShowTrace(args);
  379.                     break;
  380.                 case 'check':
  381.                     utakata.CommonSaveManager.check();
  382.                     break;
  383.                 default:
  384.                     break;
  385.             }
  386.         }
  387.     };

  388.     //-----------------------------------------------------------------------------
  389.     // DataManager
  390.     //-----------------------------------------------------------------------------
  391.     // # extension
  392.     var _Data_Manager_loadGame = DataManager.loadGame;
  393.     DataManager.loadGame = function(savefileId){
  394.         var ret = _Data_Manager_loadGame.call(this, savefileId);

  395.         if(utakata.CommonSaveManager.isAuto()){ utakata.CommonSaveManager.load(); }
  396.         return ret;
  397.     };

  398.     var _Data_Manager_saveGame = DataManager.saveGame;
  399.     DataManager.saveGame = function(savefileId){
  400.         var ret = _Data_Manager_saveGame.call(this, savefileId);

  401.         if(utakata.CommonSaveManager.isAuto()){ utakata.CommonSaveManager.save(); }
  402.         return ret;
  403.     };

  404.     var _Data_Manager_setupNewGame = DataManager.setupNewGame;
  405.     DataManager.setupNewGame = function(){
  406.         _Data_Manager_setupNewGame.call(this);
  407.         if(utakata.CommonSaveManager.isAuto()){ utakata.CommonSaveManager.load(); }
  408.     };

  409.     // # add methods
  410.     DataManager.loadCommonSave = function(){
  411.         var json;
  412.         try{
  413.             json = StorageManager.loadCommonSave();
  414.         }catch(e){
  415.             console.error(e);
  416.             return [];
  417.         }
  418.         if(json){
  419.             var commonInfo = JSON.parse(json);
  420.             return commonInfo;
  421.         }else{
  422.             return [];
  423.         }
  424.     };

  425.     DataManager.saveCommonSave = function(json){
  426.         var jsonStr = JsonEx.stringify(json);
  427.         if(jsonStr.length >= 200000){
  428.             console.warn('Common Save too big!');
  429.         }
  430.         StorageManager.saveCommonSave(jsonStr);
  431.         return true;
  432.     };

  433.     //-----------------------------------------------------------------------------
  434.     // StorageManager
  435.     //-----------------------------------------------------------------------------
  436.     //load methods ----------------------------------------------------------------
  437.     StorageManager.loadCommonSave = function(){
  438.         if(this.isLocalMode()){
  439.             return this.loadFromLocalFileCommonSave();
  440.         }else{
  441.             return this.loadFromWebStorageCommonSave();
  442.         }
  443.     };

  444.     StorageManager.loadFromLocalFileCommonSave = function(){
  445.         var data = null;
  446.         var fs = require('fs');
  447.         var filePath = this.localFilePathCommonSave();
  448.         if (fs.existsSync(filePath)) {
  449.             data = fs.readFileSync(filePath, { encoding: 'utf8' });
  450.         }
  451.         return LZString.decompressFromBase64(data);
  452.     };

  453.     StorageManager.loadFromWebStorageCommonSave = function(){
  454.         var key = this.webStorageKeyCommonSave();
  455.         var data = localStorage.getItem(key);
  456.         return LZString.decompressFromBase64(data);
  457.     };

  458.     // save methods ---------------------------------------------------------------
  459.     StorageManager.saveCommonSave = function(json){
  460.         if(this.isLocalMode()){
  461.             this.saveToLocalFileCommonSave(json);
  462.         }else{
  463.             this.saveToWebStorageCommonSave(json);
  464.         }
  465.     };

  466.     StorageManager.saveToLocalFileCommonSave = function(json){
  467.         var data = LZString.compressToBase64(json);
  468.         var fs = require('fs');
  469.         var dirPath = this.localFileDirectoryPath();
  470.         var filePath = this.localFilePathCommonSave();
  471.         if (!fs.existsSync(dirPath)) {
  472.             fs.mkdirSync(dirPath);
  473.         }
  474.         fs.writeFileSync(filePath, data);
  475.     };

  476.     StorageManager.saveToWebStorageCommonSave = function(json){
  477.         var key = this.webStorageKeyCommonSave();
  478.         var data = LZString.compressToBase64(json);
  479.         localStorage.setItem(key, data);
  480.     };

  481.     //check exists ----------------------------------------------------------------
  482.     StorageManager.existsCommonSave = function(){
  483.         if(this.isLocalMode()){
  484.             return this.localFileExistsCommonSave();
  485.         }else{
  486.             return this.webStorageExistsCommonSave();
  487.         }
  488.     };

  489.     StorageManager.localFileExistsCommonSave = function(){
  490.         var fs = require('fs');
  491.         return fs.existsSync(this.localFilePathCommonSave());
  492.     };

  493.     StorageManager.webStorageExistsCommonSave = function(){
  494.         var key = this.webStorageKeyCommonSave();
  495.         return !!localStorage.getItem(key);
  496.     };

  497.     //remove ----------------------------------------------------------------------
  498.     StorageManager.removeCommonSave = function(){
  499.         if(this.isLocalMode()){
  500.             this.removeLocalFileCommonSave();
  501.         }else{
  502.             this.removeWebStorageCommonSave();
  503.         }
  504.     };

  505.     StorageManager.removeLocalFileCommonSave = function(){
  506.         var fs = require('fs');
  507.         var filePath = this.localFilePathCommonSave();
  508.         if(fs.existsSync(filePath)){
  509.             fs.unlinkSync(filePath);
  510.         }
  511.     };

  512.     StorageManager.removeWebStorageCommonSave = function(){
  513.         var key = this.webStorageKeyCommonSave();
  514.         localStorage.removeItem(key);
  515.     };

  516.     StorageManager.localFilePathCommonSave = function(){ return this.localFileDirectoryPath() + 'common.rpgsave'; };
  517.     StorageManager.webStorageKeyCommonSave = function(){ return 'RPG Common'; };


  518.     //-----------------------------------------------------------------------------
  519.     // Scene_Gameover
  520.     //-----------------------------------------------------------------------------
  521.     var _Scene_Gameover_Start = Scene_Gameover.prototype.start;
  522.     Scene_Gameover.prototype.start = function(){
  523.         if(utakata.CommonSaveManager.isAutoOnGameOver()){
  524.             utakata.CommonSaveManager.save();
  525.         }
  526.         _Scene_Gameover_Start.call(this);
  527.     };

  528. })();
复制代码

评分

参与人数 1星屑 +266 收起 理由
余烬之中 + 266 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
72
在线时间
14 小时
注册时间
2016-5-28
回帖
9
 楼主| 发表于 2016-5-30 07:54:43 | 显示全部楼层
tseyik 发表于 2016-5-29 12:21
http://utakata-no-yume.net/gallery/plugin/tkmv/cmn_save/
共有セーブデータ

非常感谢!!看起来正是我所需要的东西!!
马上去试试看!
回复

使用道具 举报

梦石
0
星屑
72
在线时间
14 小时
注册时间
2016-5-28
回帖
9
 楼主| 发表于 2016-5-30 19:31:13 | 显示全部楼层
tseyik 发表于 2016-5-29 12:21
http://utakata-no-yume.net/gallery/plugin/tkmv/cmn_save/
共有セーブデータ

太感谢啦!这个变量设置真心好用!
收集要素或是二周目设定什么的都简单的就能实现,
非常感谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部