查看: 3006|回复: 5

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

[复制链接]
梦石
0
星屑
50
在线时间
66 小时
注册时间
2015-4-1
回帖
8
发表于 2015-8-27 13:58:42 | 显示全部楼层 |阅读模式

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

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

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

我用的是和哆啦A梦解救小夫上面一样的银行脚本,要输入:“$scene = Scene_Bank.new”才会生效,但是每次都显示银行脚本31行发生NameError,大神们能不能教教我
脚本:
[pre lang="Ruby"]
#银行脚本
class Game_Party
  attr  :cunkuan,true
  attr  :daikuan,true
  attr  :dy_item
  attr  :items
  alias old_i initialize
  def initialize
    old_i
    @daikuan = 0
    @cunkuan = 0
    @dy_item = []
  end
  def item_empty?
    return @items.empty?
  end
  def gain_dyitem(item)
    # 更新 hash 的个数数据
    if item.id > 0
      if @dy_item.size<=8
        @dy_item.push(item)
      else
        return false
      end
    end
  end
end
#场景_银行定义
class Scene_Bank
  def initialize
    @list_window = Window_HCommand.new(160,["存款","取款","贷款","还款"],416)
    @list_window.y = 64
    @temp_window = Window_Base.new(0,0,160,64)
    @temp_window.contents = Bitmap.new(160 - 32, 64 - 32)
    @temp_window.contents.font.color = Color.new(192, 224, 255, 255)
    @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
    @statu_window = Window_Bank.new
    @statu_window.x =  640 - 160
    @sell_window = Window_BankSell.new
    @sell_window.active = false
    @sell_window.index = -1
    @bin_window = Window_BankInputNumber.new(7)
    @bin_window.active = false
    @bin_window.visible = false
    @statu = nil
  end
  def main
    # 执行过渡
   Graphics.transition
   # 主循环
   loop do
     # 刷新游戏画面
     Graphics.update
     # 刷新输入情报
     Input.update
     # 刷新画面
     update
     # 如果画面被切换的话就中断循环
     if $scene != self
       break
     end
   end
   # 过渡
   Graphics.freeze
   @list_window.dispose
   @temp_window.dispose
   @statu_window.dispose
   @sell_window.dispose
  end
  def update
      @sell_window.update
      @list_window.update
      @statu_window.update
      @temp_window.update
      @bin_window.update
      if @sell_window.active == true
        update_sell
        return
      end
      if @list_window.active == true
        update_list
        return
      end
      if @bin_window.active == true
        update_bin
        return
      end
  end
  def update_list
    if @sell_window.item_max == 0
      @list_window.disable_item(2)
    else
      @list_window.draw_item(2)
    end
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      $game_system.se_play($data_system.cancel_se)
      # 切换的地图画面
      $scene = Scene_Map.new
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      case @list_window.index
      when 0  # 存款
        @temp_window.contents.clear
        @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
        @temp_window.update
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        @bin_window.visible = true
        @bin_window.active = true
        @list_window.active = false
        @statu = :ck
      when 1  # 取款
        @temp_window.contents.clear
        @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
        @temp_window.update
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        @bin_window.visible = true
        @bin_window.active = true
        @list_window.active = false
        @statu = :qk
      when 2  # 贷款
        unless @sell_window.item_max == 0
        @temp_window.contents.clear
        @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
        @temp_window.update
        # 演奏确定 SE
        $game_system.se_play($data_system.decision_se)
        # 激活状态窗口
        @list_window.active = false
        @sell_window.active = true
        @sell_window.index = 0
        else
        $game_system.se_play($data_system.buzzer_se)
        return
        end
      when 3  # 还款
        @temp_window.contents.clear
        @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
        @temp_window.update
        $game_system.se_play($data_system.decision_se)
        if $game_party.gold >= $game_party.daikuan
          $game_party.lose_gold($game_party.daikuan)
          $game_party.daikuan = 0
          $game_party.dy_item.each {|value|
          case value
          when RPG::Item
            $game_party.gain_item(value.id,1)
          when RPG::Weapon
            $game_party.gain_weapon(value.id,1)
          when RPG::Armor
            $game_party.gain_armor(value.id,1)
          end
          }
          $game_party.dy_item.clear
          @statu_window.refresh
          @sell_window.refresh
        else
          @temp_window.contents.clear
          @temp_window.contents.draw_text(0,0,32*6,32,"没有足够现金")
          @temp_window.update
        end #if
      end #case
    end #if
  end#def(被end搞晕了)
    def update_sell
      if @sell_window.item_max == 0
        @sell_window.active = false
        @sell_window.index = -1
        @list_window.active = true
      end
      if Input.trigger?(Input::B)
        # 演奏取消 SE
        $game_system.se_play($data_system.cancel_se)
        @sell_window.active = false
        @sell_window.index = -1
        @list_window.active = true
        return
      end
      if Input.trigger?(Input::C)
        unless @sell_window.item_max == 0
          $game_system.se_play($data_system.decision_se)
          dyitem = @sell_window.item
          unless dyitem.price <=0
          if $game_party.dy_item.size <800000
            case dyitem
            when RPG::Item
            $game_party.gain_item(dyitem.id ,-1)
            when RPG::Weapon
            $game_party.gain_weapon(dyitem.id ,-1)
            when RPG::Armor
            $game_party.gain_armor(dyitem.id,-1)
            end
            $game_party.gain_dyitem(dyitem)
            $game_party.gain_gold((dyitem.price * 0.8).to_i)
            $game_party.daikuan = $game_party.daikuan + (dyitem.price * 0.8).to_i
            @statu_window.refresh
            @sell_window.index = 0
            @sell_window.refresh
          else
            @temp_window.contents.clear
            @temp_window.contents.draw_text(0,0,32*6,32,"抵押达到上限")
            @temp_window.update
          end
          else
            $game_system.se_play($data_system.buzzer_se)
            return
          end
        else
          $game_system.se_play($data_system.buzzer_se)
          return
        end #unless
      end #if
    end #def
    def update_bin
      if Input.trigger?(Input::B)
        # 演奏取消 SE
        $game_system.se_play($data_system.cancel_se)
        @bin_window.active = false
        @bin_window.visible = false
        @list_window.active = true
        return
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        @bin_window.active = false
        @bin_window.visible = false
        @list_window.active = true
        if @statu == :ck
          if $game_party.gold < @bin_window.number
            @temp_window.contents.clear
            @temp_window.contents.draw_text(0,0,32*6,32,"现金不足")
            @temp_window.update
            return
          else
            $game_party.gain_gold(-@bin_window.number)
            $game_party.cunkuan += @bin_window.number
            @statu_window.refresh
            return
          end
        end
        if @statu == :qk
          if $game_party.cunkuan < @bin_window.number
            @temp_window.contents.clear
            @temp_window.contents.draw_text(0,0,32*6,32,"存款不足")
            @temp_window.update
            return
          else
            $game_party.gain_gold(@bin_window.number)
            $game_party.cunkuan -= @bin_window.number
            @statu_window.refresh
            return
          end
        end
      end
    end
end[/pre]
梦石
0
星屑
3293
在线时间
1463 小时
注册时间
2014-8-9
回帖
308
发表于 2015-8-29 17:13:39 | 显示全部楼层
还是发工程吧
回复

使用道具 举报

梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 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
回复

使用道具 举报

梦石
0
星屑
7296
在线时间
1244 小时
注册时间
2015-8-15
回帖
473
发表于 2015-8-29 17:31:07 | 显示全部楼层
我不懂脚本,但是一定生成窗口,在执行窗口,
回复

使用道具 举报

○赛

梦石
0
星屑
1254
在线时间
1276 小时
注册时间
2013-1-22
回帖
2078

贵宾

发表于 2015-8-29 17:34:07 | 显示全部楼层
这个脚本应该不完整 - -

评分

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

查看全部评分

回复

使用道具 举报

梦石
0
星屑
175
在线时间
332 小时
注册时间
2013-7-6
回帖
316
发表于 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
偶是熬夜学编程的傻子
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部