Project1

标题: 在脚本内修改全局变量$game_variables[] [打印本页]

作者: D_Lohy    时间: 2022-6-1 13:18
标题: 在脚本内修改全局变量$game_variables[]
如题,$game_variables[207] = 1 会报错()
怎么在脚本内修改Rpgmaker自带的全局变量$game_variables[](
作者: alexncf125    时间: 2022-6-1 13:26
$game_variables[207] = 1 会报啥错啊???
作者: D_Lohy    时间: 2022-6-1 13:29
alexncf125 发表于 2022-6-1 13:26
$game_variables[207] = 1 会报啥错啊???

我不到啊(恼哎)
作者: D_Lohy    时间: 2022-6-1 13:48
file:///C:/Users/Administrator/Pictures/贴图们/234捕获.PNG现在是不报错了,但是F9看了一下,变量没有发生变化
作者: D_Lohy    时间: 2022-6-1 13:54

  1. file1 = File.file?("text.txt")
  2. if file1 == false
  3.   a=0
  4.   begin
  5.     DAD = message_box("::错误::\r::没有找到核心文件::", "死亡性错误!", BUTTONS_ABORTRETRYIGNORE)
  6.     if DAD == 3
  7.       exit()
  8.     end
  9.     if DAD == 4
  10.       $game_variables[207] = 1
  11.       a-=1
  12.     end
  13.   end while a>0
  14. end
复制代码

作者: alexncf125    时间: 2022-6-1 14:08
本帖最后由 alexncf125 于 2022-6-1 14:24 编辑
D_Lohy 发表于 2022-6-1 13:54


变量没有发生变化, 你看看DAD是不是等于4
作者: D_Lohy    时间: 2022-6-1 14:33
alexncf125 发表于 2022-6-1 14:08
变量没有发生变化, 你看看DAD是不是等于4

哦哦哦还真是,DAD为5,我直接面壁思过,while也写错了
作者: D_Lohy    时间: 2022-6-1 17:17

嗨嗨,还是报错
RUBY 代码复制
  1. a=1
  2. begin
  3.   file1 = File.file?("Aoorlin.crter")
  4.   if file1 == false
  5.     DAD = er_ge2()
  6.     case DAD
  7.     when 3
  8.       exit()
  9.     when 5
  10.       $game_variables[207] = 1
  11.       a=0
  12.     end
  13.   else
  14.     a=0
  15.   end
  16. end while a==1

作者: alexncf125    时间: 2022-6-1 17:25
D_Lohy 发表于 2022-6-1 17:17
嗨嗨,还是报错
a=1
begin

所以你这是什么时机执行的$game_variables[207] = 1
是经已进到游戏里了吗?
作者: D_Lohy    时间: 2022-6-1 17:31
alexncf125 发表于 2022-6-1 17:25
所以你这是什么时机执行的$game_variables[207] = 1
是经已进到游戏里了吗?

刚开始,这些脚本是填在编辑器里面的()

就是这里(图上)

作者: alexncf125    时间: 2022-6-1 17:56
D_Lohy 发表于 2022-6-1 17:31
刚开始,这些脚本是填在编辑器里面的()

就是这里(图上)

  1. module DataManager
  2.   class << self
  3.     alias :init_create_game_objects :create_game_objects
  4.   end
  5.   def self.create_game_objects
  6.     init_create_game_objects
  7.     p "已初始化$game_variables"
  8.   end
  9. end
复制代码

你看看你初始化了$game_variables没有?
作者: D_Lohy    时间: 2022-6-2 18:29
D_Lohy 发表于 2022-6-1 17:31
刚开始,这些脚本是填在编辑器里面的()

就是这里(图上)

写在事件里就没问题了()
作者: D_Lohy    时间: 2022-6-3 02:03
D_Lohy 发表于 2022-6-1 17:31
刚开始,这些脚本是填在编辑器里面的()

就是这里(图上)

写在事件里就没问题了(





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