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

Project1

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

[已经过期] 银行脚本的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
66 小时
注册时间
2015-4-1
帖子
14
跳转到指定楼层
1
发表于 2015-8-27 13:58:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 RyanBern 于 2015-8-27 14:17 编辑

我用的是和哆啦A梦解救小夫上面一样的银行脚本,要输入:“$scene = Scene_Bank.new”才会生效,但是每次都显示银行脚本31行发生NameError,大神们能不能教教我
脚本:
RUBY 代码复制
  1. #银行脚本
  2. class Game_Party
  3.   attr  :cunkuan,true
  4.   attr  :daikuan,true
  5.   attr  :dy_item
  6.   attr  :items
  7.   alias old_i initialize
  8.   def initialize
  9.     old_i
  10.     @daikuan = 0
  11.     @cunkuan = 0
  12.     @dy_item = []
  13.   end
  14.   def item_empty?
  15.     return @items.empty?
  16.   end
  17.   def gain_dyitem(item)
  18.     # 更新 hash 的个数数据
  19.     if item.id > 0
  20.       if @dy_item.size<=8
  21.         @dy_item.push(item)
  22.       else
  23.         return false
  24.       end
  25.     end
  26.   end
  27. end
  28. #场景_银行定义
  29. class Scene_Bank
  30.   def initialize
  31.     @list_window = Window_HCommand.new(160,["存款","取款","贷款","还款"],416)
  32.     @list_window.y = 64
  33.     @temp_window = Window_Base.new(0,0,160,64)
  34.     @temp_window.contents = Bitmap.new(160 - 32, 64 - 32)
  35.     @temp_window.contents.font.color = Color.new(192, 224, 255, 255)
  36.     @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
  37.     @statu_window = Window_Bank.new
  38.     @statu_window.x =  640 - 160
  39.     @sell_window = Window_BankSell.new
  40.     @sell_window.active = false
  41.     @sell_window.index = -1
  42.     @bin_window = Window_BankInputNumber.new(7)
  43.     @bin_window.active = false
  44.     @bin_window.visible = false
  45.     @statu = nil
  46.   end
  47.   def main
  48.     # 执行过渡
  49.    Graphics.transition
  50.    # 主循环
  51.    loop do
  52.      # 刷新游戏画面
  53.      Graphics.update
  54.      # 刷新输入情报
  55.      Input.update
  56.      # 刷新画面
  57.      update
  58.      # 如果画面被切换的话就中断循环
  59.      if $scene != self
  60.        break
  61.      end
  62.    end
  63.    # 过渡
  64.    Graphics.freeze
  65.    @list_window.dispose
  66.    @temp_window.dispose
  67.    @statu_window.dispose
  68.    @sell_window.dispose
  69.   end
  70.   def update
  71.       @sell_window.update
  72.       @list_window.update
  73.       @statu_window.update
  74.       @temp_window.update
  75.       @bin_window.update
  76.       if @sell_window.active == true
  77.         update_sell
  78.         return
  79.       end
  80.       if @list_window.active == true
  81.         update_list
  82.         return
  83.       end
  84.       if @bin_window.active == true
  85.         update_bin
  86.         return
  87.       end
  88.   end
  89.   def update_list
  90.     if @sell_window.item_max == 0
  91.       @list_window.disable_item(2)
  92.     else
  93.       @list_window.draw_item(2)
  94.     end
  95.     if Input.trigger?(Input::B)
  96.       # 演奏取消 SE
  97.       $game_system.se_play($data_system.cancel_se)
  98.       # 切换的地图画面
  99.       $scene = Scene_Map.new
  100.       return
  101.     end
  102.     # 按下 C 键的情况下
  103.     if Input.trigger?(Input::C)
  104.       case @list_window.index
  105.       when 0  # 存款
  106.         @temp_window.contents.clear
  107.         @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
  108.         @temp_window.update
  109.         # 演奏确定 SE
  110.         $game_system.se_play($data_system.decision_se)
  111.         @bin_window.visible = true
  112.         @bin_window.active = true
  113.         @list_window.active = false
  114.         @statu = :ck
  115.       when 1  # 取款
  116.         @temp_window.contents.clear
  117.         @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
  118.         @temp_window.update
  119.         # 演奏确定 SE
  120.         $game_system.se_play($data_system.decision_se)
  121.         @bin_window.visible = true
  122.         @bin_window.active = true
  123.         @list_window.active = false
  124.         @statu = :qk
  125.       when 2  # 贷款
  126.         unless @sell_window.item_max == 0
  127.         @temp_window.contents.clear
  128.         @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
  129.         @temp_window.update
  130.         # 演奏确定 SE
  131.         $game_system.se_play($data_system.decision_se)
  132.         # 激活状态窗口
  133.         @list_window.active = false
  134.         @sell_window.active = true
  135.         @sell_window.index = 0
  136.         else
  137.         $game_system.se_play($data_system.buzzer_se)
  138.         return
  139.         end
  140.       when 3  # 还款
  141.         @temp_window.contents.clear
  142.         @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
  143.         @temp_window.update
  144.         $game_system.se_play($data_system.decision_se)
  145.         if $game_party.gold >= $game_party.daikuan
  146.           $game_party.lose_gold($game_party.daikuan)
  147.           $game_party.daikuan = 0
  148.           $game_party.dy_item.each {|value|
  149.           case value
  150.           when RPG::Item
  151.             $game_party.gain_item(value.id,1)
  152.           when RPG::Weapon
  153.             $game_party.gain_weapon(value.id,1)
  154.           when RPG::Armor
  155.             $game_party.gain_armor(value.id,1)
  156.           end
  157.           }
  158.           $game_party.dy_item.clear
  159.           @statu_window.refresh
  160.           @sell_window.refresh
  161.         else
  162.           @temp_window.contents.clear
  163.           @temp_window.contents.draw_text(0,0,32*6,32,"没有足够现金")
  164.           @temp_window.update
  165.         end #if
  166.       end #case
  167.     end #if
  168.   end#def(被end搞晕了)
  169.     def update_sell
  170.       if @sell_window.item_max == 0
  171.         @sell_window.active = false
  172.         @sell_window.index = -1
  173.         @list_window.active = true
  174.       end
  175.       if Input.trigger?(Input::B)
  176.         # 演奏取消 SE
  177.         $game_system.se_play($data_system.cancel_se)
  178.         @sell_window.active = false
  179.         @sell_window.index = -1
  180.         @list_window.active = true
  181.         return
  182.       end
  183.       if Input.trigger?(Input::C)
  184.         unless @sell_window.item_max == 0
  185.           $game_system.se_play($data_system.decision_se)
  186.           dyitem = @sell_window.item
  187.           unless dyitem.price <=0
  188.           if $game_party.dy_item.size <800000
  189.             case dyitem
  190.             when RPG::Item
  191.             $game_party.gain_item(dyitem.id ,-1)
  192.             when RPG::Weapon
  193.             $game_party.gain_weapon(dyitem.id ,-1)
  194.             when RPG::Armor
  195.             $game_party.gain_armor(dyitem.id,-1)
  196.             end
  197.             $game_party.gain_dyitem(dyitem)
  198.             $game_party.gain_gold((dyitem.price * 0.8).to_i)
  199.             $game_party.daikuan = $game_party.daikuan + (dyitem.price * 0.8).to_i
  200.             @statu_window.refresh
  201.             @sell_window.index = 0
  202.             @sell_window.refresh
  203.           else
  204.             @temp_window.contents.clear
  205.             @temp_window.contents.draw_text(0,0,32*6,32,"抵押达到上限")
  206.             @temp_window.update
  207.           end
  208.           else
  209.             $game_system.se_play($data_system.buzzer_se)
  210.             return
  211.           end
  212.         else
  213.           $game_system.se_play($data_system.buzzer_se)
  214.           return
  215.         end #unless
  216.       end #if
  217.     end #def
  218.     def update_bin
  219.       if Input.trigger?(Input::B)
  220.         # 演奏取消 SE
  221.         $game_system.se_play($data_system.cancel_se)
  222.         @bin_window.active = false
  223.         @bin_window.visible = false
  224.         @list_window.active = true
  225.         return
  226.       end
  227.       if Input.trigger?(Input::C)
  228.         $game_system.se_play($data_system.decision_se)
  229.         @bin_window.active = false
  230.         @bin_window.visible = false
  231.         @list_window.active = true
  232.         if @statu == :ck
  233.           if $game_party.gold < @bin_window.number
  234.             @temp_window.contents.clear
  235.             @temp_window.contents.draw_text(0,0,32*6,32,"现金不足")
  236.             @temp_window.update
  237.             return
  238.           else
  239.             $game_party.gain_gold([email]-@bin_window.number[/email])
  240.             $game_party.cunkuan += @bin_window.number
  241.             @statu_window.refresh
  242.             return
  243.           end
  244.         end
  245.         if @statu == :qk
  246.           if $game_party.cunkuan < @bin_window.number
  247.             @temp_window.contents.clear
  248.             @temp_window.contents.draw_text(0,0,32*6,32,"存款不足")
  249.             @temp_window.update
  250.             return
  251.           else
  252.             $game_party.gain_gold(@bin_window.number)
  253.             $game_party.cunkuan -= @bin_window.number
  254.             @statu_window.refresh
  255.             return
  256.           end
  257.         end
  258.       end
  259.     end
  260. end

