设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1553|回复: 5
打印 上一主题 下一主题

[有事请教] 求一个输入按键执行公共事件的插件

[复制链接]

Lv4.逐梦者

梦石
0
星屑
19285
在线时间
2308 小时
注册时间
2015-7-4
帖子
937
跳转到指定楼层
1
发表于 2017-11-18 00:17:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
找两天了到处找不到,请大神分享一下!就差这个,我想要的功能就都实现了。拜谢了!

Lv3.寻梦者

梦石
0
星屑
2727
在线时间
210 小时
注册时间
2017-9-28
帖子
283
2
发表于 2017-11-18 08:47:03 | 只看该作者
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
19285
在线时间
2308 小时
注册时间
2015-7-4
帖子
937
3
 楼主| 发表于 2017-11-18 10:31:39 | 只看该作者
擦不完的水 发表于 2017-11-18 08:47
https://www.bilibili.com/video/av3727626/index_162.html#page=67
YEP.61 - Button Common Events

感谢!但是看到教程还是没找到插件。请大神直接传个插件文件,再次拜谢!
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2727
在线时间
210 小时
注册时间
2017-9-28
帖子
283
4
发表于 2017-11-18 11:49:58 | 只看该作者
Fan723 发表于 2017-11-18 10:31
感谢!但是看到教程还是没找到插件。请大神直接传个插件文件,再次拜谢! ...

