查看: 2772|回复: 2

[已经解决] 如何通过脚本实现队列行进功能的开关?

[复制链接]
梦石
0
星屑
47
在线时间
58 小时
注册时间
2010-10-6
回帖
43
发表于 2014-7-30 16:57:40 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 VIPArcher 于 2014-7-30 17:27 编辑

找了一个设置的脚本。
然后我想在上面增加开关队列行进的功能,
请教一下怎么才能通过脚本实现队列行进功能的开关?
 $savec.set(id, data)——保存「true/false」
 $savec.check(id)——读取「true/false」
 $savec.set_num(id, data)——保存数值
 $savec.get_num(id)——读取数值0
↑
上面的是说明,和脚本无关
……
[pre lang="ruby" line="1"]
module SUI
module OPTION
  # ボイス再生ボリューム変更時のサンプルボイス
  # 指定したボイスからランダムで1つ、新しいボリュームで再生されます。
  # サンプルボイスがいらない場合は空にしてください。
  SAMPLE = [
  #ファイル名
#  "sample_voice01",
#  "sample_voice02",
   "Cat",
   "Crow",
   "Dog",
  ]
  
  # ボイスファイルの保存場所
  #VOICE_DIR = "Audio/SE/Voice/"
  VOICE_DIR = "Audio/SE/"
end
end
#==============================================================================
# 設定完了
#==============================================================================



