關於部落格
RPG製作大師XP腳本為主要更新

RPG製作大師VX腳本為其次更新

RPG製作大師VX_Ace目前不考慮

RPG製作大師MV腳本完全沒打算

留言完建議重新整理看看是否顯示

目前不處理本舖外腳本的相關問題

其他相關事項請觀看規定注意事項

本舖未來的經營計畫與VA的支援




var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37462754-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

  • 308393

    累積人氣

  • 39

    今日人氣

    0

    追蹤人氣

【腳本】多維數組檢視修改器


使用方法
打開腳本編輯器,對腳本「Main」按下右鍵,選擇插入,會出現1個空白腳本
在空白腳本內貼上以下腳本:
RPG Maker XP 適用
module Sword
#=======================================
#★ 魔劍工舖 - 多維數組檢視修改器
# 轉貼腳本請著名出處:
http://blog.yam.com/a870053jjkj/article/24863539
# 如果採用在遊戲中,看你高興是否顯示腳本出處,但嚴禁說是自己寫的腳本!!
#=======================================
#● 使用者自定設置
SWORD_TABL_XPVX = 0    # 目前此設置沒啥用處,但請勿修改
#=======================================
# 呼叫方法:$scene = Sword_Table.new(多維數組, 維數)
#詳細設置說明請參考:http://blog.yam.com/a870053jjkj/article/24863539
#=======================================

end
 
#■ 顯示多維數組的數值
class WSword_Table < Window_Base
  include Sword
  attr_reader   :index
  def initialize(table, z, dimension = 0)
    super(100, 32, 540, 384)
    self.contents = Bitmap.new(80 * table.xsize + 28, 32 * table.ysize)
    self.cursor_rect.set(30, 0, 80, 32)
    self.opacity = 0
    @index = [0, 0] # 記錄游標的位置 [X, Y]
    @scope = [0, 5, 0, 10] # 記錄游標所在範圍 [最低X, 最高X, 最低Y, 最高Y]
    @dimension = dimension if @dimension == nil
    refresh(table, z)
  end
  def refresh(table, z)
    self.contents.clear
    self.contents.font.color = normal_color
    # 顯示編號與數值
    for i in 0...table.xsize
      for ii in 0...table.ysize
        case @dimension
        when 1
          self.contents.draw_text(80*i+32, 32*ii, 80
, 32, table[i].to_s, 1) # 數值
        when 2
          self.contents.draw_text(80*i+32, 32*ii, 80, 32, table[i, ii].to_s, 1) # 數值
        when 3
          self.contents.draw_text(80*i+32, 32*ii, 80, 32, table[i, ii, z].to_s, 1) # 數值
        end
      end
    end
  end
  #● 更新游標位置
  def update_cursor_rect(table, direction) # 多維數組, 游標移動方向
    SWORD_LAND_XPVX == 0 ? $game_system.se_play($data_system.cursor_se) :
    Sound.play_cursor
    case direction
    when 2 # 下
      if @index[1] == table.ysize - 1 # 當在最下面底部時
        self.oy = 0 and @scope[2] = 0 and @scope[3] = 10
      end
      case @dimension # 依維數前進
      when 1
        table[@index[0]] == nil ? @index[1] = 0 : @index[1] += 1
      when 2
        table[@index[0], @index[1]+1] == nil ? @index[1] = 0 : @index[1] += 1
      when 3
        table[@index[0], @index[1]+1, table.zsize - 1] == nil ? @index[1] = 0 : @index[1] += 1
      end
      if @index[1] == 11 + @scope[2] # 需要換頁時
        self.oy += 32 and @scope[2] += 1 and @scope[3] += 1
      end
    when 4 # 左
      if @index[0] == 0 # 當在最左邊開頭時
        self.ox = 80*(table.xsize-6) and @scope[0] = table.xsize-6 and @scope[1] = table.xsize-1
      end
      case @dimension # 依維數前進
      when 1
        table[@index[0]-1] == nil ?
        @index[0] = table.xsize - 1 : @index[0] -=1
      when 2
        table[@index[0]-1, @index[1]] == nil ?
        @index[0] = table.xsize - 1 : @index[0] -=1
      when 3
        table[@index[0]-1, @index[1], table.zsize - 1] == nil ?
        @index[0] = table.xsize - 1 : @index[0] -=1
      end
      if @index[0] == -1 + @scope[0] # 需要換頁時
        self.ox -= 80 and @scope[0] -= 1 and @scope[1] -= 1
      end
    when 6 # 右
      if @index[0] == table.xsize - 1 # 當在最右邊底部時
        self.ox = 0 and @scope[0] = 0 and @scope[1] = 5
      end
      case @dimension # 依維數前進
      when 1
        table[@index[0]+1] == nil ? @index[0] = 0 : @index[0] += 1
      when 2
        table[@index[0]+1, @index[1]] == nil ? @index[0] = 0 : @index[0] += 1
      when 3
        table[@index[0]+1, @index[1], table.zsize - 1] == nil ? @index[0] = 0 : @index[0] += 1
      end
      if @index[0] == 6 + @scope[0] # 需要換頁時
        self.ox += 80 and @scope[0] += 1 and @scope[1] += 1
      end
    when 8 # 上
      if @index[1] == 0 # 當在最上面開頭時
        self.oy = 32*(table.ysize-11) and @scope[2]=table.ysize-11 and @scope[3]=table.ysize-1
      end
      case @dimension # 依維數前進
      when 1
        table[@index[0]] == nil ?
        @index[1] = table.ysize - 1 : @index[1] -=1
      when 2
        table[@index[0], @index[1]-1] == nil ?
        @index[1] = table.ysize - 1 : @index[1] -=1
      when 3
        table[@index[0], @index[1]-1, table.zsize - 1] == nil ?
        @index[1] = table.ysize - 1 : @index[1] -=1
      end
      if @index[1] == -1 + @scope[2] # 需要換頁時
        self.oy -= 32 and @scope[2] -= 1 and @scope[3] -= 1
      end
    end
    # 更新游標
    self.cursor_rect.set(80 * (@index[0] - @scope[0]) + 30 ,
    32 * (@index[1] - @scope[2]), 80, 32)
    return [@scope[0], @scope[2]]
  end
