Project1

标题: 自制的金钱系统出现TypeError [打印本页]

作者: 876加几    时间: 2013-10-13 15:15
标题: 自制的金钱系统出现TypeError
本帖最后由 876加几 于 2013-10-13 17:00 编辑

因为我觉得默认的金钱系统不公平:只有主角有钱,其他角色都是穷光蛋,所以自制了个公平的金钱系统。
但是让它公平吧,脚本又出问题了。
脚本:@Person
  1. #==============================================================================
  2. # ■ Game_Money
  3. #------------------------------------------------------------------------------
  4. #  处理金钱的类。本类的实例请参考$game_money。
  5. #==============================================================================
  6. class Game_Money
  7.   #--------------------------------------------------------------------------
  8.   # ● 定义实例变量
  9.   #--------------------------------------------------------------------------
  10.   attr_accessor :gold # 保存各角色金钱的数组
  11.   #--------------------------------------------------------------------------
  12.   # ● 初始化对像
  13.   #--------------------------------------------------------------------------
  14.   def initialize
  15.     [url=home.php?mod=space&uid=236945]@gold[/url] = [500, 1000, 750, 10000]
  16.   end
  17. end
复制代码
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #------------------------------------------------------------------------------
  4. #  显示菜单画面和同伴状态的窗口。
  5. #==============================================================================

  6. class Window_MenuStatus < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化目标
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 640, 480 - 64)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     refresh
  14.     self.active = false
  15.     self.index = -1
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 刷新
  19.   #--------------------------------------------------------------------------
  20.   def refresh
  21.     self.contents.clear
  22.     @item_max = $game_party.actors.size
  23.     for i in 0...$game_party.actors.size
  24.       x = 64
  25.       y = i * 116 + 64
  26.       actor = $game_party.actors[i]
  27.       draw_actor_graphic(actor, x - 20, y + 80)
  28.       draw_actor_name(actor, x + 44, y + 32)
  29.       self.contents.font.color = system_color
  30.       self.contents.draw_text(198 - 40, y + 64, 40, 32, $data_system.words.gold)
  31.       self.contents.font.color = normal_color
  32.       self.contents.draw_text(x + 44, y + 64, 32, 32, $game_money.gold[actor].to_s)
  33.       #draw_actor_class(actor, x + 150, y)
  34.       #draw_actor_level(actor, x + 44, y + 32)
  35.       #draw_actor_state(actor, x + 250, y)
  36.       #draw_actor_exp(actor, x + 44, y + 64)
  37.       #draw_actor_hp(actor, x + 185, y + 32)
  38.       #draw_actor_sp(actor, x + 185, y + 64)
  39.     end
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # ● 刷新光标矩形
  43.   #--------------------------------------------------------------------------
  44.   def update_cursor_rect
  45.     if @index < 0
  46.       self.cursor_rect.empty
  47.     else
  48.       self.cursor_rect.set(0, @index * 116 + 64, 198, 96)
  49.       refresh
  50.       x = 64 + 189
  51.       y = 64
  52.       actor = $game_party.actors[@index]
  53.       draw_actor_half(actor, x + 96, 480 - 300 - 64)
  54.       draw_actor_head(actor, x, y)
  55.       draw_actor_name(actor, x + 48, y)
  56.       draw_actor_class(actor, x + 148, y)
  57.       draw_actor_level_qq(actor, x, y + 32)
  58.       draw_actor_state(actor, x, y + 64)
  59.       draw_actor_exp(actor, x, y + 96)
  60.       draw_actor_hp(actor, x, y + 128)
  61.       draw_actor_sp(actor, x, y + 160)
  62.       draw_actor_mor(actor, x, y + 192)
  63.       draw_actor_fullname(actor, x, y + 200)
  64.     end
  65.   end
  66. end
复制代码
只能管第2个脚本的30~33行,其它是没有问题的。
报错文字:
  1. 脚本"Window_MenuStatus"的第31行出现了TypeError:
  2. cannot convert Game_Actor into integer
复制代码
  
作者: 恐惧剑刃    时间: 2013-10-13 15:54
本帖最后由 恋′挂机 于 2013-10-13 16:05 编辑

那个金钱不是某一角色的!!!你对这个问题有曲解。
年纪不大能理解成这样还算不错了。

在Game_Actor
定义实例变量里加上
attr_accessor :gold
再初始化
@gold = 100

就这么简单而已,
具体方法:

# 查看角色的金钱
$game_actors[1].gold
# 金钱+
$game_actors[1].gold += 500
   

你脚本传的参数很有问题!!!!!!!
怎么把角色传过去了?
作者: 晴兰    时间: 2013-10-14 03:58
提示: 作者被禁止或删除 内容自动屏蔽




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