查看: 1871|回复: 15

[有事请教] 有会使用,当前地图有多少宝箱的插件的吗?

[复制链接]
梦石
0
星屑
1121
在线时间
200 小时
注册时间
2020-9-28
回帖
43
发表于 2024-1-7 11:33:15 | 显示全部楼层 |阅读模式
悬赏10星屑已解决
我用了,发生了错误?有谁知道怎么使用的?
require c. 1 Window getpenis not a fur ction

  1. //=============================================================================
  2. // Mano_ChestList.js
  3. // ----------------------------------------------------------------------------
  4. // Copyright (c) 2017-2017 Sigureya
  5. // This software is released under the MIT License.
  6. // [url]http://opensource.org/licenses/mit-license.php[/url]
  7. // ----------------------------------------------------------------------------
  8. // [Twitter]: [url]https://twitter.com/Sigureya/[/url]
  9. // [github]:[url]https://github.com/Sigureya/RPGmakerMV[/url]
  10. //=============================================================================

  11. /*:
  12. * @plugindesc 查一下当前地图,宝箱的信息
  13. *
  14. * @param balloonId
  15. * @desc chestFlash()中使用的,引出序号的编号。
  16. * @type select
  17. * @option 惊吓
  18. * @value 1
  19. * @option 感動
  20. * @value 2
  21. * @option 音符
  22. * @value 3
  23. * @option 红心
  24. * @value 4
  25. * @option 怒り
  26. * @value 5
  27. * @option 汗
  28. * @value 6
  29. * @option 心情不舒畅
  30. * @value 7
  31. * @option 沈黙
  32. * @value 8
  33. * @option 電球
  34. * @value 9
  35. * @option Zzz
  36. * @value 10
  37. * @option ユーザー定義1
  38. * @value 11
  39. * @option ユーザー定義2
  40. * @value 12
  41. * @option ユーザー定義3
  42. * @value 13
  43. * @option ユーザー定義4
  44. * @value 14
  45. * @option ユーザー定義5
  46. * @value 15
  47. * @default 1
  48. *
  49. * @param flashSound
  50. * @type file
  51. * @dir audio/se
  52. * @default Flash1
  53. *
  54. * @param flashWait
  55. * @desc 插件命令「ChestFlash」在时,设置是否为开启
  56. * @type boolean
  57. * @default true
  58. *
  59. * @param CountChest
  60. * @desc 决定是否使用,简易版盗贼的鼻子
  61. *  面向写活动命令,很麻烦的人
  62. * @type boolean
  63. * @default false
  64. *
  65. * @param CountChestText
  66. * @desc 这是简易版,盗贼鼻子的,已找到宝物信息。
  67. * @default 这一带好像,还有%1个宝物。
  68. * @parent CountChest
  69. *
  70. * @param CountChestEmptyText
  71. * @desc 用简易版盗贼的鼻子
  72. *  未找到宝物时的消息
  73. * @default 这一带的宝物,好像都得到了。
  74. * @parent CountChest
  75. *
  76. *
  77. *
  78. * @author しぐれん(魔のささやき)
  79. * @help
  80. * 在想当做宝箱的活动的,笔记栏里<宝箱>或者<chest>请写下来。
  81. * 是否打开取决于事件页面,是否是最大的页面。
  82. *  没有图形也可以做成宝箱。
  83. *
  84. * 通过在变量的操作(脚本)中,写入以下内容来获取数据。
  85. *
  86. * $gameMap.countChest()
  87. * 所有宝箱的数量
  88. * $gameMap.countOpendChest()
  89. * 打开的宝箱数量
  90. * $gameMap.countClosedChest()
  91. * 未打开的宝箱数量
  92. *
  93. * 以下是可以通过,事件命令“脚本”执行的内容。
  94. * $gameMap.chestFlash()
  95. * 在画面内的宝箱中,让所有没有打开的东西发光。
  96. * 虽然是发光方式,但是通过气球的再生来进行。
  97. *
  98. * 插件命令
  99. *「ChestFlash」因此,没有打开的宝箱,会带有气球
  100. *
  101. */
  102. /*~struct~CommonDefine:
  103. *  
  104. * @param enableSwitch
  105. * @desc 指定したスイッチがONの時だけ、呼びだしを行います。
  106. * ゲームの進行で機能が追加される場合を想定しています。
  107. * @type switch
  108. *
  109. * @param symbol
  110. * @desc Input.isTriggered()の引数として使われます
  111. *
  112. * @param text
  113. * @desc コマンド名称です
  114. *
  115. * @param mandatory
  116. * @desc inputConfigの方で必須指定されたものとして扱います。
  117. * @type boolean
  118. * @default false
  119. *
  120. * @param keycode
  121. * @desc キーボードの割り当てです
  122. * キーコードは各自調べてください
  123. * @type number
  124. *
  125. * @param padButton
  126. * @desc ゲームパッドの割り当てです
  127. * カッコ内はツクールのデフォルトでの割り当てです
  128. * @type select
  129. * @default -1
  130. * @option non(割り当てなし)
  131. * @value -1
  132. * @type select
  133. * @option button6
  134. * @value 6
  135. * @option button7
  136. * @value 7
  137. * @option button8
  138. * @value 8
  139. * @option button9
  140. * @value 9
  141. * @option button10
  142. * @value 10
  143. * @option button11
  144. * @value 11
  145. * @option button0(ok/決定)
  146. * @value 0
  147. * @option button1(cancel/キャンセル)
  148. * @value 1
  149. * @option button2(shift/ダッシュ)
  150. * @value 2
  151. * @option button3(menu/メニュー)
  152. * @value 3
  153. * @option button4(pageup)
  154. * @value 4
  155. * @option button5(pagedown)
  156. * @value 5
  157. */

  158. /**
  159. * TODO
  160. * isChestで、宝箱であるかどうかをチェック
  161. * レミラーマは、該当するイベントに対してのアニメーション再生で
  162. *
  163. * 指定要素をカウントする関数で、盗賊の鼻
  164. * タグを切り替えることで、話しかけた重要人物リスト
  165. *
  166. * ■countSelfSwitch(マップID)について
  167. * 他のマップを調べられるレミラーマです。
  168. * マップに親子関係がある場合、このマップを再起的に調べます。
  169. * この関数を使う場合、全てのマップで宝箱に使うセルフスイッチが同じ番号である必要があります。
  170. * 宝箱以外で指定したセルフスイッチを使うと、正常に動作しません。
  171. * イベントの簡単作成で宝箱を作成すると、Aが割り当てられるため、Aにすることをお勧めします。
  172. * 第2引数に'B','C','D'など任意のセルフスイッチに割り当てられるキーを指定することで、
  173. * 他のセルフスイッチも調べられます。
  174. *
  175. * @param oneButtonCountChestCall
  176. * @desc キーボードやゲームパッドから1ボタンで盗賊の鼻を起動します。
  177. * @type boolean
  178. * @on 機能を使う
  179. * @off 機能を使わない
  180. * @default false
  181. *
  182. */
  183. (function(){
  184. 'use strict'

  185. function createCommonDefine(param){
  186.     const obj =JSON.parse(param);
  187.     return{
  188.         mandatory:Boolean(obj.mandatory),
  189.         text:String(obj.text),
  190.         symbol:String(obj.symbol),
  191.         enableSwitch:Number(obj.enableSwitch),
  192.         keycode:String(obj.keycode),
  193.         padButton:String(obj.padButton),
  194.     };
  195. }

  196. function createCountChestSetting(params){
  197.     if(params.CountChest!=='true'){
  198.         return null;
  199.     }
  200.     return {
  201.         countChestEmptyText:String(params.CountChestEmptyText),
  202.         inputDefine :createCommonDefine(params.CountChestinputSetting),
  203.     };
  204. }


  205. const setting=(function(){
  206.     const params = PluginManager.parameters('Mano_ChestList');

  207.     const result ={
  208.         chestTag:'chest',
  209.         chestTagJP:'宝箱',
  210.         balloonId:Number(params.balloonId),
  211.         flashSound:{
  212.             name:String(params.flashSound),
  213.             pan:0,
  214.             pitch:100,
  215.             volume:90,
  216.         },
  217.         flashWait:(params.flashWait==='true'),
  218.         countChestText:String(params.CountChestText),
  219.         countChestEmptyText:String(params.CountChestEmptyText),
  220.         countChest:createCountChestSetting(params),
  221.     };
  222.     return result;
  223. })();



  224. //const setting =createSetting();


  225. const KEYSYMBOL_CHESTCOUNT ='ChestCount';

  226. /**
  227. * @param {[]} array
  228. * @param {Function } func
  229. */
  230. function countIf(array,func){
  231.     var count =0;
  232.     const len =array.length;
  233.     for (var index = 0; index < len; index++) {
  234.         var elem =array[index];

  235.         if(elem&& func( elem )){
  236.             ++count;
  237.         }
  238.     }
  239.     return count;
  240. }

  241. Game_Event.prototype.isChest=function(){
  242.     const meta =this.event().meta;
  243.     return meta.hasOwnProperty(setting.chestTag) || meta.hasOwnProperty(setting.chestTagJP);
  244. };
  245. Game_Event.prototype.chestFlash =function(){
  246.     const flash =this.isClosedChest();
  247.     if(flash){
  248.         this.requestBalloon(setting.balloonId);
  249.     }
  250.     return flash;
  251. };

  252. /**
  253. * @param {Game_Event} event
  254. */
  255. function _finalPage(event){
  256.    return event._pageIndex ===event.event().pages.length-1
  257. }
  258. Game_Event.prototype.isOpendChest=function(){
  259.     return  _finalPage(this) &&this.isChest();
  260. };
  261. Game_Event.prototype.isClosedChest =function(){
  262.     return !_finalPage(this) &&this.isChest();
  263. };

  264. Game_Map.prototype.countOpendChest =function(){
  265.     return countIf(this._events,function(event){
  266.         return event.isOpendChest();
  267.     });
  268. };
  269. Game_Map.prototype.countClosedChest =function(){
  270.     return countIf(this._events,function(event){
  271.         return event.isClosedChest();
  272.     });
  273. };
  274. Game_Map.prototype.countChest =function(){
  275.     return countIf(this._events,function(event){
  276.         return event.isChest();
  277.     });
  278. };
  279. /**
  280. * @return {Game_Event} 最後にバルーンを出したイベント
  281. */
  282. Game_Map.prototype.chestFlash =function(){
  283.     const events = this.events();
  284.     var lastEvent=null;
  285.     events.forEach(function(event){
  286.         if(event){
  287.             if(event.chestFlash()){
  288.                 lastEvent =event;
  289.             }
  290.         }
  291.     });
  292.     if(lastEvent){
  293.         AudioManager.playSe(setting.flashSound);
  294.     }
  295.     return lastEvent;
  296. };

  297. Game_Map.prototype.showChestCountMessage =function(){
  298.     const count = this.countClosedChest();
  299.     if( count >0  ){
  300.         $gameMessage.add(setting.countChestText.format(count));
  301.     }else{
  302.         $gameMessage.add(setting.countChestEmptyText);
  303.     }
  304. };

  305. Game_Interpreter.prototype.chestFlash=function(){
  306.     const event = $gameMap.chestFlash();
  307.     if(setting.flashWait && !!event ){
  308.         this._character =event;
  309.         this.setWaitMode('balloon');
  310.     }
  311. };

  312. const Game_Interpreter_pluginCommand =Game_Interpreter.prototype.pluginCommand;
  313. Game_Interpreter.prototype.pluginCommand =function(command, args){
  314.     if(command ==='ChestFlash'){
  315.         this.chestFlash();
  316.         return;
  317.     }
  318.     if(command ==='CountChest'){
  319.         $gameMap.showChestCountMessage()
  320.         return;
  321.     }
  322.     Game_Interpreter_pluginCommand.apply(this,arguments);
  323. };

  324. })();
