Project1

标题: 修改脚本后错误.... [打印本页]

作者: 光之ZERO    时间: 2009-2-7 05:49
提示: 作者被禁止或删除 内容自动屏蔽
作者: 「旅」    时间: 2009-2-7 06:04
TypeError
若使用了错误的类型时,就会引发该异常。

if $shuru =="marths"
CHARACTER_TABLE =
["1","2","3","4","5",
   "5","7","8","9","0",]
数组过短
for i in 0..179
作者: 光之ZERO    时间: 2009-2-7 06:20
提示: 作者被禁止或删除 内容自动屏蔽
作者: 「旅」    时间: 2009-2-7 06:24
其实可以加个if在for i in 0..179那里。然后else改为for i in 0..9
作者: 光之ZERO    时间: 2009-2-7 06:25
提示: 作者被禁止或删除 内容自动屏蔽
作者: 光之ZERO    时间: 2009-2-7 06:33
提示: 作者被禁止或删除 内容自动屏蔽
作者: 「旅」    时间: 2009-2-7 06:39
以下引用光之ZERO于2009-2-6 22:33:01的发言:

def refresh
   self.contents.clear
   if $shuru =="marths"
     for i in 0..9
       x = 4 + i / 5 / 9 * 152 + i % 5 * 28
       y = i / 5 % 9 * 32
       self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE, 1)
     end
   else
     for i in 0..179
      x = 4 + i / 5 / 9 * 152 + i % 5 * 28
      y = i / 5 % 9 * 32
      self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE, 1)
     end
   end
   self.contents.draw_text(544, 9 * 32, 64, 32, "确定", 1)
end