插件好像因为作者更新最新插件所以原来的插件链接不晓得了。。。
  1. //=============================================================================
  2. // Yanfly Engine Plugins - Button Common Events
  3. // YEP_ButtonCommonEvents.js
  4. //=============================================================================

  5. var Imported = Imported || {};
  6. Imported.YEP_ButtonCommonEvents = true;

  7. var Yanfly = Yanfly || {};
  8. Yanfly.BCE = Yanfly.BCE || {};
  9. Yanfly.BCE.version = 1.02

  10. //=============================================================================
  11. /*:
  12. * @plugindesc v1.02 On the field map, call common events when certain
  13. * buttons are pressed on the keyboard.
  14. * @author Yanfly Engine Plugins
  15. *
  16. * @param ---Top Row---
  17. * @default
  18. *
  19. * @param Key ~
  20. * @parent ---Top Row---
  21. * @type common_event
  22. * @desc The common event to call when this button is pressed.
  23. * Set to 0 if you don't wish for a common event to call.
  24. * @default 0
  25. *
  26. * @param Key 1
  27. * @parent ---Top Row---
  28. * @type common_event
  29. * @desc The common event to call when this button is pressed.
  30. * Set to 0 if you don't wish for a common event to call.
  31. * @default 0
  32. *
  33. * @param Key 2
  34. * @parent ---Top Row---
  35. * @type common_event
  36. * @desc The common event to call when this button is pressed.
  37. * Set to 0 if you don't wish for a common event to call.
  38. * @default 0
  39. *
  40. * @param Key 3
  41. * @parent ---Top Row---
  42. * @type common_event
  43. * @desc The common event to call when this button is pressed.
  44. * Set to 0 if you don't wish for a common event to call.
  45. * @default 0
  46. *
  47. * @param Key 4
  48. * @parent ---Top Row---
  49. * @type common_event
  50. * @desc The common event to call when this button is pressed.
  51. * Set to 0 if you don't wish for a common event to call.
  52. * @default 0
  53. *
  54. * @param Key 5
  55. * @parent ---Top Row---
  56. * @type common_event
  57. * @desc The common event to call when this button is pressed.
  58. * Set to 0 if you don't wish for a common event to call.
  59. * @default 0
  60. *
  61. * @param Key 6
  62. * @parent ---Top Row---
  63. * @type common_event
  64. * @desc The common event to call when this button is pressed.
  65. * Set to 0 if you don't wish for a common event to call.
  66. * @default 0
  67. *
  68. * @param Key 7
  69. * @parent ---Top Row---
  70. * @type common_event
  71. * @desc The common event to call when this button is pressed.
  72. * Set to 0 if you don't wish for a common event to call.
  73. * @default 0
  74. *
  75. * @param Key 8
  76. * @parent ---Top Row---
  77. * @type common_event
  78. * @desc The common event to call when this button is pressed.
  79. * Set to 0 if you don't wish for a common event to call.
  80. * @default 0
  81. *
  82. * @param Key 9
  83. * @parent ---Top Row---
  84. * @type common_event
  85. * @desc The common event to call when this button is pressed.
  86. * Set to 0 if you don't wish for a common event to call.
  87. * @default 0
  88. *
  89. * @param Key 0
  90. * @parent ---Top Row---
  91. * @type common_event
  92. * @desc The common event to call when this button is pressed.
  93. * Set to 0 if you don't wish for a common event to call.
  94. * @default 0
  95. *
  96. * @param Key -
  97. * @parent ---Top Row---
  98. * @type common_event
  99. * @desc The common event to call when this button is pressed.
  100. * Set to 0 if you don't wish for a common event to call.
  101. * @default 0
  102. *
  103. * @param Key =
  104. * @parent ---Top Row---
  105. * @type common_event
  106. * @desc The common event to call when this button is pressed.
  107. * Set to 0 if you don't wish for a common event to call.
  108. * @default 0
  109. *
  110. * @param ---2nd Row---
  111. * @default
  112. *
  113. * @param Key Q (PageUp)
  114. * @parent ---2nd Row---
  115. * @type common_event
  116. * @desc The common event to call when this button is pressed.
  117. * Set to 0 if you don't wish for a common event to call.
  118. * @default 0
  119. *
  120. * @param Key W (PageDown)
  121. * @parent ---2nd Row---
  122. * @type common_event
  123. * @desc The common event to call when this button is pressed.
  124. * Set to 0 if you don't wish for a common event to call.
  125. * @default 0
  126. *
  127. * @param Key E
  128. * @parent ---2nd Row---
  129. * @type common_event
  130. * @desc The common event to call when this button is pressed.
  131. * Set to 0 if you don't wish for a common event to call.
  132. * @default 0
  133. *
  134. * @param Key R
  135. * @parent ---2nd Row---
  136. * @type common_event
  137. * @desc The common event to call when this button is pressed.
  138. * Set to 0 if you don't wish for a common event to call.
  139. * @default 0
  140. *
  141. * @param Key T
  142. * @parent ---2nd Row---
  143. * @type common_event
  144. * @desc The common event to call when this button is pressed.
  145. * Set to 0 if you don't wish for a common event to call.
  146. * @default 0
  147. *
  148. * @param Key Y
  149. * @parent ---2nd Row---
  150. * @type common_event
  151. * @desc The common event to call when this button is pressed.
  152. * Set to 0 if you don't wish for a common event to call.
  153. * @default 0
  154. *
  155. * @param Key U
  156. * @parent ---2nd Row---
  157. * @type common_event
  158. * @desc The common event to call when this button is pressed.
  159. * Set to 0 if you don't wish for a common event to call.
  160. * @default 0
  161. *
  162. * @param Key I
  163. * @parent ---2nd Row---
  164. * @type common_event
  165. * @desc The common event to call when this button is pressed.
  166. * Set to 0 if you don't wish for a common event to call.
  167. * @default 0
  168. *
  169. * @param Key O
  170. * @parent ---2nd Row---
  171. * @type common_event
  172. * @desc The common event to call when this button is pressed.
  173. * Set to 0 if you don't wish for a common event to call.
  174. * @default 0
  175. *
  176. * @param Key P
  177. * @parent ---2nd Row---
  178. * @type common_event
  179. * @desc The common event to call when this button is pressed.
  180. * Set to 0 if you don't wish for a common event to call.
  181. * @default 0
  182. *
  183. * @param Key [
  184. * @parent ---2nd Row---
  185. * @type common_event
  186. * @desc The common event to call when this button is pressed.
  187. * Set to 0 if you don't wish for a common event to call.
  188. * @default 0
  189. *
  190. * @param Key ]
  191. * @parent ---2nd Row---
  192. * @type common_event
  193. * @desc The common event to call when this button is pressed.
  194. * Set to 0 if you don't wish for a common event to call.
  195. * @default 0
  196. *
  197. * @param Key \
  198. * @parent ---2nd Row---
  199. * @type common_event
  200. * @desc The common event to call when this button is pressed.
  201. * Set to 0 if you don't wish for a common event to call.
  202. * @default 0
  203. *
  204. * @param ---3rd Row---
  205. * @default
  206. *
  207. * @param Key A
  208. * @parent ---3rd Row---
  209. * @type common_event
  210. * @desc The common event to call when this button is pressed.
  211. * Set to 0 if you don't wish for a common event to call.
  212. * @default 0
  213. *
  214. * @param Key S
  215. * @parent ---3rd Row---
  216. * @type common_event
  217. * @desc The common event to call when this button is pressed.
  218. * Set to 0 if you don't wish for a common event to call.
  219. * @default 0
  220. *
  221. * @param Key D
  222. * @parent ---3rd Row---
  223. * @type common_event
  224. * @desc The common event to call when this button is pressed.
  225. * Set to 0 if you don't wish for a common event to call.
  226. * @default 0
  227. *
  228. * @param Key F
  229. * @parent ---3rd Row---
  230. * @type common_event
  231. * @desc The common event to call when this button is pressed.
  232. * Set to 0 if you don't wish for a common event to call.
  233. * @default 0
  234. *
  235. * @param Key G
  236. * @parent ---3rd Row---
  237. * @type common_event
  238. * @desc The common event to call when this button is pressed.
  239. * Set to 0 if you don't wish for a common event to call.
  240. * @default 0
  241. *
  242. * @param Key H
  243. * @parent ---3rd Row---
  244. * @type common_event
  245. * @desc The common event to call when this button is pressed.
  246. * Set to 0 if you don't wish for a common event to call.
  247. * @default 0
  248. *
  249. * @param Key J
  250. * @parent ---3rd Row---
  251. * @type common_event
  252. * @desc The common event to call when this button is pressed.
  253. * Set to 0 if you don't wish for a common event to call.
  254. * @default 0
  255. *
  256. * @param Key K
  257. * @parent ---3rd Row---
  258. * @type common_event
  259. * @desc The common event to call when this button is pressed.
  260. * Set to 0 if you don't wish for a common event to call.
  261. * @default 0
  262. *
  263. * @param Key L
  264. * @parent ---3rd Row---
  265. * @type common_event
  266. * @desc The common event to call when this button is pressed.
  267. * Set to 0 if you don't wish for a common event to call.
  268. * @default 0
  269. *
  270. * @param Key ;
  271. * @parent ---3rd Row---
  272. * @type common_event
  273. * @desc The common event to call when this button is pressed.
  274. * Set to 0 if you don't wish for a common event to call.
  275. * @default 0
  276. *
  277. * @param Key "
  278. * @parent ---3rd Row---
  279. * @type common_event
  280. * @desc The common event to call when this button is pressed.
  281. * Set to 0 if you don't wish for a common event to call.
  282. * @default 0
  283. *
  284. * @param Key Enter (OK)
  285. * @parent ---3rd Row---
  286. * @type common_event
  287. * @desc The common event to call when this button is pressed.
  288. * Set to 0 if you don't wish for a common event to call.
  289. * @default 0
  290. *
  291. * @param ---4th Row---
  292. * @default
  293. *
  294. * @param Key Shift (Dash)
  295. * @parent ---4th Row---
  296. * @type common_event
  297. * @desc The common event to call when this button is pressed.
  298. * Set to 0 if you don't wish for a common event to call.
  299. * @default 0
  300. *
  301. * @param Key Z (OK)
  302. * @parent ---4th Row---
  303. * @type common_event
  304. * @desc The common event to call when this button is pressed.
  305. * Set to 0 if you don't wish for a common event to call.
  306. * @default 0
  307. *
  308. * @param Key X (Cancel)
  309. * @parent ---4th Row---
  310. * @type common_event
  311. * @desc The common event to call when this button is pressed.
  312. * Set to 0 if you don't wish for a common event to call.
  313. * @default 0
  314. *
  315. * @param Key C
  316. * @parent ---4th Row---
  317. * @type common_event
  318. * @desc The common event to call when this button is pressed.
  319. * Set to 0 if you don't wish for a common event to call.
  320. * @default 0
  321. *
  322. * @param Key V
  323. * @parent ---4th Row---
  324. * @type common_event
  325. * @desc The common event to call when this button is pressed.
  326. * Set to 0 if you don't wish for a common event to call.
  327. * @default 0
  328. *
  329. * @param Key B
  330. * @parent ---4th Row---
  331. * @type common_event
  332. * @desc The common event to call when this button is pressed.
  333. * Set to 0 if you don't wish for a common event to call.
  334. * @default 0
  335. *
  336. * @param Key N
  337. * @parent ---4th Row---
  338. * @type common_event
  339. * @desc The common event to call when this button is pressed.
  340. * Set to 0 if you don't wish for a common event to call.
  341. * @default 0
  342. *
  343. * @param Key M
  344. * @parent ---4th Row---
  345. * @type common_event
  346. * @desc The common event to call when this button is pressed.
  347. * Set to 0 if you don't wish for a common event to call.
  348. * @default 0
  349. *
  350. * @param Key ,
  351. * @parent ---4th Row---
  352. * @type common_event
  353. * @desc The common event to call when this button is pressed.
  354. * Set to 0 if you don't wish for a common event to call.
  355. * @default 0
  356. *
  357. * @param Key .
  358. * @parent ---4th Row---
  359. * @type common_event
  360. * @desc The common event to call when this button is pressed.
  361. * Set to 0 if you don't wish for a common event to call.
  362. * @default 0
  363. *
  364. * @param Key /
  365. * @parent ---4th Row---
  366. * @type common_event
  367. * @desc The common event to call when this button is pressed.
  368. * Set to 0 if you don't wish for a common event to call.
  369. * @default 0
  370. *
  371. * @param ---Misc---
  372. * @default
  373. *
  374. * @param Key Space (OK)
  375. * @parent ---Misc---
  376. * @type common_event
  377. * @desc The common event to call when this button is pressed.
  378. * Set to 0 if you don't wish for a common event to call.
  379. * @default 0
  380. *
  381. * @param Key Left (Left)
  382. * @parent ---Misc---
  383. * @type common_event
  384. * @desc The common event to call when this button is pressed.
  385. * Set to 0 if you don't wish for a common event to call.
  386. * @default 0
  387. *
  388. * @param Key Up (Up)
  389. * @parent ---Misc---
  390. * @type common_event
  391. * @desc The common event to call when this button is pressed.
  392. * Set to 0 if you don't wish for a common event to call.
  393. * @default 0
  394. *
  395. * @param Key Right (Right)
  396. * @parent ---Misc---
  397. * @type common_event
  398. * @desc The common event to call when this button is pressed.
  399. * Set to 0 if you don't wish for a common event to call.
  400. * @default 0
  401. *
  402. * @param Key Down (Down)
  403. * @parent ---Misc---
  404. * @type common_event
  405. * @desc The common event to call when this button is pressed.
  406. * Set to 0 if you don't wish for a common event to call.
  407. * @default 0
  408. *
  409. * @param Key Insert (Cancel)
  410. * @parent ---Misc---
  411. * @type common_event
  412. * @desc The common event to call when this button is pressed.
  413. * Set to 0 if you don't wish for a common event to call.
  414. * @default 0
  415. *
  416. * @param Key Delete
  417. * @parent ---Misc---
  418. * @type common_event
  419. * @desc The common event to call when this button is pressed.
  420. * Set to 0 if you don't wish for a common event to call.
  421. * @default 0
  422. *
  423. * @param Key Home
  424. * @parent ---Misc---
  425. * @type common_event
  426. * @desc The common event to call when this button is pressed.
  427. * Set to 0 if you don't wish for a common event to call.
  428. * @default 0
  429. *
  430. * @param Key End
  431. * @parent ---Misc---
  432. * @type common_event
  433. * @desc The common event to call when this button is pressed.
  434. * Set to 0 if you don't wish for a common event to call.
  435. * @default 0
  436. *
  437. * @param Key Page Up (PageUp)
  438. * @parent ---Misc---
  439. * @type common_event
  440. * @desc The common event to call when this button is pressed.
  441. * Set to 0 if you don't wish for a common event to call.
  442. * @default 0
  443. *
  444. * @param Key Page Down (PageDown)
  445. * @parent ---Misc---
  446. * @type common_event
  447. * @desc The common event to call when this button is pressed.
  448. * Set to 0 if you don't wish for a common event to call.
  449. * @default 0
  450. *
  451. * @param ---NumPad---
  452. * @default
  453. *
  454. * @param Key NumPad 0 (Cancel)
  455. * @parent ---NumPad---
  456. * @type common_event
  457. * @desc The common event to call when this button is pressed.
  458. * Set to 0 if you don't wish for a common event to call.
  459. * @default 0
  460. *
  461. * @param Key NumPad 1
  462. * @parent ---NumPad---
  463. * @type common_event
  464. * @desc The common event to call when this button is pressed.
  465. * Set to 0 if you don't wish for a common event to call.
  466. * @default 0
  467. *
  468. * @param Key NumPad 2 (Down)
  469. * @parent ---NumPad---
  470. * @type common_event
  471. * @desc The common event to call when this button is pressed.
  472. * Set to 0 if you don't wish for a common event to call.
  473. * @default 0
  474. *
  475. * @param Key NumPad 3
  476. * @parent ---NumPad---
  477. * @type common_event
  478. * @desc The common event to call when this button is pressed.
  479. * Set to 0 if you don't wish for a common event to call.
  480. * @default 0
  481. *
  482. * @param Key NumPad 4 (Left)
  483. * @parent ---NumPad---
  484. * @type common_event
  485. * @desc The common event to call when this button is pressed.
  486. * Set to 0 if you don't wish for a common event to call.
  487. * @default 0
  488. *
  489. * @param Key NumPad 5
  490. * @parent ---NumPad---
  491. * @type common_event
  492. * @desc The common event to call when this button is pressed.
  493. * Set to 0 if you don't wish for a common event to call.
  494. * @default 0
  495. *
  496. * @param Key NumPad 6 (Right)
  497. * @parent ---NumPad---
  498. * @type common_event
  499. * @desc The common event to call when this button is pressed.
  500. * Set to 0 if you don't wish for a common event to call.
  501. * @default 0
  502. *
  503. * @param Key NumPad 7
  504. * @parent ---NumPad---
  505. * @type common_event
  506. * @desc The common event to call when this button is pressed.
  507. * Set to 0 if you don't wish for a common event to call.
  508. * @default 0
  509. *
  510. * @param Key NumPad 8 (Up)
  511. * @parent ---NumPad---
  512. * @type common_event
  513. * @desc The common event to call when this button is pressed.
  514. * Set to 0 if you don't wish for a common event to call.
  515. * @default 0
  516. *
  517. * @param Key NumPad 9
  518. * @parent ---NumPad---
  519. * @type common_event
  520. * @desc The common event to call when this button is pressed.
  521. * Set to 0 if you don't wish for a common event to call.
  522. * @default 0
  523. *
  524. * @param Key NumPad .
  525. * @parent ---NumPad---
  526. * @type common_event
  527. * @desc The common event to call when this button is pressed.
  528. * Set to 0 if you don't wish for a common event to call.
  529. * @default 0
  530. *
  531. * @param Key NumPad +
  532. * @parent ---NumPad---
  533. * @type common_event
  534. * @desc The common event to call when this button is pressed.
  535. * Set to 0 if you don't wish for a common event to call.
  536. * @default 0
  537. *
  538. * @param Key NumPad -
  539. * @parent ---NumPad---
  540. * @type common_event
  541. * @desc The common event to call when this button is pressed.
  542. * Set to 0 if you don't wish for a common event to call.
  543. * @default 0
  544. *
  545. * @param Key NumPad *
  546. * @parent ---NumPad---
  547. * @type common_event
  548. * @desc The common event to call when this button is pressed.
  549. * Set to 0 if you don't wish for a common event to call.
  550. * @default 0
  551. *
  552. * @param Key NumPad /
  553. * @parent ---NumPad---
  554. * @type common_event
  555. * @desc The common event to call when this button is pressed.
  556. * Set to 0 if you don't wish for a common event to call.
  557. * @default 0
  558. *
  559. * @help
  560. * ============================================================================
  561. * Introduction
  562. * ============================================================================
  563. *
  564. * This plugin enables you to bind common events to the individual buttons on
  565. * your keyboard. Instead of having the standard Z for OK and X for cancel,
  566. * you can make other keys work differently. With the exception of important
  567. * keys that shouldn't be altered, nearly full access is given across the span
  568. * of the keyboard.
  569. *
  570. * ============================================================================
  571. * Instructions
  572. * ============================================================================
  573. *
  574. * In the plugin's parameters, you will see a list of all the keys that you can
  575. * bind to a common event. If that number is something other than 0, then the
  576. * number associated with it will be the common event that will run. If you
  577. * assign it to a common event ID that does not exist, you will get an error so
  578. * please be wary of that.
  579. *
  580. * You may also notice that some of the keys have in parenthesis a word like
  581. * (OK) or (Cancel) next to them. What this means is that those keys already
  582. * have a function assigned to them by the game. If you assign a common event
  583. * to these keys, the native function of the key will be removed in favor of
  584. * the common event you've assigned.
  585. *
  586. * Here is a list of the keys that already have a common assigned:
  587. *
  588. * Key - What they're assigned to
  589. *   - Q         - Assigned to PageUp
  590. *   - W         - Assigned to PageDown
  591. *   - Shift     - Assigned to Dash
  592. *   - Z         - Assigned to OK
  593. *   - X         - Assigned to Cancel
  594. *   - Space     - Assigned to OK
  595. *   - Left      - Assigned to moving left
  596. *   - Up        - Assigned to moving up
  597. *   - Right     - Assigned to moving right
  598. *   - Down      - Assigned to moving down
  599. *   - Insert    - Assigned to Cancel
  600. *   - Page Up   - Assigned to PageUp
  601. *   - Page Down - Assigned to PageDown
  602. *   - Numpad 0  - Assigned to Cancel
  603. *   - Numpad 2  - Assigned to moving down
  604. *   - Numpad 4  - Assigned to moving left
  605. *   - Numpad 6  - Assigned to moving right
  606. *   - Numpad 8  - Assigned to moving up
  607. *
  608. * Once again, if you assign common events to these keys, the common event will
  609. * removing the binding the key had natively. However, this will only apply
  610. * while the player is in the field map. Being inside of a menu or battle
  611. * system will restore the previously native functions.
  612. *
  613. * ============================================================================
  614. * Compatibility Issues
  615. * ============================================================================
  616. *
  617. * This plugin will most likely have compatibility issues with anything that
  618. * alters keystrokes or makes use of them through a different manner.
  619. *
  620. * This will include the KeyboardConfig.js that was provided for the RPG Maker
  621. * MV plugin pack made by Yanfly Engine Plugins. A revision of this plugin
  622. * KeyboardConfig.js is made on Yanfly.moe for you to pick up! Make sure you
  623. * have YEP_KeyboardConfig.js version 1.01 in order for this to be compatible
  624. * with it. This plugin must be placed above YEP_KeyboardConfig.js for the
  625. * two plugins to work together.
  626. *
  627. * ============================================================================
  628. * Plugin Commands
  629. * ============================================================================
  630. *
  631. * For those who would like for a way to toggle back and forth between the
  632. * bound common events and the default buttons, use these plugin commands.
  633. *
  634. * Plugin Commands
  635. *
  636. *   RevertButton Ok
  637. *   RevertButton Cancel
  638. *   RevertButton Dash
  639. *   RevertButton PageUp
  640. *   RevertButton PageDown
  641. *   RevertButton Left
  642. *   RevertButton Up
  643. *   RevertButton Right
  644. *   RevertButton Down
  645. *   RevertButton All
  646. *   - Reverts all keys bound to any of the original functions back to their
  647. *   original buttons and unbinds the common events bound to them. If the "All"
  648. *   function is reverted, then all affected buttons will revert back to their
  649. *   original functions.
  650. *
  651. *   SwitchButton Ok
  652. *   SwitchButton Cancel
  653. *   SwitchButton Dash
  654. *   SwitchButton PageUp
  655. *   SwitchButton PageDown
  656. *   SwitchButton Left
  657. *   SwitchButton Up
  658. *   SwitchButton Right
  659. *   SwitchButton Down
  660. *   SwitchButton All
  661. *   - Switches all keys with original functions to use the common event binds
  662. *   instead of their original versions. If the "All" function is switched,
  663. *   then all affected buttons will switch to common event bindings if there
  664. *   are any.
  665. *
  666. *   TriggerButton Ok
  667. *   TriggerButton Cancel
  668. *   TriggerButton Dash
  669. *   TriggerButton PageUp
  670. *   TriggerButton PageDown
  671. *   TriggerButton Left
  672. *   TriggerButton Up
  673. *   TriggerButton Right
  674. *   TriggerButton Down
  675. *   - This will cause the game to simulate triggering the button command of
  676. *   one of those original functions even if there is a common event bound to
  677. *   all of the keys of that original function.
  678. *
  679. * ============================================================================
  680. * Changelog
  681. * ============================================================================
  682. *
  683. * Version 1.02:
  684. * - Updated for RPG Maker MV version 1.5.0.
  685. *
  686. * Version 1.01:
  687. * - Changed buttons from triggering to repeating so that common events can
  688. * continuously run while being held down.
  689. *
  690. * Version 1.00:
  691. * - Finished Plugin!
  692. */
  693. //=============================================================================

  694. //=============================================================================
  695. // Parameter Variables
  696. //=============================================================================

  697. Yanfly.Parameters = PluginManager.parameters('YEP_ButtonCommonEvents');
  698. Yanfly.Param = Yanfly.Param || {};

  699. Yanfly.Param.BCEList = {
  700.       tilde: Number(Yanfly.Parameters['Key ~']),
  701.           1: Number(Yanfly.Parameters['Key 1']),
  702.           2: Number(Yanfly.Parameters['Key 2']),
  703.           3: Number(Yanfly.Parameters['Key 3']),
  704.           4: Number(Yanfly.Parameters['Key 4']),
  705.           5: Number(Yanfly.Parameters['Key 5']),
  706.           6: Number(Yanfly.Parameters['Key 6']),
  707.           7: Number(Yanfly.Parameters['Key 7']),
  708.           8: Number(Yanfly.Parameters['Key 8']),
  709.           9: Number(Yanfly.Parameters['Key 9']),
  710.           0: Number(Yanfly.Parameters['Key 0']),
  711.       minus: Number(Yanfly.Parameters['Key -']),
  712.       equal: Number(Yanfly.Parameters['Key =']),

  713.           q: Number(Yanfly.Parameters['Key Q (PageUp)']),
  714.           w: Number(Yanfly.Parameters['Key W (PageDown)']),
  715.           e: Number(Yanfly.Parameters['Key E']),
  716.           r: Number(Yanfly.Parameters['Key R']),
  717.           t: Number(Yanfly.Parameters['Key T']),
  718.           y: Number(Yanfly.Parameters['Key Y']),
  719.           u: Number(Yanfly.Parameters['Key U']),
  720.           i: Number(Yanfly.Parameters['Key I']),
  721.           o: Number(Yanfly.Parameters['Key O']),
  722.           p: Number(Yanfly.Parameters['Key P']),
  723.   foreBrack: Number(Yanfly.Parameters['Key [']),
  724.   backBrack: Number(Yanfly.Parameters['Key ]']),
  725.   backSlash: Number(Yanfly.Parameters['Key \\']),

  726.           a: Number(Yanfly.Parameters['Key A']),
  727.           s: Number(Yanfly.Parameters['Key S']),
  728.           d: Number(Yanfly.Parameters['Key D']),
  729.           f: Number(Yanfly.Parameters['Key F']),
  730.           g: Number(Yanfly.Parameters['Key G']),
  731.           h: Number(Yanfly.Parameters['Key H']),
  732.           j: Number(Yanfly.Parameters['Key J']),
  733.           k: Number(Yanfly.Parameters['Key K']),
  734.           l: Number(Yanfly.Parameters['Key L']),
  735.   semicolon: Number(Yanfly.Parameters['Key ;']),
  736.       quote: Number(Yanfly.Parameters['Key "']),
  737.       enter: Number(Yanfly.Parameters['Key Enter (OK)']),

  738.    keyShift: Number(Yanfly.Parameters['Key Shift (Dash)']),
  739.           z: Number(Yanfly.Parameters['Key Z (OK)']),
  740.           x: Number(Yanfly.Parameters['Key X (Cancel)']),
  741.           c: Number(Yanfly.Parameters['Key C']),
  742.           v: Number(Yanfly.Parameters['Key V']),
  743.           b: Number(Yanfly.Parameters['Key B']),
  744.           n: Number(Yanfly.Parameters['Key N']),
  745.           m: Number(Yanfly.Parameters['Key M']),
  746.       comma: Number(Yanfly.Parameters['Key ,']),
  747.      period: Number(Yanfly.Parameters['Key .']),
  748.   foreSlash: Number(Yanfly.Parameters['Key /']),

  749.       space: Number(Yanfly.Parameters['Key Space (OK)']),
  750.     dirLeft: Number(Yanfly.Parameters['Key Left (Left)']),
  751.       dirUp: Number(Yanfly.Parameters['Key Up (Up)']),
  752.    dirRight: Number(Yanfly.Parameters['Key Right (Right)']),
  753.     dirDown: Number(Yanfly.Parameters['Key Down (Down)']),
  754.         ins: Number(Yanfly.Parameters['Key Insert (Cancel)']),
  755.         del: Number(Yanfly.Parameters['Key Delete']),
  756.        home: Number(Yanfly.Parameters['Key Home']),
  757.         end: Number(Yanfly.Parameters['Key End']),
  758.      pageUp: Number(Yanfly.Parameters['Key Page Up (PageUp)']),
  759.    pageDown: Number(Yanfly.Parameters['Key Page Down (PageDown)']),

  760.        num0: Number(Yanfly.Parameters['Key NumPad 0 (Cancel)']),
  761.        num1: Number(Yanfly.Parameters['Key NumPad 1']),
  762.        num2: Number(Yanfly.Parameters['Key NumPad 2 (Down)']),
  763.        num3: Number(Yanfly.Parameters['Key NumPad 3']),
  764.        num4: Number(Yanfly.Parameters['Key NumPad 4 (Left)']),
  765.        num5: Number(Yanfly.Parameters['Key NumPad 5']),
  766.        num6: Number(Yanfly.Parameters['Key NumPad 6 (Right)']),
  767.        num7: Number(Yanfly.Parameters['Key NumPad 7']),
  768.        num8: Number(Yanfly.Parameters['Key NumPad 8 (Up)']),
  769.        num9: Number(Yanfly.Parameters['Key NumPad 9']),
  770.   numPeriod: Number(Yanfly.Parameters['Key NumPad .']),
  771.     numPlus: Number(Yanfly.Parameters['Key NumPad +']),
  772.    numMinus: Number(Yanfly.Parameters['Key NumPad -']),
  773.    numTimes: Number(Yanfly.Parameters['Key NumPad *']),
  774.   numDivide: Number(Yanfly.Parameters['Key NumPad /'])
  775. };
  776. Yanfly.Param.Variables = String(Yanfly.Parameters['Variables']);

  777. //=============================================================================
  778. // Input Key Mapper
  779. //=============================================================================

  780. if (Yanfly.Param.BCEList['tilde'] !== 0) Input.keyMapper[192]     = 'tilde';
  781. if (Yanfly.Param.BCEList['1'] !== 0) Input.keyMapper[49]          = '1';
  782. if (Yanfly.Param.BCEList['2'] !== 0) Input.keyMapper[50]          = '2';
  783. if (Yanfly.Param.BCEList['3'] !== 0) Input.keyMapper[51]          = '3';
  784. if (Yanfly.Param.BCEList['4'] !== 0) Input.keyMapper[52]          = '4';
  785. if (Yanfly.Param.BCEList['5'] !== 0) Input.keyMapper[53]          = '5';
  786. if (Yanfly.Param.BCEList['6'] !== 0) Input.keyMapper[54]          = '6';
  787. if (Yanfly.Param.BCEList['7'] !== 0) Input.keyMapper[55]          = '7';
  788. if (Yanfly.Param.BCEList['8'] !== 0) Input.keyMapper[56]          = '8';
  789. if (Yanfly.Param.BCEList['9'] !== 0) Input.keyMapper[57]          = '9';
  790. if (Yanfly.Param.BCEList['0'] !== 0) Input.keyMapper[48]          = '0';
  791. if (Yanfly.Param.BCEList['minus'] !== 0) Input.keyMapper[189]     = 'minus';
  792. if (Yanfly.Param.BCEList['equal'] !== 0) Input.keyMapper[187]     = 'equal';

  793. if (Yanfly.Param.BCEList['q'] !== 0) Input.keyMapper[81]          = 'q';
  794. if (Yanfly.Param.BCEList['w'] !== 0) Input.keyMapper[87]          = 'w';
  795. if (Yanfly.Param.BCEList['e'] !== 0) Input.keyMapper[69]          = 'e';
  796. if (Yanfly.Param.BCEList['r'] !== 0) Input.keyMapper[82]          = 'r';
  797. if (Yanfly.Param.BCEList['t'] !== 0) Input.keyMapper[84]          = 't';
  798. if (Yanfly.Param.BCEList['y'] !== 0) Input.keyMapper[89]          = 'y';
  799. if (Yanfly.Param.BCEList['u'] !== 0) Input.keyMapper[85]          = 'u';
  800. if (Yanfly.Param.BCEList['i'] !== 0) Input.keyMapper[73]          = 'i';
  801. if (Yanfly.Param.BCEList['o'] !== 0) Input.keyMapper[79]          = 'o';
  802. if (Yanfly.Param.BCEList['p'] !== 0) Input.keyMapper[80]          = 'p';
  803. if (Yanfly.Param.BCEList['foreBrack'] !== 0) Input.keyMapper[219] = 'foreBrack';
  804. if (Yanfly.Param.BCEList['backBrack'] !== 0) Input.keyMapper[221] = 'backBrack';
  805. if (Yanfly.Param.BCEList['backSlash'] !== 0) Input.keyMapper[220] = 'backSlash';

  806. if (Yanfly.Param.BCEList['a'] !== 0) Input.keyMapper[65]          = 'a';
  807. if (Yanfly.Param.BCEList['s'] !== 0) Input.keyMapper[83]          = 's';
  808. if (Yanfly.Param.BCEList['d'] !== 0) Input.keyMapper[68]          = 'd';
  809. if (Yanfly.Param.BCEList['f'] !== 0) Input.keyMapper[70]          = 'f';
  810. if (Yanfly.Param.BCEList['g'] !== 0) Input.keyMapper[71]          = 'g';
  811. if (Yanfly.Param.BCEList['h'] !== 0) Input.keyMapper[72]          = 'h';
  812. if (Yanfly.Param.BCEList['j'] !== 0) Input.keyMapper[74]          = 'j';
  813. if (Yanfly.Param.BCEList['k'] !== 0) Input.keyMapper[75]          = 'k';
  814. if (Yanfly.Param.BCEList['l'] !== 0) Input.keyMapper[76]          = 'l';
  815. if (Yanfly.Param.BCEList['semicolon'] !== 0) Input.keyMapper[186] = 'semicolon';
  816. if (Yanfly.Param.BCEList['quote'] !== 0) Input.keyMapper[222]     = 'quote';
  817. if (Yanfly.Param.BCEList['enter'] !== 0) Input.keyMapper[13]      = 'enter';

  818. if (Yanfly.Param.BCEList['keyShift'] !== 0) Input.keyMapper[16]   = 'keyShift';
  819. if (Yanfly.Param.BCEList['z'] !== 0) Input.keyMapper[90]          = 'z';
  820. if (Yanfly.Param.BCEList['x'] !== 0) Input.keyMapper[88]          = 'x';
  821. if (Yanfly.Param.BCEList['c'] !== 0) Input.keyMapper[67]          = 'c';
  822. if (Yanfly.Param.BCEList['v'] !== 0) Input.keyMapper[86]          = 'v';
  823. if (Yanfly.Param.BCEList['b'] !== 0) Input.keyMapper[66]          = 'b';
  824. if (Yanfly.Param.BCEList['n'] !== 0) Input.keyMapper[78]          = 'n';
  825. if (Yanfly.Param.BCEList['m'] !== 0) Input.keyMapper[77]          = 'm';
  826. if (Yanfly.Param.BCEList['comma'] !== 0) Input.keyMapper[188]     = 'comma';
  827. if (Yanfly.Param.BCEList['period'] !== 0) Input.keyMapper[190]    = 'period';
  828. if (Yanfly.Param.BCEList['foreSlash'] !== 0) Input.keyMapper[191] = 'foreSlash';

  829. if (Yanfly.Param.BCEList['space'] !== 0) Input.keyMapper[32]     = 'space';
  830. if (Yanfly.Param.BCEList['dirLeft'] !== 0) Input.keyMapper[37]   = 'dirLeft';
  831. if (Yanfly.Param.BCEList['dirUp'] !== 0) Input.keyMapper[38]     = 'dirUp';
  832. if (Yanfly.Param.BCEList['dirRight'] !== 0) Input.keyMapper[39]  = 'dirRight';
  833. if (Yanfly.Param.BCEList['dirDown'] !== 0) Input.keyMapper[40]   = 'dirDown';
  834. if (Yanfly.Param.BCEList['ins'] !== 0) Input.keyMapper[45]       = 'ins';
  835. if (Yanfly.Param.BCEList['del'] !== 0)Input.keyMapper[46]        = 'del';
  836. if (Yanfly.Param.BCEList['home'] !== 0)Input.keyMapper[36]       = 'home';
  837. if (Yanfly.Param.BCEList['end'] !== 0)Input.keyMapper[35]        = 'end';
  838. if (Yanfly.Param.BCEList['pageUp'] !== 0) Input.keyMapper[33]    = 'pageUp';
  839. if (Yanfly.Param.BCEList['pageDown'] !== 0) Input.keyMapper[34]  = 'pageDown';

  840. if (Yanfly.Param.BCEList['num0'] !== 0) Input.keyMapper[96]      = 'num0';
  841. if (Yanfly.Param.BCEList['num1'] !== 0)Input.keyMapper[97]       = 'num1';
  842. if (Yanfly.Param.BCEList['num2'] !== 0) Input.keyMapper[98]      = 'num2';
  843. if (Yanfly.Param.BCEList['num3'] !== 0)Input.keyMapper[99]       = 'num3';
  844. if (Yanfly.Param.BCEList['num4'] !== 0) Input.keyMapper[100]     = 'num4';
  845. if (Yanfly.Param.BCEList['num5'] !== 0)Input.keyMapper[101]      = 'num5';
  846. if (Yanfly.Param.BCEList['num6'] !== 0) Input.keyMapper[102]     = 'num6';
  847. if (Yanfly.Param.BCEList['num7'] !== 0)Input.keyMapper[103]      = 'num7';
  848. if (Yanfly.Param.BCEList['num8'] !== 0) Input.keyMapper[104]     = 'num8';
  849. if (Yanfly.Param.BCEList['num9'] !== 0)Input.keyMapper[105]      = 'num9';
  850. if (Yanfly.Param.BCEList['numPeriod'] !== 0)Input.keyMapper[110] = 'numPeriod';
  851. if (Yanfly.Param.BCEList['numPlus'] !== 0)Input.keyMapper[107]   = 'numPlus';
  852. if (Yanfly.Param.BCEList['numMinus'] !== 0)Input.keyMapper[109]  = 'numMinus';
  853. if (Yanfly.Param.BCEList['numTimes'] !== 0)Input.keyMapper[106]  = 'numTimes';
  854. if (Yanfly.Param.BCEList['numDivide'] !== 0)Input.keyMapper[111] = 'numDivide';

  855. //=============================================================================
  856. // Input
  857. //=============================================================================

  858. Input._revertButton = function(button) {
  859.   if (button === 'OK') {
  860.     this.keyMapper[13] = 'ok';
  861.     this.keyMapper[32] = 'ok';
  862.     this.keyMapper[90] = 'ok';
  863.   } else if (button === 'CANCEL') {
  864.     this.keyMapper[45] = 'escape';
  865.     this.keyMapper[88] = 'escape';
  866.     this.keyMapper[96] = 'escape';
  867.   } else if (button === 'DASH') {
  868.     this.keyMapper[16] = 'shift';
  869.   } else if (button === 'PAGEUP') {
  870.     this.keyMapper[33] = 'pageup';
  871.     this.keyMapper[81] = 'pageup';
  872.   } else if (button === 'PAGEDOWN') {
  873.     this.keyMapper[34] = 'pagedown';
  874.     this.keyMapper[87] = 'pagedown';
  875.   } else if (button === 'LEFT') {
  876.     this.keyMapper[37] = 'left';
  877.     this.keyMapper[100] = 'left';
  878.   } else if (button === 'UP') {
  879.     this.keyMapper[38] = 'up';
  880.     this.keyMapper[104] = 'up';
  881.   } else if (button === 'RIGHT') {
  882.     this.keyMapper[39] = 'right';
  883.     this.keyMapper[102] = 'right';
  884.   } else if (button === 'DOWN') {
  885.     this.keyMapper[40] = 'down';
  886.     this.keyMapper[98] = 'down';
  887.   } else if (button === 'ALL') {
  888.     this.keyMapper[13] = 'ok';
  889.     this.keyMapper[32] = 'ok';
  890.     this.keyMapper[90] = 'ok';
  891.     this.keyMapper[45] = 'escape';
  892.     this.keyMapper[88] = 'escape';
  893.     this.keyMapper[96] = 'escape';
  894.     this.keyMapper[16] = 'shift';
  895.     this.keyMapper[33] = 'pageup';
  896.     this.keyMapper[81] = 'pageup';
  897.     this.keyMapper[34] = 'pagedown';
  898.     this.keyMapper[87] = 'pagedown';
  899.     this.keyMapper[37] = 'left';
  900.     this.keyMapper[100] = 'left';
  901.     this.keyMapper[38] = 'up';
  902.     this.keyMapper[104] = 'up';
  903.     this.keyMapper[39] = 'right';
  904.     this.keyMapper[102] = 'right';
  905.     this.keyMapper[40] = 'down';
  906.     this.keyMapper[98] = 'down';
  907.   }
  908. }

  909. Input._switchButton = function(button) {
  910.   if (button === 'OK') {
  911.     if (Yanfly.Param.BCEList['enter'] !== 0) this.keyMapper[13] = 'enter';
  912.     if (Yanfly.Param.BCEList['space'] !== 0) this.keyMapper[32] = 'space';
  913.     if (Yanfly.Param.BCEList['z'] !== 0) this.keyMapper[90] = 'z';
  914.   } else if (button === 'CANCEL') {
  915.     if (Yanfly.Param.BCEList['ins'] !== 0) this.keyMapper[45] = 'ins';
  916.     if (Yanfly.Param.BCEList['x'] !== 0) this.keyMapper[88] = 'x';
  917.     if (Yanfly.Param.BCEList['num0'] !== 0) this.keyMapper[96] = 'num0';
  918.   } else if (button === 'DASH') {
  919.     if (Yanfly.Param.BCEList['keyShift'] !== 0) this.keyMapper[16] = 'keyShift';
  920.   } else if (button === 'PAGEUP') {
  921.     if (Yanfly.Param.BCEList['pageUp'] !== 0) this.keyMapper[33] = 'pageUp';
  922.     if (Yanfly.Param.BCEList['q'] !== 0) this.keyMapper[81] = 'q';
  923.   } else if (button === 'PAGEDOWN') {
  924.     if (Yanfly.Param.BCEList['pageDown'] !== 0) this.keyMapper[34] = 'pageDown';
  925.     if (Yanfly.Param.BCEList['w'] !== 0) this.keyMapper[87] = 'w';
  926.   } else if (button === 'LEFT') {
  927.     if (Yanfly.Param.BCEList['dirLeft'] !== 0) this.keyMapper[37] = 'dirLeft';
  928.     if (Yanfly.Param.BCEList['num4'] !== 0) this.keyMapper[100] = 'num4';
  929.   } else if (button === 'UP') {
  930.     if (Yanfly.Param.BCEList['dirUp'] !== 0) this.keyMapper[38] = 'dirUp';
  931.     if (Yanfly.Param.BCEList['num8'] !== 0) this.keyMapper[104] = 'num8';
  932.   } else if (button === 'RIGHT') {
  933.     if (Yanfly.Param.BCEList['dirRight'] !== 0) this.keyMapper[39] = 'dirRight';
  934.     if (Yanfly.Param.BCEList['num6'] !== 0) this.keyMapper[102] = 'num6';
  935.   } else if (button === 'DOWN') {
  936.     if (Yanfly.Param.BCEList['dirDown'] !== 0) this.keyMapper[40] = 'dirDown';
  937.     if (Yanfly.Param.BCEList['num2'] !== 0) this.keyMapper[98] = 'num2';
  938.   } else if (button === 'ALL') {
  939.     if (Yanfly.Param.BCEList['enter'] !== 0) this.keyMapper[13] = 'enter';
  940.     if (Yanfly.Param.BCEList['space'] !== 0) this.keyMapper[32] = 'space';
  941.     if (Yanfly.Param.BCEList['z'] !== 0) this.keyMapper[90] = 'z';
  942.     if (Yanfly.Param.BCEList['ins'] !== 0) this.keyMapper[45] = 'ins';
  943.     if (Yanfly.Param.BCEList['x'] !== 0) this.keyMapper[88] = 'x';
  944.     if (Yanfly.Param.BCEList['num0'] !== 0) this.keyMapper[96] = 'num0';
  945.     if (Yanfly.Param.BCEList['keyShift'] !== 0) this.keyMapper[16] = 'keyShift';
  946.     if (Yanfly.Param.BCEList['pageUp'] !== 0) this.keyMapper[33] = 'pageUp';
  947.     if (Yanfly.Param.BCEList['q'] !== 0) this.keyMapper[81] = 'q';
  948.     if (Yanfly.Param.BCEList['pageDown'] !== 0) this.keyMapper[34] = 'pageDown';
  949.     if (Yanfly.Param.BCEList['w'] !== 0) this.keyMapper[87] = 'w';
  950.     if (Yanfly.Param.BCEList['dirLeft'] !== 0) this.keyMapper[37] = 'dirLeft';
  951.     if (Yanfly.Param.BCEList['num4'] !== 0) this.keyMapper[100] = 'num4';
  952.     if (Yanfly.Param.BCEList['dirUp'] !== 0) this.keyMapper[38] = 'dirUp';
  953.     if (Yanfly.Param.BCEList['num8'] !== 0) this.keyMapper[104] = 'num8';
  954.     if (Yanfly.Param.BCEList['dirRight'] !== 0) this.keyMapper[39] = 'dirRight';
  955.     if (Yanfly.Param.BCEList['num6'] !== 0) this.keyMapper[102] = 'num6';
  956.     if (Yanfly.Param.BCEList['dirDown'] !== 0) this.keyMapper[40] = 'dirDown';
  957.     if (Yanfly.Param.BCEList['num2'] !== 0) this.keyMapper[98] = 'num2';
  958.   }
  959. };

  960. //=============================================================================
  961. // Scene_Base
  962. //=============================================================================

  963. Yanfly.BCE.Scene_Base_start = Scene_Base.prototype.start;
  964. Scene_Base.prototype.start = function() {
  965.     Yanfly.BCE.Scene_Base_start.call(this);
  966.     Input._revertButton('ALL');
  967. };

  968. //=============================================================================
  969. // Scene_Map
  970. //=============================================================================

  971. Yanfly.BCE.Scene_Map_start = Scene_Map.prototype.start;
  972. Scene_Map.prototype.start = function() {
  973.     Yanfly.BCE.Scene_Map_start.call(this);
  974.     Input._switchButton('ALL');
  975. };

  976. Yanfly.BCE.Scene_Map_updateScene = Scene_Map.prototype.updateScene;
  977. Scene_Map.prototype.updateScene = function() {
  978.     Yanfly.BCE.Scene_Map_updateScene.call(this);
  979.     if (SceneManager.isSceneChanging()) return;
  980.     if ($gameMap.isEventRunning()) return;
  981.     this.updateButtonEvents();
  982. };

  983. Scene_Map.prototype.updateButtonEvents = function() {
  984.     for (var key in Yanfly.Param.BCEList) {
  985.       var eventId = Yanfly.Param.BCEList[key];
  986.       if (eventId <= 0) continue;
  987.       if (!Input.isRepeated(key)) continue;
  988.       $gameTemp.reserveCommonEvent(eventId);
  989.       break;
  990.     }
  991. };

  992. //=============================================================================
  993. // Game_Interpreter
  994. //=============================================================================

  995. Yanfly.BCE.Game_Interpreter_pluginCommand =
  996.     Game_Interpreter.prototype.pluginCommand;
  997. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  998.   Yanfly.BCE.Game_Interpreter_pluginCommand.call(this, command, args);
  999.   if (command === 'RevertButton') this.revertButton(args);
  1000.   if (command === 'SwitchButton') this.switchButton(args);
  1001.   if (command === 'TriggerButton') this.triggerButton(args);
  1002. };

  1003. Game_Interpreter.prototype.revertButton = function(args) {
  1004.   if (!args) return;
  1005.   var button = args[0].toUpperCase();
  1006.   Input._revertButton(button);
  1007. };

  1008. Game_Interpreter.prototype.switchButton = function(args) {
  1009.   if (!args) return;
  1010.   var button = args[0].toUpperCase();
  1011.   Input._switchButton(button);
  1012. };

  1013. Game_Interpreter.prototype.triggerButton = function(args) {
  1014.   if (!args) return;
  1015.   var button = args[0].toLowerCase();
  1016.   if (button === 'cancel') button = 'escape';
  1017.   if (button === 'dash') button = 'shift';
  1018.   Input._latestButton = button;
  1019.   Input._pressedTime = 0;
  1020. };

  1021. //=============================================================================
  1022. // End of File
  1023. //=============================================================================