复制代码


最佳答案

查看完整内容

额,你试试脚本直接填$gameMap.showChestCountMessage() 不是变量赋值填脚本,而是事件指令-脚本填$gameMap.showChestCountMessage() 就像填写插件指令一样
梦石
0
星屑
7009
在线时间
1280 小时
注册时间
2016-12-6
回帖
378
发表于 2024-1-7 11:33:16 | 显示全部楼层
云端城主 发表于 2024-1-8 16:22
原来是我代码大小写出错了。
但是为什么使用 简易版盗贼的鼻子,功能代码又出错了? ...

额,你试试脚本直接填$gameMap.showChestCountMessage()
不是变量赋值填脚本,而是事件指令-脚本填$gameMap.showChestCountMessage()
就像填写插件指令一样
回复

使用道具 举报

梦石
0
星屑
7009
在线时间
1280 小时
注册时间
2016-12-6
回帖
378
发表于 2024-1-7 12:26:29 | 显示全部楼层
贴个完整的报错页面,按F8打开控制台截图
回复

使用道具 举报

梦石
0
星屑
1121
在线时间
200 小时
注册时间
2020-9-28
回帖
43
 楼主| 发表于 2024-1-7 17:07:19 | 显示全部楼层
shiroin 发表于 2024-1-7 12:26
贴个完整的报错页面,按F8打开控制台截图




