设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3460|回复: 24
打印 上一主题 下一主题

脚本中的变量?

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
跳转到指定楼层
1
发表于 2007-7-11 22:02:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
我用以下脚本,它可以显示人物的年龄,身高体重等,然而我想它显示的是一个变量,
例如,我想身高显示的是12号变量,开始游戏时可以输入,游戏中会随着年龄的增长而增长.
该怎么做?

  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # 人物介绍     Ver. 1.1          作者: Claimh     翻译与修正:柳柳
  5. #------------------------------------------------------------------------------
  6. # http://www.k3.dion.ne.jp/~claimh/
  7. #==============================================================================
  8.   
  9.   #——功能简介:在状态页面按下回车键会进入人物介绍页面。
  10.   #——如果想自行建立功能,使用$scene = Scene_Charactor(角色编号).new即可
  11.   #——如果自行建立了功能不想使用默认的切换,去掉217行以后的内容
  12.   
  13.   #——以下数组,如果人物超过8人,请自行继续添加(一般游戏没那么多主人公吧)
  14.   #——如果想更改内容,比如把“体重”改为“智商”,请修改102-107行的文字内容
  15.   
  16.   # 从状态页面切换至人物介绍页面的按键
  17.   CHENGE_KEY = Input::C
  18.   #--------------------------------------------------------------------------
  19.   # 人物年龄 (自定义)
  20.   #--------------------------------------------------------------------------
  21.   CHARA_AGE = ["17","23","15","18","16","17","19","","","","","",""]
  22.   #--------------------------------------------------------------------------
  23.   # 人物出生地
  24.   #--------------------------------------------------------------------------
  25.   CHARA_FROM = ["","","","","","","",
  26.   "","","","",]
  27.   #--------------------------------------------------------------------------
  28.   # 人物身高
  29.   #--------------------------------------------------------------------------
  30.   CHARA_H = ["174","178","159","165","160","162","167","","","",
  31.   "","","",]
  32.   #--------------------------------------------------------------------------
  33.   # 人物体重
  34.   #--------------------------------------------------------------------------
  35.   CHARA_W = ["58","68","44","51","47","49","53","53","68","44","47",]
  36.   #--------------------------------------------------------------------------
  37.   # 人物介绍,可以写多行
  38.   #--------------------------------------------------------------------------
  39.   # 人物1号介绍
  40.   L1 = ""
  41.   L2 = ""
  42.   L3 = ""               
  43.   L_SET1 = [L1, L2, L3]  # 人物1号的数组
  44.   # 人物2号介绍
  45.   L1 = ""
  46.   L2 = ""
  47.   L3 = ""
  48.   L_SET2 = [L1, L2, L3]  # 人物2号的数组
  49.   # 人物3号介绍
  50.   L1 = ""
  51.   L2 = ""
  52.   L3 = ""
  53.   L_SET3 = [L1, L2, L3]
  54.   # 人物4号介绍
  55.   L1 = ""
  56.   L2 = ""
  57.   L3 = ""
  58.   L_SET4 = [L1, L2, L3]
  59.   # 人物5号介绍
  60.   L1 = ""
  61.   L2 = ""
  62.   L3 = ""
  63.   L_SET5 = [L1, L2, L3]
  64.   # 人物6号介绍
  65.   L1 = ""
  66.   L2 = ""
  67.   L3 = ""
  68.   L_SET6 = [L1, L2, L3]
  69.   # 人物7号介绍
  70.   L1 = ""
  71.   L2 = ""
  72.   L3 = ""
  73.   L4 = ""
  74.   L_SET7 = [L1, L2, L3, L4]
  75.   # 人物8号介绍
  76.   L1 = ""
  77.   L2 = ""
  78.   L3 = ""
  79.   L_SET8 = [L1, L2, L3]
  80.   # 人物9号介绍
  81.   L1 = ""
  82.   L2 = ""
  83.   L3 = ""
  84.   L_SET9 = [L1, L2, L3]
  85.   # 人物10号介绍
  86.   L1 = ""
  87.   L2 = ""
  88.   L3 = ""
  89.   L_SET10 = [L1, L2, L3]
  90.   # 人物11号介绍
  91.   L1 = ""
  92.   L2 = ""
  93.   L3 = ""
  94.   L_SET11 = [L1, L2, L3]

  95.   # 人物介绍数组,如果不够继续添加。
  96.   CHARA_INFO = [L_SET1,L_SET2,L_SET3,L_SET4,L_SET5,L_SET6,L_SET7,L_SET8,L_SET9,
  97.   L_SET10,L_SET11]


  98. #==============================================================================
  99. # Window_Charactor
  100. #==============================================================================

  101. class Window_Charactor < Window_Base
  102.   #--------------------------------------------------------------------------
  103.   # actor : 初始化的角色
  104.   #--------------------------------------------------------------------------
  105.   def initialize(actor)
  106.     super(0, 0, 640, 480)
  107.     self.contents = Bitmap.new(width - 32, height - 32)
  108.     @actor = actor
  109.     refresh
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   #--------------------------------------------------------------------------
  113.   def refresh
  114.     self.contents.clear
  115.     draw_battler_graphics(@actor, 100, 250)
  116.     self.contents.font.color.set(255, 255,50)
  117.     self.contents.draw_text(250, 10, 80, 32, "姓名")
  118.     self.contents.draw_text(250, 50, 80, 32, "年龄")
  119.     self.contents.draw_text(250, 90, 80, 32, "IQ")
  120.     self.contents.draw_text(250, 130, 80, 32, "身高")
  121.     self.contents.draw_text(250, 170, 80, 32, "体重")
  122.     self.contents.font.color = normal_color
  123.     draw_actor_name(@actor, 350, 10)
  124.     draw_actor_age(@actor, 350, 50)
  125.     draw_actor_from(@actor, 350, 90)
  126.     draw_actor_height(@actor, 350, 130)   
  127.     draw_actor_weight(@actor, 350, 170)
  128.     draw_actor_other(@actor, 50, 250)
  129.   end
  130. end

  131. class Window_Base < Window
  132.   #--------------------------------------------------------------------------
  133.   #--------------------------------------------------------------------------
  134.   def draw_battler_graphics(actor, x, y)
  135.     battler=RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  136.     w = battler.width
  137.     h = battler.height
  138.     self.contents.blt(x-w/2, y-h, battler, Rect.new(0, 0, w,h))
  139.   end

  140.   #--------------------------------------------------------------------------
  141.   #--------------------------------------------------------------------------
  142.   def draw_actor_age(actor, x, y)
  143.     self.contents.draw_text(x, y, 80, 32, CHARA_AGE[actor.id-1])
  144.   end

  145.   #--------------------------------------------------------------------------
  146.   #--------------------------------------------------------------------------
  147.   def draw_actor_from(actor, x, y)
  148.     self.contents.draw_text(x, y, 180, 32, CHARA_FROM[actor.id-1])
  149.   end

  150.   #--------------------------------------------------------------------------
  151.   #--------------------------------------------------------------------------
  152.   def draw_actor_height(actor, x, y)
  153.     self.contents.draw_text(x, y , 200, 32, CHARA_H[actor.id-1])
  154.   end

  155.   #--------------------------------------------------------------------------
  156.   #--------------------------------------------------------------------------
  157.   def draw_actor_weight(actor, x, y)
  158.     self.contents.draw_text(x, y, 250, 32, CHARA_W[actor.id-1])
  159.   end

  160.   #--------------------------------------------------------------------------
  161.   #--------------------------------------------------------------------------
  162.   def draw_actor_other(actor, x, y)
  163.     info = CHARA_INFO[actor.id-1]
  164.     for i in 0...info.size
  165.       self.contents.draw_text(x, y+32*i, 600, 32, info[i])
  166.     end
  167.   end
  168. end


  169. #==============================================================================
  170. # Scene_Charactor
  171. #==============================================================================

  172. class Scene_Charactor
  173.   #--------------------------------------------------------------------------
  174.   #   actor_index :角色编号
  175.   #--------------------------------------------------------------------------
  176.   def initialize(actor_index = 0, equip_index = 0)
  177.     @actor_index = actor_index
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   #--------------------------------------------------------------------------
  181.   def main
  182.     @actor = $game_party.actors[@actor_index]
  183.     @status_window = Window_Charactor.new(@actor)
  184.     Graphics.transition
  185.     loop do
  186.       Graphics.update
  187.       Input.update
  188.       update
  189.       if $scene != self
  190.         break
  191.       end
  192.     end
  193.     Graphics.freeze
  194.     @status_window.dispose
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   #--------------------------------------------------------------------------
  198.   def update
  199.     if Input.trigger?(Input::B)
  200.       $game_system.se_play($data_system.cancel_se)
  201.       $scene = Scene_Menu.new(8)
  202.       return
  203.     end
  204.     if Input.trigger?(Input::R)
  205.       $game_system.se_play($data_system.cursor_se)
  206.       @actor_index += 1
  207.       @actor_index %= $game_party.actors.size
  208.       $scene = Scene_Charactor.new(@actor_index)
  209.       return
  210.     end
  211.     if Input.trigger?(Input::L)
  212.       $game_system.se_play($data_system.cursor_se)
  213.       @actor_index += $game_party.actors.size - 1
  214.       @actor_index %= $game_party.actors.size
  215.       $scene = Scene_Charactor.new(@actor_index)
  216.       return
  217.     end
  218.   end
  219. end


  220. #==============================================================================
  221. # Scene_Status
  222. #==============================================================================

  223. class Scene_Status
  224.   alias update_chara update
  225.   def update
  226.     if Input.trigger?(CHENGE_KEY)
  227.       $game_system.se_play($data_system.decision_se)
  228.       $scene = Scene_Charactor.new(@actor_index)
  229.       return
  230.     end
  231.     update_chara
  232.   end
  233. end