Lv3.寻梦者

梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
帖子
337
2
发表于 2015-8-29 17:13:39 | 只看该作者
还是发工程吧
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7559
在线时间
1315 小时
注册时间
2015-8-15
帖子
747
3
发表于 2015-8-29 17:27:38 | 只看该作者
def main
    # 生成命令窗口
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "状态"
    s5 = "队伍"
    s6 = "存档"
    s7 = "结束游戏"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6 ,s7])
    @command_window.index = @menu_index
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7559
在线时间
1315 小时
注册时间
2015-8-15
帖子
747
4
发表于 2015-8-29 17:31:07 | 只看该作者
我不懂脚本,但是一定生成窗口,在执行窗口,
回复 支持 反对

使用道具 举报

Lv3.寻梦者

○赛

梦石
0
星屑
1249
在线时间
1276 小时
注册时间
2013-1-22
帖子
2246

贵宾

5
发表于 2015-8-29 17:34:07 | 只看该作者
这个脚本应该不完整 - -

评分

参与人数 1星屑 +90 收起 理由
RyanBern + 90 我很赞同

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
155
在线时间
332 小时
注册时间
2013-7-6
帖子
356
6
发表于 2015-8-29 22:22:54 | 只看该作者
本帖最后由 wolves 于 2015-8-29 22:24 编辑

Window_HCommand.new
改成
Window_Command.new
(貌似就是多打了个H)

点评

不是多打了H,因为Window_Command的initialize接收两个参数,这里是三个。原因楼主没有Window_HCommand的脚本  发表于 2015-9-6 09:37
偶是熬夜学编程的傻子
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 05:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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