end
 
#■ 顯示Z座標用語
class WSword_TableZ < Window_Base
  def initialize
    super(0, 0, 100, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 52, 32, "Z", 1)
  end
end
 
#■ 顯示X、Y的用語編號
class WSword_TableXY < Window_Base
  def initialize(table, x, y)
    super(100, 0, 540, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh(table, x, y)
  end
  def refresh(table, x, y)
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.font.size = 25
    self.contents.draw_text(0, 0, 32, 32, "\")
    self.contents.font.size = 15
    self.contents.draw_text(20, 0, 22, 32, "X")
    self.contents.draw_text(0, 8, 22, 32, "Y")
    self.contents.font.size = 22
    a = true
    for i in 0...table.xsize
      self.contents.draw_text(80*i+32, 0, 80, 32, (i + x).to_s, 1) # X編號
      for ii in 0...table.ysize
        self.contents.draw_text(0, 32*ii+32, 32, 32, (ii + y).to_s) if a # Y編號
      end
      a = false
    end
  end
end
 
#■ 多維數組幫助窗口
class WSword_TableHelp < Window_Base
  def initialize
    super(100, 416, 540, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  def refresh(type = 0, parameter = nil) # 顯示內容, 參數
    self.contents.clear
    case type
    when 0 # 一般模式(選項內容)
      self.contents.font.color = system_color
      self.contents.draw_text(16, 0, 508, 32, 'A鍵:')
      self.contents.draw_text(185, 0, 508, 32, 'S鍵:')
      self.contents.draw_text(345, 0, 508, 32, 'D鍵:')
      self.contents.font.color = normal_color
      self.contents.draw_text(68, 0, 508, 32, '快速移動')
      self.contents.draw_text(237, 0, 508, 32, '搜尋數值')
      self.contents.draw_text(406, 0, 508, 32, '全部修改')
    when 1 # 快速移動模式
      self.contents.font.color = system_color
      self.contents.draw_text(0, 0, 508, 32, '移動座標:')
      self.contents.draw_text(110, 0, 508, 32, 'X:')
      self.contents.draw_text(242, 0, 508, 32, '/Y:')
      self.contents.draw_text(474, 0, 508, 32, '/Z:')
    when 2 # 搜尋數值模式
      self.contents.font.color = system_color
      self.contents.draw_text(0, 0, 508, 32, '搜尋數值:')
      self.contents.draw_text(110, 0, 508, 32, '數值:')
      self.contents.draw_text(242, 0, 508, 32, '/範圍:')
      self.contents.font.color = normal_color
      self.contents.draw_text(474, 0, 508, 32, '相等')
      self.contents.draw_text(474, 0, 508, 32, '以上')
      self.contents.draw_text(474, 0, 508, 32, '以下')
    when 3 # 全部修改模式
      self.contents.font.color = system_color
      self.contents.draw_text(0, 0, 508, 32, '請輸入數值:')
      self.contents.draw_text(262, 0, 508, 32, 'Z鍵:')
      self.contents.font.color = normal_color
      self.contents.draw_text(132, 0, 508, 32, '-') if parameter >= 6
      self.contents.draw_text(312, 0, 508, 32, '方式切換')
      self.contents.font.color = crisis_color
      if parameter == 0 or parameter == 6
        self.contents.draw_text(0, 0, 508-16, 32, '代入', 2)
      elsif parameter == 1 or parameter == 7
        self.contents.draw_text(0, 0, 508, 32, '加法', 2)
      elsif parameter == 2 or parameter == 8
        self.contents.draw_text(0, 0, 508, 32, '減法', 2)
      elsif parameter == 3 or parameter == 9
        self.contents.draw_text(0, 0, 508, 32, '乘法', 2)
      elsif parameter == 4 or parameter == 10
        self.contents.draw_text(0, 0, 508, 32, '除法', 2)
      elsif parameter == 5 or parameter == 11
        self.contents.draw_text(0, 0, 508, 32, '求餘', 2)
      end
    when 4 # 一般模式(多維數組單元內容)
      self.contents.font.color = system_color
      self.contents.draw_text(0, 0, 508, 32, '空白:')
      #self.contents.draw_text(176, 0, 508, 32, 'Z鍵:')
      #self.contents.draw_text(169, 0, 508, 32, 'A鍵:')
      #self.contents.draw_text(338, 0, 508, 32, 'S鍵:')
      #self.contents.draw_text(338, 0, 508, 32, 'D鍵:')
      self.contents.font.color = normal_color
      self.contents.draw_text(66, 0, 508, 32, '修改數值')
      #self.contents.draw_text(226, 0, 508, 32, '切換 ±')
      #self.contents.draw_text(169, 0, 508, 32, '±1')
      #self.contents.draw_text(338, 0, 508, 32, '±10')
      #self.contents.draw_text(338, 0, 508, 32, '±100')
    when 5 # 修改數值
      self.contents.font.color = system_color
      self.contents.draw_text(0, 0, 508, 32, '請輸入數值:')
      self.contents.draw_text(262, 0, 508, 32, 'Z鍵:')
      self.contents.font.size = 15
      self.contents.draw_text(410, 0, 508, 16, '上限:')
      self.contents.draw_text(410, 16, 508, 16, '下限:')
      self.contents.font.size = 22
      self.contents.font.color = normal_color
      self.contents.draw_text(132, 0, 508, 32, '-') if parameter
      self.contents.draw_text(312, 0, 508, 32, '正負切換')
      self.contents.font.size = 15
      self.contents.draw_text(468, 0, 508, 16, '32767')
      self.contents.draw_text(460, 16, 508, 16, '-32768')
      self.contents.font.size = 22
    end
  end
end
 
#■ 事件 [數值輸入處理]
class Window_InputNumber
  attr_writer    :index
end
 
#■ 多維數組檢視修改器畫面
class Sword_Table
  include Sword
  def initialize(table, dimension) # 多維數組, 維數
    @table = table
    @dimension = dimension
  end
  def main
    # 產生窗口
    @table_wsword = WSword_Table.new(@table, 0, @dimension) # 多維數組窗口
    @table_wsword.active = false
    @tablez_wsword = WSword_TableZ.new# Z用語窗口
    @tablexy_wsword = WSword_TableXY.new(@table, 0, 0) # XY用語窗口
    @tablehelp_wsword = WSword_TableHelp.new
    @input_number_window = Window_InputNumber.new(5) # 數值輸入窗口
    @input_number_window.x = 232
    @input_number_window.y = 416
    @input_number_window.active = false
    @input_number_window.visible = false
    z = Array.new(@table.zsize){|a|a.to_s}
    @command_window = Window_Command.new(100, z) # 選項窗口
    @command_window.y = 32
    @command_window.opacity = 0
    @command_window.height = 448
    # 主流程
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    # 釋放窗口
    @table_wsword.dispose
    @command_window.dispose
    @tablez_wsword.dispose
    @tablexy_wsword.dispose
    @tablehelp_wsword.dispose
    @input_number_window.dispose
  end
  #● 更新
  def update
    # 更新窗口
    @table_wsword.update
    @command_window.update
    @tablehelp_wsword.update
    @input_number_window.update
    #○ 選項窗口活動時的場合
    if @command_window.active
      if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) and @dimension == 3
        @table_wsword.refresh(@table, @command_window.index)
      elsif Input.trigger?(Input::B) # 關閉多維數組畫面
        SWORD_LAND_XPVX == 0 ?
        $game_system.se_play($data_system.cancel_se) : Sound.play_cancel
        $Sword_Table = @table # 將修改後的多維數組代入 $Sword_Table
        $scene = Scene_Map.new
      elsif Input.trigger?(Input::C) or @dimension != 3 # 切換至多維數組窗口
        if @dimension == 3
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.decision_se) : Sound.play_decision
        end
        @command_window.update
        @command_window.active = false
        @table_wsword.active = true
        @tablehelp_wsword.refresh(4)
      elsif Input.trigger?(Input::X) # 快速移動模式
        p '尚未開放'
        return
      elsif Input.trigger?(Input::Y) # 搜尋數值模式
        p '尚未開放'
        return
      elsif Input.trigger?(Input::Z) # 全部修改模式
        p '尚未開放'
        return
        @negative = false
        @command_window.active = false
        @input_number_window.number = 0
        @input_number_window.active = true
        @input_number_window.visible = true
        @input_number_type = 3
        @tablehelp_wsword.refresh(3, @manipulate = 0)
      end
    #○ 多為數組窗口活動時的場合
    elsif @table_wsword.active
      if Input.repeat?(Input::UP) and @dimension != 1
        a = @table_wsword.update_cursor_rect(@table, 8)
        @tablexy_wsword.refresh(@table, a[0], a[1])
      elsif Input.repeat?(Input::DOWN) and @dimension != 1
        a = @table_wsword.update_cursor_rect(@table, 2)
        @tablexy_wsword.refresh(@table, a[0], a[1])
      elsif Input.repeat?(Input::LEFT)
        a = @table_wsword.update_cursor_rect(@table, 4)
        @tablexy_wsword.refresh(@table, a[0], a[1])
      elsif Input.repeat?(Input::RIGHT)
        a = @table_wsword.update_cursor_rect(@table, 6)
        @tablexy_wsword.refresh(@table, a[0], a[1])
      elsif Input.trigger?(Input::X) # 增減數值 1
        0
      elsif Input.trigger?(Input::Y) # 增減數值 10
        0
      elsif Input.trigger?(Input::Z) # 增減數值 100
        0
      elsif Input.trigger?(Input::A) # 加減切換
        0
      elsif Input.trigger?(Input::B)
        SWORD_LAND_XPVX == 0 ? $game_system.se_play($data_system.cancel_se) :
        Sound.play_cancel
        if @dimension != 3 # 如果是1或2維數組,就回到地圖
          $Sword_Table = @table # 將修改後的多維數組代入 $Sword_Table
          $scene = Scene_Map.new
        else # 如果是3維數組,就活動Z值選項窗口
          @command_window.active = true
          @table_wsword.active = false
          @tablehelp_wsword.refresh(0)
        end
      elsif Input.trigger?(Input::C) # 更改數值
        SWORD_LAND_XPVX == 0 ?
        $game_system.se_play($data_system.decision_se) : Sound.play_decision
        a = @table_wsword.index
        case @dimension
        when 1
          @table[a[0]] < 0 ? @negative = true : @negative = false
          @input_number_window.number = @table[a[0]].abs
        when 2
          @table[a[0], a[1]] < 0 ? @negative = true : @negative = false
          @input_number_window.number = @table[a[0], a[1]].abs
        when 3
          @table[a[0], a[1], @command_window.index] < 0 ? @negative = true : @negative = false
          @input_number_window.number = @table[a[0], a[1], @command_window.index].abs
        end
        @tablehelp_wsword.refresh(5, @negative)
        @negative ? @input_number_window.x = 247 : @input_number_window.x = 232
        @input_number_window.index = 0
        @input_number_window.update # 快速更新游標位置
        @input_number_window.active = true
        @input_number_window.visible = true
        @input_number_type = 5
        @table_wsword.active = false
      end
    #○ 數值輸入窗口活動時的場合
    elsif @input_number_window.active
      case @input_number_type
      when 3 # 全部修改模式
        if Input.trigger?(Input::B)
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.cancel_se) : Sound.play_cancel
          @input_number_window.active = false
          @input_number_window.visible = false
          @command_window.active = true
        elsif Input.trigger?(Input::A) # 正負切換
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.cursor_se) : Sound.play_cursor
          if @negative # 如果是負數就換成正數
            @input_number_window.x = 232
            @negative = false
          else # 如果是正數就換成負數
            @input_number_window.x = 247
            @negative = true
          end
          @tablehelp_wsword.refresh(5, @negative)
        elsif Input.trigger?(Input::C) # 送出數值
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.decision_se) : Sound.play_decision
          for i in