作者: 光之ZERO    时间: 2009-2-7 06:44
提示: 作者被禁止或删除 内容自动屏蔽
作者: asperta    时间: 2009-2-7 06:54
你可以把 脚本第12行那句
elsif $shuru =="japanese"
改为
else 试试,还报错吗?
作者: 光之ZERO    时间: 2009-2-7 06:56
提示: 作者被禁止或删除 内容自动屏蔽
作者: 「旅」    时间: 2009-2-7 07:01
实验证明事实= =
  1. #==============================================================================
  2. # ■ Window_NameInput
  3. #------------------------------------------------------------------------------
  4. #  输入名称的画面、文字选择窗口。
  5. #==============================================================================

  6. class Window_NameInput < Window_Base
  7.   $shuru ="marths"#——初始化,测试用
  8. if $shuru =="marths"
  9. CHARACTER_TABLE =
  10. ["1","2","3","4","5",
  11.    "5","7","8","9","0",]
  12. elsif $shuru =="japanese"
  13.   CHARACTER_TABLE =
  14. [    "あ","い","う","え","お",
  15.    "か","き","く","け","こ",
  16.    "さ","し","す","せ","そ",
  17.    "た","ち","つ","て","と",
  18.    "な","に","ぬ","ね","の",
  19.    "は","ひ","ふ","へ","ほ",
  20.    "ま","み","む","め","も",
  21.    "や", "" ,"ゆ", "" ,"よ",
  22.    "ら","り","る","れ","ろ",
  23.    "わ", "" ,"を", "" ,"ん",
  24.    "が","ぎ","ぐ","げ","ご",
  25.    "ざ","じ","ず","ぜ","ぞ",
  26.    "だ","ぢ","づ","で","ど",
  27.    "ば","び","ぶ","べ","ぼ",
  28.    "ぱ","ぴ","ぷ","ぺ","ぽ",
  29.    "ゃ","ゅ","ょ","っ","ゎ",
  30.    "ぁ","ぃ","ぅ","ぇ","ぉ",
  31.    "ー","・", "" , "" , "" ,
  32.    "ア","イ","ウ","エ","オ",
  33.    "カ","キ","ク","ケ","コ",
  34.    "サ","シ","ス","セ","ソ",
  35.    "タ","チ","ツ","テ","ト",
  36.    "ナ","ニ","ヌ","ネ","ノ",
  37.    "ハ","ヒ","フ","ヘ","ホ",
  38.    "マ","ミ","ム","メ","モ",
  39.    "ヤ", "" ,"ユ", "" ,"ヨ",
  40.    "ラ","リ","ル","レ","ロ",
  41.    "ワ", "" ,"ヲ", "" ,"ン",
  42.    "ガ","ギ","グ","ゲ","ゴ",
  43.    "ザ","ジ","ズ","ゼ","ゾ",
  44.    "ダ","ヂ","ヅ","デ","ド",
  45.    "バ","ビ","ブ","ベ","ボ",
  46.    "パ","ピ","プ","ペ","ポ",
  47.    "ャ","ュ","ョ","ッ","ヮ",
  48.    "ァ","ィ","ゥ","ェ","ォ",
  49.    "ー","・","ヴ", "" , "" ,
  50.    ]
  51.    end
  52. #--------------------------------------------------------------------------
  53. # ● 初始化对像
  54. #--------------------------------------------------------------------------
  55. def initialize
  56.    super(0, 128, 640, 352)
  57.    self.contents = Bitmap.new(width - 32, height - 32)
  58.    @index = 0
  59.    refresh
  60.    update_cursor_rect
  61. end
  62. #--------------------------------------------------------------------------
  63. # ● 获取文字
  64. #--------------------------------------------------------------------------
  65. def character
  66.    return CHARACTER_TABLE[@index]
  67. end
  68. #--------------------------------------------------------------------------
  69. # ● 刷新
  70. #--------------------------------------------------------------------------
  71. def refresh
  72. self.contents.clear
  73. if $shuru =="marths"
  74.    for i in 0..9
  75.      x = 4 + i / 5 / 9 * 152 + i % 5 * 28
  76.      y = i / 5 % 9 * 32
  77.      self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
  78.    end
  79. else
  80.    for i in 0..179
  81.     x = 4 + i / 5 / 9 * 152 + i % 5 * 28
  82.     y = i / 5 % 9 * 32
  83.     self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
  84.    end
  85. end
  86. self.contents.draw_text(544, 9 * 32, 64, 32, "确定", 1)
  87. end
  88. #--------------------------------------------------------------------------
  89. # ● 刷新光标矩形
  90. #--------------------------------------------------------------------------
  91. def update_cursor_rect
  92.    # 光标位置在 [确定] 的情况下
  93.    if @index >= 180
  94.      self.cursor_rect.set(544, 9 * 32, 64, 32)
  95.    # 光标位置在 [确定] 以外的情况下
  96.    else
  97.      x = 4 + @index / 5 / 9 * 152 + @index % 5 * 28
  98.      y = @index / 5 % 9 * 32
  99.      self.cursor_rect.set(x, y, 28, 32)
  100.    end
  101. end
  102. #--------------------------------------------------------------------------
  103. # ● 刷新画面
  104. #--------------------------------------------------------------------------
  105. def update
  106.    super
  107.    # 光标位置在 [确定] 的情况下
  108.    if @index >= 180
  109.      # 光标下
  110.      if Input.trigger?(Input::DOWN)
  111.        $game_system.se_play($data_system.cursor_se)
  112.        @index -= 180
  113.      end
  114.      # 光标上
  115.      if Input.repeat?(Input::UP)
  116.        $game_system.se_play($data_system.cursor_se)
  117.        @index -= 180 - 40
  118.      end
  119.    # 光标位置在 [确定] 以外的情况下
  120.    else
  121.      # 按下方向键右的情况下
  122.      if Input.repeat?(Input::RIGHT)
  123.        # 按下状态不是重复的情况下、
  124.        # 光标位置不在右端的情况下
  125.        if Input.trigger?(Input::RIGHT) or
  126.           @index / 45 < 3 or @index % 5 < 4
  127.          # 光标向右移动
  128.          $game_system.se_play($data_system.cursor_se)
  129.          if @index % 5 < 4
  130.            @index += 1
  131.          else
  132.            @index += 45 - 4
  133.          end
  134.          if @index >= 180
  135.            @index -= 180
  136.          end
  137.        end
  138.      end
  139.      # 按下方向键左的情况下
  140.      if Input.repeat?(Input::LEFT)
  141.        # 按下状态不是重复的情况下、
  142.        # 光标位置不在左端的情况下
  143.        if Input.trigger?(Input::LEFT) or
  144.           @index / 45 > 0 or @index % 5 > 0
  145.          # 光标向右移动
  146.          $game_system.se_play($data_system.cursor_se)
  147.          if @index % 5 > 0
  148.            @index -= 1
  149.          else
  150.            @index -= 45 - 4
  151.          end
  152.          if @index < 0
  153.            @index += 180
  154.          end
  155.        end
  156.      end
  157.      # 按下方向键下的情况下
  158.      if Input.repeat?(Input::DOWN)
  159.        # 光标向下移动
  160.        $game_system.se_play($data_system.cursor_se)
  161.        if @index % 45 < 40
  162.          @index += 5
  163.        else
  164.          @index += 180 - 40
  165.        end
  166.      end
  167.      # 按下方向键上的情况下
  168.      if Input.repeat?(Input::UP)
  169.        # 按下状态不是重复的情况下、
  170.        # 光标位置不在上端的情况下
  171.        if Input.trigger?(Input::UP) or @index % 45 >= 5
  172.          # 光标向上移动
  173.          $game_system.se_play($data_system.cursor_se)
  174.          if @index % 45 >= 5
  175.            @index -= 5
  176.          else
  177.            @index += 180
  178.          end
  179.        end
  180.      end
  181.      # L 键与 R 键被按下的情况下
  182.      if Input.repeat?(Input::L) or Input.repeat?(Input::R)
  183.        # 平假名 / 片假名 之间移动
  184.        $game_system.se_play($data_system.cursor_se)
  185.        if @index / 45 < 2
  186.          @index += 90
  187.        else
  188.          @index -= 90
  189.        end
  190.      end
  191.    end
  192.    update_cursor_rect
  193. end
  194. end
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
作者: 光之ZERO    时间: 2009-2-7 07:11
提示: 作者被禁止或删除 内容自动屏蔽
作者: asperta    时间: 2009-2-7 07:12
  1. #==============================================================================
  2. # ■ Window_NameInput
  3. #------------------------------------------------------------------------------
  4. #  输入名称的画面、文字选择窗口。
  5. #==============================================================================

  6. class Window_NameInput < Window_Base
  7. CHARACTER_ASPERTA =
  8. ["1","2","3","4","5",
  9.    "5","7","8","9","0",]
  10.   CHARACTER_TABLE =
  11. [    "あ","い","う","え","お",
  12.    "か","き","く","け","こ",
  13.    "さ","し","す","せ","そ",
  14.    "た","ち","つ","て","と",
  15.    "な","に","ぬ","ね","の",
  16.    "は","ひ","ふ","へ","ほ",
  17.    "ま","み","む","め","も",
  18.    "や", "" ,"ゆ", "" ,"よ",
  19.    "ら","り","る","れ","ろ",
  20.    "わ", "" ,"を", "" ,"ん",
  21.    "が","ぎ","ぐ","げ","ご",
  22.    "ざ","じ","ず","ぜ","ぞ",
  23.    "だ","ぢ","づ","で","ど",
  24.    "ば","び","ぶ","べ","ぼ",
  25.    "ぱ","ぴ","ぷ","ぺ","ぽ",
  26.    "ゃ","ゅ","ょ","っ","ゎ",
  27.    "ぁ","ぃ","ぅ","ぇ","ぉ",
  28.    "ー","・", "" , "" , "" ,
  29.    "ア","イ","ウ","エ","オ",
  30.    "カ","キ","ク","ケ","コ",
  31.    "サ","シ","ス","セ","ソ",
  32.    "タ","チ","ツ","テ","ト",
  33.    "ナ","ニ","ヌ","ネ","ノ",
  34.    "ハ","ヒ","フ","ヘ","ホ",
  35.    "マ","ミ","ム","メ","モ",
  36.    "ヤ", "" ,"ユ", "" ,"ヨ",
  37.    "ラ","リ","ル","レ","ロ",
  38.    "ワ", "" ,"ヲ", "" ,"ン",
  39.    "ガ","ギ","グ","ゲ","ゴ",
  40.    "ザ","ジ","ズ","ゼ","ゾ",
  41.    "ダ","ヂ","ヅ","デ","ド",
  42.    "バ","ビ","ブ","ベ","ボ",
  43.    "パ","ピ","プ","ペ","ポ",
  44.    "ャ","ュ","ョ","ッ","ヮ",
  45.    "ァ","ィ","ゥ","ェ","ォ",
  46.    "ー","・","ヴ", "" , "" ,
  47.    ]
  48. #--------------------------------------------------------------------------
  49. # ● 初始化对像
  50. #--------------------------------------------------------------------------
  51. def initialize
  52.    super(0, 128, 640, 352)
  53.    self.contents = Bitmap.new(width - 32, height - 32)
  54.    @index = 0
  55.    refresh
  56.    update_cursor_rect
  57. end
  58. #--------------------------------------------------------------------------
  59. # ● 获取文字
  60. #--------------------------------------------------------------------------
  61. def character
  62.    if $shuru =="marths"
  63.      return CHARACTER_ASPERTA[@index]
  64.    else
  65.      return CHARACTER_TABLE[@index]
  66.    end  
  67. end
  68. #--------------------------------------------------------------------------
  69. # ● 刷新
  70. #--------------------------------------------------------------------------
  71. def refresh
  72. self.contents.clear
  73. if $shuru =="marths"
  74.    for i in 0..9
  75.      x = 4 + i / 5 / 9 * 152 + i % 5 * 28
  76.      y = i / 5 % 9 * 32
  77.      self.contents.draw_text(x, y, 28, 32, CHARACTER_ASPERTA[i], 1)
  78.    end
  79. else
  80.    for i in 0..179
  81.     x = 4 + i / 5 / 9 * 152 + i % 5 * 28
  82.     y = i / 5 % 9 * 32
  83.     self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
  84.    end
  85. end
  86. self.contents.draw_text(544, 9 * 32, 64, 32, "确定", 1)
  87. end
  88. #--------------------------------------------------------------------------
  89. # ● 刷新光标矩形
  90. #--------------------------------------------------------------------------
  91. def update_cursor_rect
  92.    # 光标位置在 [确定] 的情况下
  93.    if @index >= 180
  94.      self.cursor_rect.set(544, 9 * 32, 64, 32)
  95.    # 光标位置在 [确定] 以外的情况下
  96.    else
  97.      x = 4 + @index / 5 / 9 * 152 + @index % 5 * 28
  98.      y = @index / 5 % 9 * 32
  99.      self.cursor_rect.set(x, y, 28, 32)
  100.    end
  101. end
  102. #--------------------------------------------------------------------------
  103. # ● 刷新画面
  104. #--------------------------------------------------------------------------
  105. def update
  106.    super
  107.    # 光标位置在 [确定] 的情况下
  108.    if @index >= 180
  109.      # 光标下
  110.      if Input.trigger?(Input::DOWN)
  111.        $game_system.se_play($data_system.cursor_se)
  112.        @index -= 180
  113.      end
  114.      # 光标上
  115.      if Input.repeat?(Input::UP)
  116.        $game_system.se_play($data_system.cursor_se)
  117.        @index -= 180 - 40
  118.      end
  119.    # 光标位置在 [确定] 以外的情况下
  120.    else
  121.      # 按下方向键右的情况下
  122.      if Input.repeat?(Input::RIGHT)
  123.        # 按下状态不是重复的情况下、
  124.        # 光标位置不在右端的情况下
  125.        if Input.trigger?(Input::RIGHT) or
  126.           @index / 45 < 3 or @index % 5 < 4
  127.          # 光标向右移动
  128.          $game_system.se_play($data_system.cursor_se)
  129.          if @index % 5 < 4
  130.            @index += 1
  131.          else
  132.            @index += 45 - 4
  133.          end
  134.          if @index >= 180
  135.            @index -= 180
  136.          end
  137.        end
  138.      end
  139.      # 按下方向键左的情况下
  140.      if Input.repeat?(Input::LEFT)
  141.        # 按下状态不是重复的情况下、
  142.        # 光标位置不在左端的情况下
  143.        if Input.trigger?(Input::LEFT) or
  144.           @index / 45 > 0 or @index % 5 > 0
  145.          # 光标向右移动
  146.          $game_system.se_play($data_system.cursor_se)
  147.          if @index % 5 > 0
  148.            @index -= 1
  149.          else
  150.            @index -= 45 - 4
  151.          end
  152.          if @index < 0
  153.            @index += 180
  154.          end
  155.        end
  156.      end
  157.      # 按下方向键下的情况下
  158.      if Input.repeat?(Input::DOWN)
  159.        # 光标向下移动
  160.        $game_system.se_play($data_system.cursor_se)
  161.        if @index % 45 < 40
  162.          @index += 5
  163.        else
  164.          @index += 180 - 40
  165.        end
  166.      end
  167.      # 按下方向键上的情况下
  168.      if Input.repeat?(Input::UP)
  169.        # 按下状态不是重复的情况下、
  170.        # 光标位置不在上端的情况下
  171.        if Input.trigger?(Input::UP) or @index % 45 >= 5
  172.          # 光标向上移动
  173.          $game_system.se_play($data_system.cursor_se)
  174.          if @index % 45 >= 5
  175.            @index -= 5
  176.          else
  177.            @index += 180
  178.          end
  179.        end
  180.      end
  181.      # L 键与 R 键被按下的情况下
  182.      if Input.repeat?(Input::L) or Input.repeat?(Input::R)
  183.        # 平假名 / 片假名 之间移动
  184.        $game_system.se_play($data_system.cursor_se)
  185.        if @index / 45 < 2
  186.          @index += 90
  187.        else
  188.          @index -= 90
  189.        end
  190.      end
  191.    end
  192.    update_cursor_rect
  193. end
  194. end
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
作者: 「旅」    时间: 2009-2-7 07:14
那么直接把CHARACTER_TABLE改为CHARACTER_TABLE1、CHARACTER_TABLE2
然后在描绘中的if内部替换掉不就好了。
[LINE]2,#dddddd[/LINE]
楼上是正解。
作者: 光之ZERO    时间: 2009-2-7 07:17
提示: 作者被禁止或删除 内容自动屏蔽
作者: 「旅」    时间: 2009-2-7 07:20
因为开头是一个代入。然而改了变量$shuru后这个常量CHARACTER_TABLE没发生变化,所以发生了错误。
作者: 光之ZERO    时间: 2009-2-7 07:22
提示: 作者被禁止或删除 内容自动屏蔽




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