复制代码
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
22968
在线时间
8639 小时
注册时间
2011-12-31
帖子
3367
5
发表于 2017-11-18 13:38:49 | 只看该作者
本帖最后由 tseyik 于 2017-11-18 13:46 编辑
  1. [pre lang="javascript"]//=============================================================================
  2. // Mano_SymbolCommonEventCall.js
  3. // ----------------------------------------------------------------------------
  4. // Copyright (c) 2017-2017 Sigureya
  5. // This software is released under the MIT License.
  6. // http://opensource.org/licenses/mit-license.php
  7. // ----------------------------------------------------------------------------
  8. // [Twitter]: https://twitter.com/Sigureya/
  9. // [github]:https://github.com/Sigureya/RPGmakerMV
  10. //=============================================================================

  11. /*:
  12. * @plugindesc マップ上で、1ボタンでコモンイベントを呼び出す機能を追加します。
  13. *
  14. *
  15. * @author しぐれん(魔のささやき)
  16. *
  17. * @param commonA
  18. * @type Struct<CommonDefine>
  19. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event1","description":"イベント1","text":"テキスト1","keycode":"","padButton":"-1"}
  20. *
  21. * @param commonB
  22. * @type Struct<CommonDefine>
  23. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event2","description":"イベント2","text":"テキスト2","keycode":"","padButton":"-1"}
  24. *
  25. * @param commonC
  26. * @type Struct<CommonDefine>
  27. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event3","description":"イベント3","text":"テキスト3","keycode":"","padButton":"-1"}
  28. *
  29. * @param commonD
  30. * @type Struct<CommonDefine>
  31. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event4","description":"イベント4","text":"テキスト4","keycode":"","padButton":"-1"}
  32. *
  33. * @param commonE
  34. * @type Struct<CommonDefine>
  35. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event5","description":"イベント5","text":"テキスト5","keycode":"","padButton":"-1"}
  36. *
  37. * @param commonF
  38. * @type Struct<CommonDefine>
  39. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event6","description":"イベント6","text":"テキスト6","keycode":"","padButton":"-1"}
  40. *
  41. * @param commonG
  42. * @type Struct<CommonDefine>
  43. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event7","description":"イベント7","text":"テキスト7","keycode":"","padButton":"-1"}
  44. *
  45. * @param commonH
  46. * @type Struct<CommonDefine>
  47. * @default {"enabled":"false","enableSwitch":"0","event":"0","symbol":"event8","description":"イベント8","text":"テキスト8","keycode":"","padButton":"-1"}
  48. *
  49. * @help
  50. * 1ボタンでコモンイベントを呼び出せるようになります。
  51. * ゲームパッドにも対応しています。
  52. *
  53. * マップ中でのみ有効です。
  54. * Aから順に呼び出し判定を行います。
  55. * 一つでも呼びだされた場合、残りは呼ばれません.
  56. *
  57. * 呼び出しのタイミングは、通常のコモンイベントの実行が終了したあとです。
  58. *
  59. * ゲームパッドのボタンですが、割り当てはGamepadAPIで調べてください。
  60. * 16は意図的に割り当て不能にしています。
  61. * 存在しない場合もあるためです。
  62. * 12から15は十字キーなので不可。
  63. * 元から機能が割り当てられている0~5への割り当ては、自己責任でお願いします。
  64. *
  65. * Mano_InputConfigよりも上に入れることで、
  66. * Mano_InputConfig用の設定を自動で用意します。
  67. *
  68. * Mano_InputConfigと一緒に入れている状態で動かない場合、
  69. * オプション画面を開いて初期設定に戻すを選択してください。
  70. * 解決するかもしれません。
  71. *
  72. * var 1.0(2017/10/17) 公開
  73. */

  74. /*~struct~CommonDefine:
  75. * @param enabled
  76. * @desc このパラメータがONの時だけ、機能します
  77. * デバッグ用に機能を無効化する場合を想定しています
  78. * @type boolean
  79. *  
  80. * @param enableSwitch
  81. * @desc 指定したスイッチがONの時だけ、呼びだしを行います。
  82. * 指定がない場合、チェックしません。
  83. * @type switch
  84. * @default 0
  85. *
  86. * @param event
  87. * @desc 呼びだされるコモンイベント
  88. * @type common_event
  89. *
  90. * @param symbol
  91. * @desc Input.isTriggered()の引数として使われます
  92. *
  93. * @param text
  94. * @desc コマンド名称です
  95. *
  96. * @param mandatory
  97. * @desc inputConfigの方で必須指定されたものとして扱います。
  98. * @type boolean
  99. * @default false
  100. *
  101. * @param keycode
  102. * @desc キーボードの割り当てです
  103. * キーコードは各自調べてください
  104. * @type number
  105. *
  106. * @param padButton
  107. * @desc ゲームパッドの割り当てです
  108. * カッコ内はツクールのデフォルトでの割り当てです
  109. * @type select
  110. * @default -1
  111. * @option non(割り当てなし)
  112. * @value -1
  113. * @type select
  114. * @option button6
  115. * @value 6
  116. * @option button7
  117. * @value 7
  118. * @option button8
  119. * @value 8
  120. * @option button9
  121. * @value 9
  122. * @option button10
  123. * @value 10
  124. * @option button11
  125. * @value 11
  126. * @option button0(ok/決定)
  127. * @value 0
  128. * @option button1(cancel/キャンセル)
  129. * @value 1
  130. * @option button2(shift/ダッシュ)
  131. * @value 2
  132. * @option button3(menu/メニュー)
  133. * @value 3
  134. * @option button4(pageup)
  135. * @value 4
  136. * @option button5(pagedown)
  137. * @value 5
  138. */
  139. /*~
  140. * @param description
  141. * @desc コマンドの簡易説明です
  142. * Mano_InputConfigと組み合わせて使います
  143. *
  144. */
  145. function MA_OneButtonCommonEvent(){
  146.     this.initialize.apply(this,arguments);
  147. }

  148. var MA_InputSymbols =MA_InputSymbols||[];

  149. (function () {
  150.     'use strict';
  151. function fetchCommonEvent(CommonDefine){
  152.     const obj =JSON.parse(CommonDefine);
  153.     const enabled=(obj.enabled==='true');
  154.     if(!enabled){
  155.         return null;
  156.     }
  157.     return {
  158. //        enabled:(obj.enabled==='true'),
  159.         enableSwitch:Number(obj.enableSwitch ||0 ),
  160.         symbol:String(obj.symbol),
  161.         text:String(obj.text),
  162.         eventId:Number(obj.event),
  163.         keycode:Number(obj.keycode),
  164.         padButtonNumber:Number(obj.padButton),
  165.         mandatory:(obj.mandatory==='true'),
  166.     };
  167. }
  168. function createCommonEventList(params){
  169.     return [
  170.         fetchCommonEvent(params.commonA),
  171.         fetchCommonEvent(params.commonB),
  172.         fetchCommonEvent(params.commonC),
  173.         fetchCommonEvent(params.commonD),
  174.         fetchCommonEvent(params.commonE),
  175.         fetchCommonEvent(params.commonF),
  176.         fetchCommonEvent(params.commonG),
  177.         fetchCommonEvent(params.commonH),        
  178.     ];//.filter(function(e){return !!e});
  179. }
  180. function createSetting(){
  181.     const params =PluginManager.parameters('Mano_OneButtonCommonEventCall')
  182.     const result= {
  183.         eventList:createCommonEventList(params)
  184.     };
  185.     return result;
  186. }

  187. const setting = createSetting();

  188. function setMapper(){

  189.     setting.eventList.forEach(function(data){
  190.         if(!data){return;}
  191.         if(data.keycode !==undefined){
  192.             Input.keyMapper[data.keycode ] =data.symbol;
  193.         }
  194.         if( (  data.padButtonNumber)>=0){
  195.             Input.gamepadMapper[ data.padButtonNumber]=data.symbol;
  196.         }

  197.         MA_InputSymbols.push({
  198.             mandatory:data.mandatory,
  199.             text:data.text,
  200.             symbol:data.symbol,
  201.         })
  202.     })
  203. }

  204. setMapper();
  205. /**
  206. * @param {Number} settingId
  207. */
  208. MA_OneButtonCommonEvent.prototype.initialize =function(settingId){
  209.     const param =setting.eventList[settingId];
  210.     this._commonEventId = param.eventId;
  211.     this._enableSwitch=  param.enableSwitch;
  212.     this._symbol= param.symbol;
  213.     this._interpreter = null;
  214.     this.refresh()
  215. };
  216. MA_OneButtonCommonEvent.prototype.refresh = function() {
  217.     if (!this._interpreter) {
  218.         this._interpreter = new Game_Interpreter();
  219.     }
  220. };

  221. /**
  222. * @return {RPG.Event}
  223. */
  224. MA_OneButtonCommonEvent.prototype.event =function(){
  225.     return $dataCommonEvents[this._commonEventId];
  226. };
  227. /**
  228. * @return {RPG.EventCommand[]}
  229. */
  230. MA_OneButtonCommonEvent.prototype.list = function() {
  231.     return this.event().list;
  232. };
  233. MA_OneButtonCommonEvent.prototype.isSwitchOk =function(){
  234.     return this._enableSwitch ===0||$gameSwitches.value(this._enableSwitch);
  235. };

  236. MA_OneButtonCommonEvent.prototype.isCalled=function(){
  237.     return Input.isTriggered(this._symbol);
  238. };

  239. MA_OneButtonCommonEvent.prototype.update=function(){
  240.     if (this._interpreter) {
  241.         if (!this._interpreter.isRunning()  && this.isCalled() ) {
  242.             if(this.isSwitchOk()){
  243.                 this._interpreter.setup(this.list());
  244.             }
  245.         }
  246.         this._interpreter.update();
  247.     }
  248. };
  249. /**
  250. * @return {MA_OneButtonCommonEvent[]}
  251. */
  252. function createOneButtonEvents(){
  253.     const result =[];
  254.     const len =setting.eventList.length
  255.     for(var i=0; i < len; ++i){
  256.         var e =setting.eventList[i]
  257.         if(e && e.eventId !==0 ){
  258.             result.push( new MA_OneButtonCommonEvent(i));
  259.         }
  260.     }
  261.     return result;
  262. }

  263. const Game_Map_initialize=Game_Map.prototype.initialize;
  264. Game_Map.prototype.initialize =function(){
  265.     Game_Map_initialize.apply(this,arguments);
  266.     this._oneButtonEvents =[];
  267. };

  268. const  Game_Map_setupEvents=Game_Map.prototype.setupEvents;
  269. Game_Map.prototype.setupEvents =function(){
  270.     Game_Map_setupEvents.call(this);
  271.     this.setupOneButtonEvents();
  272. };

  273. Game_Map.prototype.setupOneButtonEvents =function(){
  274.     this._oneButtonEvents=createOneButtonEvents();         
  275. };

  276. const  Game_Map_updateEvents=Game_Map.prototype.updateEvents;
  277. Game_Map.prototype.updateEvents =function(){
  278.     this._oneButtonEvents.forEach(function(event){
  279.         event.update();
  280.     });
  281.     Game_Map_updateEvents.call(this);
  282. };

  283. const Scene_Load_reloadMapIfUpdated =Scene_Load.prototype.reloadMapIfUpdated;
  284. Scene_Load.prototype.reloadMapIfUpdated =function (){
  285.     Scene_Load_reloadMapIfUpdated.call(this);
  286.     if($gameMap._oneButtonEvents){
  287.         $gameMap.setupOneButtonEvents();
  288.     }
  289. } ;

  290. })();
  291. [/pre]

复制代码
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
19285
在线时间
2308 小时
注册时间
2015-7-4
帖子
937
6
 楼主| 发表于 2017-11-18 15:39:44 | 只看该作者
感谢两位大神!都收下了,晚上研究。
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-18 22:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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