0...@table.xsize
            for ii in
0...@table.ysize
              for iii in
0...@table.zsize
                case @manipulate
                when 0 # 代入
                  @table[i, ii, iii] = @input_number_window.number
                when 1 # 加法
                  @table[i, ii, iii] += @input_number_window.number
                when 2 # 減法
                  @table[i, ii, iii] -= @input_number_window.number
                when 3 # 乘法
                  @table[i, ii, iii] *= @input_number_window.number
                when 4 # 除法
                  @table[i, ii, iii] /= @input_number_window.number
                when 5 # 求餘
                  @table[i, ii, iii] %= @input_number_window.number
                end
              end
            end
          end
          @input_number_window.active = false
          @input_number_window.visible = false
          @tablehelp_wsword.refresh(0)
          @table_wsword.refresh(@table, @command_window.index)
          @command_window.active = true
        end
      when 5 # 一般模式(修改數值)
        if Input.trigger?(Input::B) # 設回原始值
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.cancel_se) : Sound.play_cancel
          a = @table_wsword.index
          case @dimension
          when 1
            @input_number_window.number = @table[a[0]]
          when 2
            @input_number_window.number = @table[a[0], a[1]]
          when 3
            @input_number_window.number = @table[a[0], a[1], @command_window.index]
          end
        elsif Input.trigger?(Input::A) # 正負切換
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.cursor_se) : Sound.play_cursor
          if @negative # 如果是負數就換成正數
            @input_number_window.x = 232
            @negative = false
          else # 如果是正數就換成負數
            @input_number_window.x = 247
            @negative = true
          end
          @tablehelp_wsword.refresh(5, @negative)
        elsif Input.trigger?(Input::C) # 送出數值
          SWORD_LAND_XPVX == 0 ?
          $game_system.se_play($data_system.decision_se) : Sound.play_decision
          @input_number_window.active = false
          @input_number_window.visible = false
          a = @table_wsword.index
          case @dimension
          when 1
            b = @input_number_window.number
            @table[a[0]] = @negative ? -b : b.abs
          when 2
            b = @input_number_window.number
            @table[a[0], a[1]] = @table[a[0]] = @negative ? -b : b.abs
          when 3
            b = @input_number_window.number
            @table[a[0], a[1], @command_window.index] = @negative ? -b : b.abs
          end
          @input_number_window.number
          @tablehelp_wsword.refresh(4)
          @table_wsword.refresh(@table, @command_window.index)
          @table_wsword.active = true
        end
      end
    end
  end
end
 
 
設置方法
可用於事件中的 [腳本] 事件或是腳本編輯器中
呼叫方法
$scene = Sword_Table.new(多維數組, 多維數組的維數)
 
 
注意事項
☆由於這是嚴格來說是半成品,所以文章整個是寫的很懶XD
☆修改後的多維數組會存在變量【$Sword_Table】中,可用代入的方式取代舊的多維數組
相簿設定
標籤設定
相簿狀態