回复

使用道具 举报

梦石
0
星屑
7009
在线时间
1280 小时
注册时间
2016-12-6
回帖
378
发表于 2024-1-7 17:17:29 | 显示全部楼层
这个$gameMap. countClosedChest(1)是你自己输入的脚本?
如果你是想获知地图上未开锁宝箱的数量,直接输入$gameMap.countClosedChest()就行了,这个函数不接受额外的参数
如果还会报错,你应该注意下事件的注释是不是没正确书写
回复

使用道具 举报

梦石
0
星屑
1121
在线时间
200 小时
注册时间
2020-9-28
回帖
43
 楼主| 发表于 2024-1-7 20:44:04 | 显示全部楼层
shiroin 发表于 2024-1-7 17:17
这个$gameMap. countClosedChest(1)是你自己输入的脚本?
如果你是想获知地图上未开锁宝箱的数量,直接输入 ...

那要怎么输入代码?试过很久都发生错误,不知道是不是脚本就有问题?
回复

使用道具 举报

梦石
0
星屑
7009
在线时间
1280 小时
注册时间
2016-12-6
回帖
378
发表于 2024-1-7 20:57:54 | 显示全部楼层
本帖最后由 shiroin 于 2024-1-7 21:27 编辑


这个插件我刚也下来玩了一下,也遇到一样的报错原因,排查了下发现是因为这个插件识别宝箱有两个条件,一是宝箱事件需要有<宝箱>或<chest>的"备注",是"备注"而不是"注释",这个我一开始也搞混了……
二是宝箱事件的事件页数要有2页以上,只有一页会始终判定为"被打开的宝箱",$gameMap.countClosedChest()会无法搜索到这一类的宝箱
回复

