加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
研究过程中搞出来的小玩具...
可以将Event的数据永久保存到全局, 和独立开关的使用方法一致
可以存储任意类型的数据
大概率也有其他类似的插件吧
理论上应该是MV/MZ通用
{ class Game_SelfData extends Game_SelfSwitches { setValue(key, value) { this._data[key] = value; this.onChange(); } value(key) { return this._data[key]; } } window.Game_SelfData = Game_SelfData; } { const temp = DataManager.createGameObjects; DataManager.createGameObjects = () => { temp(); $gameSelfData = new Game_SelfData(); }; } { const temp = DataManager.makeSaveContents; DataManager.makeSaveContents = () => { const contents = temp(); contents.selfData = $gameSelfData; return contents; }; } { const temp = DataManager.extractSaveContents; DataManager.extractSaveContents = (contents) => { console.log(contents.selfData); temp(contents); $gameSelfData = contents.selfData; }; }
{
class Game_SelfData extends Game_SelfSwitches {
setValue(key, value) {
this._data[key] = value;
this.onChange();
}
value(key) {
return this._data[key];
}
}
window.Game_SelfData = Game_SelfData;
}
{
const temp = DataManager.createGameObjects;
DataManager.createGameObjects = () => {
temp();
$gameSelfData = new Game_SelfData();
};
}
{
const temp = DataManager.makeSaveContents;
DataManager.makeSaveContents = () => {
const contents = temp();
contents.selfData = $gameSelfData;
return contents;
};
}
{
const temp = DataManager.extractSaveContents;
DataManager.extractSaveContents = (contents) => {
console.log(contents.selfData);
temp(contents);
$gameSelfData = contents.selfData;
};
}
使用方法, 在事件中插入脚本:
例子:记录数据
const event = $gameMap.event(this._eventId); const key = [this._mapId, this._eventId, 'pos']; $gameSelfData.setValue(key, [event.x, event.y, event.direction()]);
const event = $gameMap.event(this._eventId);
const key = [this._mapId, this._eventId, 'pos'];
$gameSelfData.setValue(key, [event.x, event.y, event.direction()]);
例子:读取数据
const event = $gameMap.event(this._eventId); const key = [this._mapId, this._eventId, 'pos']; const [x, y, d] = $gameSelfData.value(key); event.setPosition(x, y) event.setDirection(d)
const event = $gameMap.event(this._eventId);
const key = [this._mapId, this._eventId, 'pos'];
const [x, y, d] = $gameSelfData.value(key);
event.setPosition(x, y)
event.setDirection(d)
|