快捷导航
查看: 359|回复: 1

[技巧] 在默认脚本中添加新的option选项

[复制链接]
会员等级

积分信息
金币:725
元宝:20
活跃:187
发电:0

荣誉勋章
热心会员优秀版主首批会员最佳新人

TA的形象
UID: 6 发表于 2023-1-4 08:45:17 | 显示全部楼层 |阅读模式
1.JPG

游戏中的系统设置(option),里面的开关都是属于可控的全局变量。对于如何增加新的选项,只需要在几处地方复制粘贴即可。

第1部分:在manager.js中,搜索此部分代码,并添加新的代码。
[JavaScript] 纯文本查看 复制代码
ConfigManager.alwaysDash = false;
ConfigManager.commandRemember = false;
ConfigManager.command_X = false;//此处为新添加部分
ConfigManager.touchUI = true;
ConfigManager._isLoaded = false;

第2部分:在manager.js中:
[JavaScript] 纯文本查看 复制代码
ConfigManager.makeData = function() {
    const config = {};
    config.alwaysDash = this.alwaysDash;
    config.commandRemember = this.commandRemember;
	config.command_X = this.command_X;//此处为新添加部分
    config.touchUI = this.touchUI;
    config.bgmVolume = this.bgmVolume;
    config.bgsVolume = this.bgsVolume;
    config.meVolume = this.meVolume;
    config.seVolume = this.seVolume;
    return config;
};

第3部分:在manager.js中
[JavaScript] 纯文本查看 复制代码
ConfigManager.applyData = function(config) {
    this.alwaysDash = this.readFlag(config, "alwaysDash", false);
    this.commandRemember = this.readFlag(config, "commandRemember", false);
	this.command_X = this.readFlag(config, "command_X", false);//此处为新添加部分
    this.touchUI = this.readFlag(config, "touchUI", true);
    this.bgmVolume = this.readVolume(config, "bgmVolume");
    this.bgsVolume = this.readVolume(config, "bgsVolume");
    this.meVolume = this.readVolume(config, "meVolume");
    this.seVolume = this.readVolume(config, "seVolume");
};

第4部分(回帖可见)
游客,如果您要查看本帖隐藏内容请回复

之后若其他脚本需要调用此变量/开关时,只需要判定ConfigManager.command_X即可。可以DIY很多有趣的功能。
2.JPG

帖子的最近访客

回复 论坛版权

使用道具 举报

会员等级

积分信息
金币:3
元宝:0
活跃:42
发电:0

荣誉勋章

TA的形象
UID: 19 发表于 2023-1-4 19:13:06 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

ahome_bigavatar:guest
ahome_bigavatar:welcomelogin
您需要登录后才可以回帖 登录 | 加入民族

本版积分规则

论坛用工具

蓝凑云 hello图床 聚合图床 TinyPNG remove 代码测试 颜色代码 颜色代码2

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

实用工具

AI人工智能图片放大 图片无损放大 Deepl翻译器 百宝箱 孟坤工具箱 在线压缩图片 图片切圆角

您一共访问了本站 加载中...

Archiver|小黑屋|RPG民族

GMT+8, 2024-10-23 06:27 , Processed in 0.203073 second(s), 62 queries .

快速回复 返回顶部 返回列表