使用道具 举报

梦石
0
星屑
1121
在线时间
200 小时
注册时间
2020-9-28
回帖
43
 楼主| 发表于 2024-1-7 21:28:12 | 显示全部楼层
本帖最后由 云端城主 于 2024-1-7 23:40 编辑
shiroin 发表于 2024-1-7 20:57
这个插件我刚也下来玩了一下,也遇到一样的报错原因,排查了下发现是因为这个插件识别宝箱有两个条件,一 ...


通过在变量的操作(脚本)中,写入以下内容来获取数据。
*
* $gameMap.countChest()
* 所有宝箱的数量
* $gameMap.countOpendChest()
* 打开的宝箱数量
* $gameMap.countClosedChest()
* 未打开的宝箱数量
*
* 以下是可以通过,事件命令“脚本”执行的内容。
* $gameMap.chestFlash()
* 在画面内的宝箱中,让所有没有打开的东西发光。
* 虽然是发光方式,但是通过气球的再生来进行。
*
* 插件命令
*「ChestFlash」因此,没有打开的宝箱,会带有气球

我的设置跟脚本没什么,关系了。这个脚本插件太奇怪了?




回复

使用道具 举报

梦石
0
星屑
7009
在线时间
1280 小时
注册时间
2016-12-6
回帖
378
发表于 2024-1-7 21:33:39 | 显示全部楼层
云端城主 发表于 2024-1-7 21:28
通过在变量的操作(脚本)中,写入以下内容来获取数据。
*
* $gameMap.countChest()

你重新看下我的回复,刚编辑过了,如果还没搞好,就发下你作为宝箱的事件页截图给我看看
回复

使用道具 举报

梦石
0
星屑
1121
在线时间
200 小时
注册时间
2020-9-28
回帖
43
 楼主| 发表于 2024-1-7 23:04:38 | 显示全部楼层
本帖最后由 云端城主 于 2024-1-8 14:05 编辑
shiroin 发表于 2024-1-7 20:57
这个插件我刚也下来玩了一下,也遇到一样的报错原因,排查了下发现是因为这个插件识别宝箱有两个条件,一 ...


通过在变量的操作(脚本)中,写入以下内容来获取数据。
*
* $gameMap.countChest()
* 所有宝箱的数量
* $gameMap.countOpendChest()
* 打开的宝箱数量
* $gameMap.countClosedChest()
* 未打开的宝箱数量
*
* 以下是可以通过,事件命令“脚本”执行的内容。
* $gameMap.chestFlash()
* 在画面内的宝箱中,让所有没有打开的东西发光。
* 虽然是发光方式,但是通过气球的再生来进行。
*
* 插件命令
*「ChestFlash」因此,没有打开的宝箱,会带有气球

就是上面的代码调用功能,就会出错?没效果啊。不知道是不是脚本就有问题?还是调用的问题?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部