复制代码


版务信息:本贴由楼主自主结贴~

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
2
 楼主| 发表于 2007-7-11 22:02:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
我用以下脚本,它可以显示人物的年龄,身高体重等,然而我想它显示的是一个变量,
例如,我想身高显示的是12号变量,开始游戏时可以输入,游戏中会随着年龄的增长而增长.
该怎么做?

  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================


  4. # 人物介绍     Ver. 1.1          作者: Claimh     翻译与修正:柳柳
  5. #------------------------------------------------------------------------------
  6. # http://www.k3.dion.ne.jp/~claimh/
  7. #==============================================================================
  8.   
  9.   #——功能简介:在状态页面按下回车键会进入人物介绍页面。
  10.   #——如果想自行建立功能,使用$scene = Scene_Charactor(角色编号).new即可
  11.   #——如果自行建立了功能不想使用默认的切换,去掉217行以后的内容
  12.   
  13.   #——以下数组,如果人物超过8人,请自行继续添加(一般游戏没那么多主人公吧)
  14.   #——如果想更改内容,比如把“体重”改为“智商”,请修改102-107行的文字内容
  15.   
  16.   # 从状态页面切换至人物介绍页面的按键
  17.   CHENGE_KEY = Input::C
  18.   #--------------------------------------------------------------------------
  19.   # 人物年龄 (自定义)
  20.   #--------------------------------------------------------------------------
  21.   CHARA_AGE = ["17","23","15","18","16","17","19","","","","","",""]
  22.   #--------------------------------------------------------------------------
  23.   # 人物出生地
  24.   #--------------------------------------------------------------------------
  25.   CHARA_FROM = ["","","","","","","",
  26.   "","","","",]
  27.   #--------------------------------------------------------------------------
  28.   # 人物身高
  29.   #--------------------------------------------------------------------------
  30.   CHARA_H = ["174","178","159","165","160","162","167","","","",
  31.   "","","",]
  32.   #--------------------------------------------------------------------------
  33.   # 人物体重
  34.   #--------------------------------------------------------------------------
  35.   CHARA_W = ["58","68","44","51","47","49","53","53","68","44","47",]
  36.   #--------------------------------------------------------------------------
  37.   # 人物介绍,可以写多行
  38.   #--------------------------------------------------------------------------
  39.   # 人物1号介绍
  40.   L1 = ""
  41.   L2 = ""
  42.   L3 = ""               
  43.   L_SET1 = [L1, L2, L3]  # 人物1号的数组
  44.   # 人物2号介绍
  45.   L1 = ""
  46.   L2 = ""
  47.   L3 = ""
  48.   L_SET2 = [L1, L2, L3]  # 人物2号的数组
  49.   # 人物3号介绍
  50.   L1 = ""
  51.   L2 = ""
  52.   L3 = ""
  53.   L_SET3 = [L1, L2, L3]
  54.   # 人物4号介绍
  55.   L1 = ""
  56.   L2 = ""
  57.   L3 = ""
  58.   L_SET4 = [L1, L2, L3]
  59.   # 人物5号介绍
  60.   L1 = ""
  61.   L2 = ""
  62.   L3 = ""
  63.   L_SET5 = [L1, L2, L3]
  64.   # 人物6号介绍
  65.   L1 = ""
  66.   L2 = ""
  67.   L3 = ""
  68.   L_SET6 = [L1, L2, L3]
  69.   # 人物7号介绍
  70.   L1 = ""
  71.   L2 = ""
  72.   L3 = ""
  73.   L4 = ""
  74.   L_SET7 = [L1, L2, L3, L4]
  75.   # 人物8号介绍
  76.   L1 = ""
  77.   L2 = ""
  78.   L3 = ""
  79.   L_SET8 = [L1, L2, L3]
  80.   # 人物9号介绍
  81.   L1 = ""
  82.   L2 = ""
  83.   L3 = ""
  84.   L_SET9 = [L1, L2, L3]
  85.   # 人物10号介绍
  86.   L1 = ""
  87.   L2 = ""
  88.   L3 = ""
  89.   L_SET10 = [L1, L2, L3]
  90.   # 人物11号介绍
  91.   L1 = ""
  92.   L2 = ""
  93.   L3 = ""
  94.   L_SET11 = [L1, L2, L3]

  95.   # 人物介绍数组,如果不够继续添加。
  96.   CHARA_INFO = [L_SET1,L_SET2,L_SET3,L_SET4,L_SET5,L_SET6,L_SET7,L_SET8,L_SET9,
  97.   L_SET10,L_SET11]


  98. #==============================================================================
  99. # Window_Charactor
  100. #==============================================================================

  101. class Window_Charactor < Window_Base
  102.   #--------------------------------------------------------------------------
  103.   # actor : 初始化的角色
  104.   #--------------------------------------------------------------------------
  105.   def initialize(actor)
  106.     super(0, 0, 640, 480)
  107.     self.contents = Bitmap.new(width - 32, height - 32)
  108.     @actor = actor
  109.     refresh
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   #--------------------------------------------------------------------------
  113.   def refresh
  114.     self.contents.clear
  115.     draw_battler_graphics(@actor, 100, 250)
  116.     self.contents.font.color.set(255, 255,50)
  117.     self.contents.draw_text(250, 10, 80, 32, "姓名")
  118.     self.contents.draw_text(250, 50, 80, 32, "年龄")
  119.     self.contents.draw_text(250, 90, 80, 32, "IQ")
  120.     self.contents.draw_text(250, 130, 80, 32, "身高")
  121.     self.contents.draw_text(250, 170, 80, 32, "体重")
  122.     self.contents.font.color = normal_color
  123.     draw_actor_name(@actor, 350, 10)
  124.     draw_actor_age(@actor, 350, 50)
  125.     draw_actor_from(@actor, 350, 90)
  126.     draw_actor_height(@actor, 350, 130)   
  127.     draw_actor_weight(@actor, 350, 170)
  128.     draw_actor_other(@actor, 50, 250)
  129.   end
  130. end

  131. class Window_Base < Window
  132.   #--------------------------------------------------------------------------
  133.   #--------------------------------------------------------------------------
  134.   def draw_battler_graphics(actor, x, y)
  135.     battler=RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  136.     w = battler.width
  137.     h = battler.height
  138.     self.contents.blt(x-w/2, y-h, battler, Rect.new(0, 0, w,h))
  139.   end

  140.   #--------------------------------------------------------------------------
  141.   #--------------------------------------------------------------------------
  142.   def draw_actor_age(actor, x, y)
  143.     self.contents.draw_text(x, y, 80, 32, CHARA_AGE[actor.id-1])
  144.   end

  145.   #--------------------------------------------------------------------------
  146.   #--------------------------------------------------------------------------
  147.   def draw_actor_from(actor, x, y)
  148.     self.contents.draw_text(x, y, 180, 32, CHARA_FROM[actor.id-1])
  149.   end

  150.   #--------------------------------------------------------------------------
  151.   #--------------------------------------------------------------------------
  152.   def draw_actor_height(actor, x, y)
  153.     self.contents.draw_text(x, y , 200, 32, CHARA_H[actor.id-1])
  154.   end

  155.   #--------------------------------------------------------------------------
  156.   #--------------------------------------------------------------------------
  157.   def draw_actor_weight(actor, x, y)
  158.     self.contents.draw_text(x, y, 250, 32, CHARA_W[actor.id-1])
  159.   end

  160.   #--------------------------------------------------------------------------
  161.   #--------------------------------------------------------------------------
  162.   def draw_actor_other(actor, x, y)
  163.     info = CHARA_INFO[actor.id-1]
  164.     for i in 0...info.size
  165.       self.contents.draw_text(x, y+32*i, 600, 32, info[i])
  166.     end
  167.   end
  168. end


  169. #==============================================================================
  170. # Scene_Charactor
  171. #==============================================================================

  172. class Scene_Charactor
  173.   #--------------------------------------------------------------------------
  174.   #   actor_index :角色编号
  175.   #--------------------------------------------------------------------------
  176.   def initialize(actor_index = 0, equip_index = 0)
  177.     @actor_index = actor_index
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   #--------------------------------------------------------------------------
  181.   def main
  182.     @actor = $game_party.actors[@actor_index]
  183.     @status_window = Window_Charactor.new(@actor)
  184.     Graphics.transition
  185.     loop do
  186.       Graphics.update
  187.       Input.update
  188.       update
  189.       if $scene != self
  190.         break
  191.       end
  192.     end
  193.     Graphics.freeze
  194.     @status_window.dispose
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   #--------------------------------------------------------------------------
  198.   def update
  199.     if Input.trigger?(Input::B)
  200.       $game_system.se_play($data_system.cancel_se)
  201.       $scene = Scene_Menu.new(8)
  202.       return
  203.     end
  204.     if Input.trigger?(Input::R)
  205.       $game_system.se_play($data_system.cursor_se)
  206.       @actor_index += 1
  207.       @actor_index %= $game_party.actors.size
  208.       $scene = Scene_Charactor.new(@actor_index)
  209.       return
  210.     end
  211.     if Input.trigger?(Input::L)
  212.       $game_system.se_play($data_system.cursor_se)
  213.       @actor_index += $game_party.actors.size - 1
  214.       @actor_index %= $game_party.actors.size
  215.       $scene = Scene_Charactor.new(@actor_index)
  216.       return
  217.     end
  218.   end
  219. end


  220. #==============================================================================
  221. # Scene_Status
  222. #==============================================================================

  223. class Scene_Status
  224.   alias update_chara update
  225.   def update
  226.     if Input.trigger?(CHENGE_KEY)
  227.       $game_system.se_play($data_system.decision_se)
  228.       $scene = Scene_Charactor.new(@actor_index)
  229.       return
  230.     end
  231.     update_chara
  232.   end
  233. end
