Project1

标题: 用一个量计算某个开关的使用次数 [打印本页]

作者: ywl@project1    时间: 2022-5-31 21:43
标题: 用一个量计算某个开关的使用次数
本帖最后由 ywl@project1 于 2022-5-31 21:46 编辑

我想用一个数来当做分支条件的前提,具体就是当特定开关被使用过一定次数之后,可以开启分支条件。不知道表达清楚了吗

就是开关A,使用过1次后,一个数B加1.
然后我想用这个数B.
作者: alexncf125    时间: 2022-5-31 22:33
  1. class Game_Switches
  2.   alias :timer_turnon_switchesone :[]=
  3.   def []=(switch_id, value)
  4.     $game_variables[1] += 1 if switch_id == 1 && value == true
  5.     timer_turnon_switchesone(switch_id, value)
  6.   end
  7. end
复制代码

作者: ywl@project1    时间: 2022-6-1 00:09
本帖最后由 ywl@project1 于 2022-6-1 01:08 编辑
alexncf125 发表于 2022-5-31 22:33


确实实现了。
非常感谢。
请问$game_variables[1] += 1 if switch_id == 1 && value == true是怎么想出来的?我只能看到有种恍然大悟的感觉,自己怎么也想不到这么表达。
顺带问一下:用class Variables能实现吗?

作者: alexncf125    时间: 2022-6-1 09:05
ywl[url=home.php?mod=space&uid=2692918]@project1 发表于 2022-6-1 00:09[/url]
确实实现了。
非常感谢。
请问$game_variables[1] += 1 if switch_id == 1 && value == true是怎么想出来 ...


怎么想出来的?
不就按你的要求想出来的

就是开关A  ----   switch_id == 1
使用过1次后  ----   value == true
一个数B加1.  ----   $game_variables[1] += 1

顺带问一下:class Variables是什么东西
作者: ywl@project1    时间: 2022-6-1 22:52
alexncf125 发表于 2022-6-1 09:05
怎么想出来的?
不就按你的要求想出来的

class Variables 我的意思是用变量定义的方式能不能完成我在这个帖子里提出的要求。
可能问题有点蠢。哈哈




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1