Project1
标题:
自制的金钱系统出现TypeError
[打印本页]
作者:
876加几
时间:
2013-10-13 15:15
标题:
自制的金钱系统出现TypeError
本帖最后由 876加几 于 2013-10-13 17:00 编辑
因为我觉得默认的金钱系统不公平:只有主角有钱,其他角色都是穷光蛋,所以自制了个公平的金钱系统。
但是让它公平吧,脚本又出问题了。
脚本:@Person
#==============================================================================
# ■ Game_Money
#------------------------------------------------------------------------------
# 处理金钱的类。本类的实例请参考$game_money。
#==============================================================================
class Game_Money
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :gold # 保存各角色金钱的数组
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
[url=home.php?mod=space&uid=236945]@gold[/url] = [500, 1000, 750, 10000]
end
end
复制代码
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# 显示菜单画面和同伴状态的窗口。
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目标
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480 - 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = 64
y = i * 116 + 64
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 20, y + 80)
draw_actor_name(actor, x + 44, y + 32)
self.contents.font.color = system_color
self.contents.draw_text(198 - 40, y + 64, 40, 32, $data_system.words.gold)
self.contents.font.color = normal_color
self.contents.draw_text(x + 44, y + 64, 32, 32, $game_money.gold[actor].to_s)
#draw_actor_class(actor, x + 150, y)
#draw_actor_level(actor, x + 44, y + 32)
#draw_actor_state(actor, x + 250, y)
#draw_actor_exp(actor, x + 44, y + 64)
#draw_actor_hp(actor, x + 185, y + 32)
#draw_actor_sp(actor, x + 185, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116 + 64, 198, 96)
refresh
x = 64 + 189
y = 64
actor = $game_party.actors[@index]
draw_actor_half(actor, x + 96, 480 - 300 - 64)
draw_actor_head(actor, x, y)
draw_actor_name(actor, x + 48, y)
draw_actor_class(actor, x + 148, y)
draw_actor_level_qq(actor, x, y + 32)
draw_actor_state(actor, x, y + 64)
draw_actor_exp(actor, x, y + 96)
draw_actor_hp(actor, x, y + 128)
draw_actor_sp(actor, x, y + 160)
draw_actor_mor(actor, x, y + 192)
draw_actor_fullname(actor, x, y + 200)
end
end
end
复制代码
只能管第2个脚本的30~33行,其它是没有问题的。
报错文字:
脚本"Window_MenuStatus"的第31行出现了TypeError:
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