复制代码


版务信息:本贴由楼主自主结贴~
头像被屏蔽

Lv1.梦旅人 (禁止发言)

圣魔

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-1-12
帖子
3395
3
发表于 2007-7-11 22:08:59 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
4
 楼主| 发表于 2007-7-11 22:14:53 | 只看该作者
以下引用永劫的咎人于2007-7-11 14:08:59的发言:

事件中可以使用的“变量”只是一个数字而已。

#--------------------------------------------------------------------------
# 人物年龄 (自定义)
#--------------------------------------------------------------------------
CHARA_AGE = ["17","23","15","18","16","17","19","","","","","",""]

第一个17,试试改成这样。

#--------------------------------------------------------------------------
# 人物年龄 (自定义)
#--------------------------------------------------------------------------
CHARA_AGE = ["#{$game_variables[12]}","23","15","18","16","17","19","","","","","",""]

不行,一开始就提示undefined method '[]' for nil:Nilclass
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

圣魔

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-1-12
帖子
3395
5
发表于 2007-7-11 22:16:13 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
6
 楼主| 发表于 2007-7-11 22:19:23 | 只看该作者
怎么输入?
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

圣魔

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-1-12
帖子
3395
7
发表于 2007-7-11 22:26:58 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
8
 楼主| 发表于 2007-7-11 22:29:26 | 只看该作者

以下引用永劫的咎人于2007-7-11 14:26:58的发言:

在事件中给12号变量定义一个数值哦

可是它未进入游戏就出现错误了
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

圣魔

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-1-12
帖子
3395
9
发表于 2007-7-11 22:38:56 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
60
在线时间
45 小时
注册时间
2006-8-23
帖子
303
10
 楼主| 发表于 2007-7-11 22:45:21 | 只看该作者
以下引用永劫的咎人于2007-7-11 14:38:56的发言:

啊啊啊,忘记变量本来就是数值了……

#--------------------------------------------------------------------------
# 人物年龄 (自定义)
#--------------------------------------------------------------------------
CHARA_AGE = [$game_variables[12],"23","15","18","16","17","19","","","","","",""]

看看这样可以么

也是不行啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-9-22 03:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表