Project1

标题: 如何用脚本批量控制开关与变数? [打印本页]

作者: so_aries    时间: 2015-2-27 16:26
标题: 如何用脚本批量控制开关与变数?
搜寻半天,还是找不到。
这事件脚本没人有需求吗?
例如:我想开起1~10开关  关闭5开关 变数1~10代入1 变数5+1
$game_switches[1]=true
$game_switches[2]=true
                :
$game_switches[10]=true
$game_switches[5]=false

$game_variables[1]=1
$game_variables[2]=1
               :
$game_variables[10]=1
$game_variables[5]=+1
只能一个一个写吗?
我知道有批量控制的选项,但我有用破限脚本,超过5000个就没法子用。
$game_switches[1..10]=true  <===貌似错误?只有开关1开启其他无效?
$game_switches[1,2,3,4,6,7,8,9,10]=true  <==还是错误?
那么,除了一个一个设定开关与变数外,有批量的脚本可以解吗?
作者: 三途亚梦    时间: 2015-2-27 16:33
本帖最后由 三途亚梦 于 2015-2-27 16:44 编辑

写一个循环……
  1. (1..10).each do {|i|  $game_switches[i] = true}
复制代码
类似这样。
作者: howhow1314    时间: 2015-2-27 16:41
RUBY 代码复制
  1. for i in 1..10
  2. $game_switches[i] = true
  3. end
這樣
作者: 喵呜喵5    时间: 2015-2-27 16:50
插入下面的脚本,
  1. class Game_Variables
  2.   alias m5_20150227_set []=
  3.   def []=(variable_id, value)
  4.     if variable_id.is_a?(Range)
  5.       variable_id.each{ |v| m5_20150227_set(v,value) }
  6.     else
  7.       m5_20150227_set(variable_id,value)
  8.     end   
  9.   end
  10. end
  11. class Game_Switches
  12.   alias m5_20150227_set []=
  13.   def []=(switch_id, value)
  14.     if switch_id.is_a?(Range)
  15.       switch_id.each{ |s| m5_20150227_set(s,value) }
  16.     else
  17.       m5_20150227_set(switch_id,value)
  18.     end   
  19.   end
  20. end
复制代码
然后
$game_switches[1..10] = true
$game_variables[1..10] = 1




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