class Window_Option < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 430, 330)
    self.openness = 0
    self.x = Graphics.width / 2 - self.width / 2
    self.y = Graphics.height / 2 - self.height / 2 + line_height / 2 + padding
    self.z = 160
    @line = 0
    set_index
    refresh
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    contents.font.color = normal_color
    contents.draw_text(0, 0 * rows_height, contents.width, line_height, "背景音量")
    contents.draw_text(0, 1 * rows_height, contents.width, line_height, "语音音量")
    contents.draw_text(0, 2 * rows_height, contents.width, line_height, "角色语音开关")
    contents.draw_text(0, 3 * rows_height, contents.width, line_height, "文字表示速度")
    contents.draw_text(0, 4 * rows_height, contents.width, line_height, "队列行进开关")
    draw_command_10(0)
    draw_command_10(1)
    draw_command_2(2)
    draw_command_3(3)
    draw_command_2(4)
  end
  #--------------------------------------------------------------------------
  # ● 行の高さ(2行分)
  #--------------------------------------------------------------------------
  def rows_height
    60
  end
  #--------------------------------------------------------------------------
  # ● 文字の描画
  #--------------------------------------------------------------------------
  def draw_text2(x, y, w, text, blue = false)
    contents.font.color = blue ? system_color : normal_color
    contents.font.color.alpha = blue ? 255 : 128
    draw_text(x, y, w, line_height, text)
  end
  #--------------------------------------------------------------------------
  # ● 10コマンドの描画
  #--------------------------------------------------------------------------
  def draw_command_10(row)
    y = rows_height * row + line_height
    10.times do |i|
      x = 30 + 36 * i - ((i == 9) ? 2 : 0)
      draw_text2(x, y, 30, ((i + 1) * 10).to_s, (i == @index[row]))
    end
  end
  #--------------------------------------------------------------------------
  # ● 10コマンドの矩形を取得
  #--------------------------------------------------------------------------
  def item_rect_10
    rect = Rect.new
    rect.x = 30 - 9 + 36 * @index[@line]
    rect.y = rows_height * @line + line_height
    rect.width = 30 + 8
    rect.height = line_height
    rect
  end
  #--------------------------------------------------------------------------
  # ● 2コマンドの描画
  #--------------------------------------------------------------------------
  def draw_command_2(row)
    y = rows_height * row + line_height
    list = ["开启", "关闭"]
    2.times do |i|
      x = 30 + 100 * i
      draw_text2(x, y, 40, list, (i == @index[row]))
    end
  end
  #--------------------------------------------------------------------------
  # ● 2コマンドの矩形を取得
  #--------------------------------------------------------------------------
  def item_rect_2
    rect = Rect.new
    rect.x = 30 - 11+ 100 * @index[@line]
    rect.y = rows_height * @line + line_height
    rect.width = 50 + 8
    rect.height = line_height
    rect
  end
  #--------------------------------------------------------------------------
  # ● 3コマンドの描画
  #--------------------------------------------------------------------------
  def draw_command_3(row)
    y = rows_height * row + line_height
    list = ["缓慢", "普通", "快速"]
    3.times do |i|
      x = 30 + 80 * i
      draw_text2(x, y, 40, list, (i == @index[row]))
    end
  end
  #--------------------------------------------------------------------------
  # ● 3コマンドの矩形を取得
  #--------------------------------------------------------------------------
  def item_rect_3
    rect = Rect.new
    rect.x = 30 - 11 + 80 * @index[@line]
    rect.y = rows_height * @line + line_height
    rect.width = 50 + 8
    rect.height = line_height
    rect
  end
  #--------------------------------------------------------------------------
  # ● カーソルの更新
  #--------------------------------------------------------------------------
  def update_cursor
    case @line
      when 0, 1
        cursor_rect.set(item_rect_10)
      when 2, 4
        cursor_rect.set(item_rect_2)
      when 3
        cursor_rect.set(item_rect_3)
      end
      Sound.play_cursor
  end
  #--------------------------------------------------------------------------
  # ● 行の設定
  #--------------------------------------------------------------------------
  def line=(row)
    old = @line
    @line = [[@line + row, 0].max, 4].min
    update_cursor if old != @line
  end
  #--------------------------------------------------------------------------
  # ● 行の設定
  #--------------------------------------------------------------------------
  def index=(i)
    max = 10 if( @line == 0 || @line == 1)
    max = 1 if( @line == 2|| @line == 4)
    max = 2 if( @line == 3)
    old = @index[@line]
    @index[@line] = [[@index[@line] + i, 0].max, max].min
    update_cursor if old != @index[@line]
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    return unless self.openness == 255
    self.line = +1 if Input.repeat?(:DOWN)
    self.line = -1 if Input.repeat?(:UP)
    self.index = +1 if Input.repeat?(:RIGHT)
    self.index = -1 if Input.repeat?(:LEFT)
    if Input.trigger?(:C)
      Sound.play_use_item
      case @line
        when 0
          $savec.set_num("bgm_vol", (@index[@line] + 0) * 10)
          refresh
          RPG::BGM::last.play
        when 1
          $savec.set_num("voice_vol", (@index[@line] + 0) * 10)
          refresh
          Audio.se_stop
          vol = SUI::OPTION.voice_volume
          return if SUI::OPTION::SAMPLE.length == 0
          r = SUI::OPTION::SAMPLE[rand(SUI::OPTION::SAMPLE.length)]
          Audio.se_play("#{SUI::OPTION::VOICE_DIR}#{r}", 100 * vol)
        when 2
          $savec.set("voice", @index[@line] == 1)
          refresh
        when 3
          $savec.set_num("speed", @index[@line])
          refresh
        when 4
          $savec.set("followers_move", @index[@line] == 1)
          refresh
        end
    end
  end
  #--------------------------------------------------------------------------
  # ● アクティブ設定
  #--------------------------------------------------------------------------
  def set_index
    @index = []
   
    res = $savec.get_num("bgm_vol")
    res = 70 if res < 10
    @index[0] = (res / 10) - 1
   
    res = $savec.get_num("voice_vol")
    res = 70 if res < 10
    @index[1] = (res / 10) - 1
   
    @index[2] = $savec.check("voice") ? 1 : 0
   
    @index[3] = $savec.get_num("speed")
    @index[3] = 1 if @index[3] == -1
   
    @index[4] = $savec.check("followers_move") ? 1 : 0
  end
end[/pre]
……
   

点评

你就不能用一次代码框吗? 就是发帖的时候工具栏上的这个<>  发表于 2014-7-30 17:26
[

梦石
1
星屑
23241
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2014-7-30 17:25:25 | 显示全部楼层
本帖最后由 喵呜喵5 于 2014-7-30 17:26 编辑
  1. $game_player.followers.visible = $data_system.opt_followers = true #false 关闭队列行进
  2. $game_player.refresh
复制代码

评分

参与人数 1梦石 +1 收起 理由
VIPArcher + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
47
在线时间
58 小时
注册时间
2010-10-6
回帖
43
 楼主| 发表于 2014-7-31 00:53:44 | 显示全部楼层
喵呜喵5 发表于 2014-7-30 17:25

受帮助了
[
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部