Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

To anyone familiar with LASS by brainstorm

I need some help making it work for me. Everything is fine until i enter the wrong combo intentionally. maybe you guys can look at the scripts and help me out eh?

Code:
#==============================================================================
# Keyboard Input Module
#----------------------------------------------------------------------------
# Script by Cybersam
#==============================================================================

module Input
  @keys = []
  @pressed = []
  Mouse_Left = 1
  Mouse_Right = 2
  Mouse_Middle = 4
  Back= 8
  Tab = 9
  Enter = 13
  Shift = 16
  Ctrl = 17
  Alt = 18
  Esc = 27
  Space = 32
  Numberkeys = {}
  Numberkeys[0] = 48        # => 0
  Numberkeys[1] = 49        # => 1
  Numberkeys[2] = 50        # => 2
  Numberkeys[3] = 51        # => 3
  Numberkeys[4] = 52        # => 4
  Numberkeys[5] = 53        # => 5
  Numberkeys[6] = 54        # => 6
  Numberkeys[7] = 55        # => 7
  Numberkeys[8] = 56        # => 8
  Numberkeys[9] = 57        # => 9
  Numberpad = {}
  Numberpad[0] = 45
  Numberpad[1] = 35
  Numberpad[2] = 40
  Numberpad[3] = 34
  Numberpad[4] = 37
  Numberpad[5] = 12
  Numberpad[6] = 39
  Numberpad[7] = 36
  Numberpad[8] = 38
  Numberpad[9] = 33
  Letters = {}
  Letters["A"] = 65
  Letters["B"] = 66
  Letters["C"] = 67
  Letters["D"] = 68
  Letters["E"] = 69
  Letters["F"] = 70
  Letters["G"] = 71
  Letters["H"] = 72
  Letters["I"] = 73
  Letters["J"] = 74
  Letters["K"] = 75
  Letters["L"] = 76
  Letters["M"] = 77
  Letters["N"] = 78
  Letters["O"] = 79
  Letters["P"] = 80
  Letters["Q"] = 81
  Letters["R"] = 82
  Letters["S"] = 83
  Letters["T"] = 84
  Letters["U"] = 85
  Letters["V"] = 86
  Letters["W"] = 87
  Letters["X"] = 88
  Letters["Y"] = 89
  Letters["Z"] = 90
  Fkeys = {}
  Fkeys[1] = 112
  Fkeys[2] = 113
  Fkeys[3] = 114
  Fkeys[4] = 115
  Fkeys[5] = 116
  Fkeys[6] = 117
  Fkeys[7] = 118
  Fkeys[8] = 119
  Fkeys[9] = 120
  Fkeys[10] = 121
  Fkeys[11] = 122
  Fkeys[12] = 123
  Collon = 186        # => \ |
  Equal = 187         # => = +
  Comma = 188         # => , <
  Underscore = 189    # => - _
  Dot = 190           # => . >
  Backslash = 191     # => / ?
  Lb = 219
  Rb = 221
  Quote = 222         # => '"
  #-------------------------------------------------------------------------------
  USED_KEYS = [Mouse_Left, Mouse_Right, Mouse_Middle] 
  #-------------------------------------------------------------------------------
  
module_function
  #--------------------------------------------------------------------------
  def triggered?(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  end
  #-------------------------------------------------------------------------- 
  def check(key)
    Win32API.new("user32","GetAsyncKeyState",['i'],'i').call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  def pressed?(key)
    return true unless Win32API.new("user32","GetKeyState",['i'],'i').call(key).between?(0, 1)
    return false
  end
  #--------------------------------------------------------------------------
  def mouse_update
    @used_i = []
    for i in USED_KEYS
      x = check(i)
      if x == true
        @used_i.push(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  def self.C
    self.trigger?(C)
  end
  #-------------------------------------------------------------------------- 
  def self.B
    self.trigger?(B)
  end
  #-------------------------------------------------------------------------- 
  def self.A
    self.trigger?(A)
  end
  #-------------------------------------------------------------------------- 
  def self.Down
    self.trigger?(DOWN)
  end
  #-------------------------------------------------------------------------- 
  def self.Up
    self.trigger?(UP)
  end
  #-------------------------------------------------------------------------- 
  def self.Right
    self.trigger?(RIGHT)
  end
  #-------------------------------------------------------------------------- 
  def self.Left
    self.trigger?(LEFT)
  end
  #--------------------------------------------------------------------------
  def self.Anykey
    if A or B or C or Down or Up or Right or Left
      return true
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
end

Code:
class Game_Locker
  attr_accessor :lockercombo
  def initialize
    @lockercombo = Hash.new("45-64-75")
    #@lockercombo = []
    #for i in 0..5000
    #  @lockercombo[i] = "45-64-75"   #default combination
    #end
    @lockercombo[0] = "45-64-75"      #first combination
    @lockercombo[1] = "456475"        #other usable combination
    @lockercombo[2] = "45 64 75"      #other usable combination
  end
end
class Scene_Locker
  attr_accessor :lockerinput
  attr_accessor :lc
  attr_accessor :sename
  attr_accessor :se
  attr_accessor :template
  def initialize
    @sename = "032-Switch01"          #"032-Switch01" used to make locker sound
    @se = false                       #Put false if you do not like the sound.
    @changecombination = true         #Allows character to change combination
    @template = true                  #Changes Template of Scene.
  end
  def main
    @spriteset = Spriteset_Map.new
    @lockerinput = Window_LockerInput.new(0,8)
    @lockerinto = Window_LockerInstructions.new
    @lockerinput.opacity = 175
    @lockerinto.opacity = 175
    s1 = "Change Combination"
    s2 = "Enter Combination"
    @lc2 = Window_Command.new(350,[s1,s2])#(155,130,350,200)
    @lc2.x = 320 - @lc2.width / 2
    @lc2.y = 130
    @lc2.height = 200
    @lc2.opacity = 175
    @lc2.active = false
    @lc2.visible = false
    @lc = Window_LockerChange.new(0,8)
    @lc.active = false
    @lc.visible = false
    @lc.opacity = 175
    #if @changecombination == true
    #end
    if @changecombination == true
      secondupdate
    end
    if @template == true
      @lc.draw_locker_graphic
      @lockerinput.draw_locker_graphic
    end
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    @spriteset.dispose
    @lockerinto.dispose
    @lc2.dispose
    @lockerinput.dispose
    @lc.dispose
  end
  def secondupdate
    @lc2.visible = true
    @lc2.active = true
    @lockerinput.active = false
    @lockerinput.visible = false
  end
  def update
    @spriteset.update
    @lc.update
    @lockerinput.update
    @lockerinto.update
    @lc2.update
    if @lockerinput.active
      @lockerinto.set_text("Insert your locker combination and then click the screen")
      update2
    elsif @lc2.active
      @lockerinto.set_text("Change combination or enter combination")
      update3
    elsif @lc.active
      @lockerinto.set_text("Change your locker combination and then click the screen")
      update4
    end
  end
  #--------------------------------------------------------------------------
  def change_name
    #if @lockerinput.index == $game_temp.name_max_char
    #  $game_system.se_play($data_system.buzzer_se)
    #  return
    #end
    $game_system.se_play($data_system.decision_se)
    if @lockerinput.index < 6
      $scene = Scene_Map.new
    end
    if @lockerinput.name == $game_locker.lockercombo[0]
      $scene = Scene_Inventory_Items.new
    end
    if @lockerinput.name == $game_locker.lockercombo[1]
      $scene = Scene_Inventory_Items.new
    end
    #if @lockerinput.name == $game_locker.lockercombo[2]
    #  $scene = Scene_Inventory_Items.new
    #end
  end
  #--------------------------------------------------------------------------
  def input_processing
    if @lockerinput.index == $game_temp.name_max_char
      $game_system.se_play($data_system.buzzer_se)
    else
      $game_system.se_play($data_system.cursor_se)
    end
  end
  #--------------------------------------------------------------------------
  def update3
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      case @lc2.index
      when 0
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @lc.active = true
        @lc.visible = true
        @lc2.active = false
        @lc2.visible = false
      when 1
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @lockerinput.active = true
        @lockerinput.visible = true
        @lc2.active = false
        @lc2.visible = false
      end
      return
    end
  end
  def update2
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      @lockerinput.active = false
      @lockerinput.visible = false
      @lc2.active = true
      @lc2.visible = true
      return
    end
    if Input.triggered?(32) # [SPACE]
      input_processing
      @lockerinput.add(" ")
    end
    if Input.triggered?(1)
      change_name
    end
    @lockerinput.update
    if Input.triggered?(27) # [ESCAPE]
      $game_system.se_play($data_system.decision_se)
      @lockerinput.restore_default
      return
    end
    if Input.triggered?(8) # [BACKSPACE]
      if @lockerinput.index == 0
        return
      end
      $game_system.se_play($data_system.cancel_se)
      @lockerinput.back
      return
    end
    if Input.triggered?(13) # [ENTER]
      if @lockerinput.name == ""
        @lockerinput.restore_default
        return
      end
    end
    if Input.triggered?(189) # [SPACE]
      input_processing
      @lockerinput.add("-")
    end
    #for letter in 'A'..'Z'
    #  if Input.triggered?(letter[0])
    #    if Input.pressed?(16)
    #      input_processing
    #      @lockerinput.add(letter.upcase)
    #    else
    #      input_processing
    #      @lockerinput.add(letter.downcase)
    #    end
    #  end
    #end
    for letter in '0'..'9'
      if Input.triggered?(letter[0])
        input_processing
        @lockerinput.add(letter)
      end
    end
  end
  def input_processing2
    if @lc.index == $game_temp.name_max_char
      $game_system.se_play($data_system.buzzer_se)
    else
      $game_system.se_play($data_system.cursor_se)
    end
  end
  def update4
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      @lc.active = false
      @lc.visible = false
      @lc2.active = true
      @lc2.visible = true
      return
    end
    if Input.triggered?(32) # [SPACE]
      input_processing2
      @lc.add(" ")
    end
    if Input.triggered?(1)
      change_name2
    end
    @lc.update
    if Input.triggered?(27) # [ESCAPE]
      $game_system.se_play($data_system.decision_se)
      @lc.restore_default
      return
    end
    if Input.triggered?(8) # [BACKSPACE]
      if @lc.index == 0
        return
      end
      $game_system.se_play($data_system.cancel_se)
      @lc.back
      return
    end
    if Input.triggered?(13) # [ENTER]
      if @lc.name == ""
        @lc.restore_default
        return
      end
    end
    if Input.triggered?(189) # [SPACE]
      input_processing2
      @lc.add("-")
    end
    #for letter in 'A'..'Z'
    #  if Input.triggered?(letter[0])
    #    if Input.pressed?(16)
    #      input_processing
    #      @lockerinput.add(letter.upcase)
    #    else
    #      input_processing
    #      @lockerinput.add(letter.downcase)
    #    end
    #  end
    #end
    for letter in '0'..'9'
      if Input.triggered?(letter[0])
        input_processing2
        @lc.add(letter)
      end
    end
  end
  def change_name2
    #if @lockerinput.index == $game_temp.name_max_char
    #  $game_system.se_play($data_system.buzzer_se)
    #  return
    #end
    $game_system.se_play($data_system.decision_se)
    for i in 0..1
      $game_locker.lockercombo[i] = @lc.name    #default combination
    end
    @lc.active = false
    @lc.visible = false
    @lc2.active = true
    @lc2.visible = true
  end
end
class Window_LockerChange < Window_Base
  attr_reader   :name
  attr_reader   :index
  attr_accessor :max_char
  #--------------------------------------------------------------------------
  def initialize(actor, max_char)
    super(155,130,350,200)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.x = 320 - self.width / 2
    #@actor = $game_party.actors[actor]
    @name = ""#@actor.name
    @max_char = max_char
    name_array = @name.split(//)[0...@max_char]
    @name = ""
    for i in 0...name_array.size
      @name += name_array[i]
    end
    @default_name = @name
    @index = name_array.size
    @sprite_size = 0 # 0 for small sprites, 1 for bigger sprites
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  def restore_default
    @name = @default_name
    @index = @name.split(//).size
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  def add(character)
    if @index < @max_char and character != ""
      @name += character
      @index += 1
      refresh
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  def back
    if @index > 0
      name_array = @name.split(//)
      @name = ""
      for i in 0...name_array.size-1
        @name += name_array[i]
      end
      @index -= 1
      refresh
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    name_array = @name.split(//)
    for i in 0...@max_char
      c = name_array[i]
      if c == nil
        c = "_"
      end
      if $scene.template == true
        x = 320 - 16 * 14 + i * 28
      else
        x = 320 - 16 * 14 + i * 28 - width / 4
      end
      self.contents.draw_text(x, 49, 28, 32, c, 1)
    end
    #if @sprite_size == 0
    #  draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 92)
    #else
    #  draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 112)
    #end
  end
  def draw_locker_graphic
    @bitmap = 0
    if @bitmap != nil
      @bitmap = nil
    end
    #self.contents2.clear
    @bitmap = RPG::Cache.picture("locker")
    @timing = 4
    @counter = 0
    @pattern = 0
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if $scene.template == true
      if @index < @max_char-1
        self.cursor_rect.set(-96 + @max_char * 25 + @index * 28, 48, 28, 32)#16
      else
        self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28, 48, 28, 32)
      end
    else
      if @index < @max_char-1
        self.cursor_rect.set(-96 + @max_char * 25 + @index * 28 - width / 4, 48, 28, 32)#16
      else
        self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28 - width / 4, 48, 28, 32)
      end
    end
  end
  #--------------------------------------------------------------------------
  def update
    super
    if $scene.template == true
      bitmap = @bitmap
      cw = bitmap.width / 4
      ch = bitmap.height
      if @counter == @timing
        @counter = 0
        if @pattern == 3
          @pattern = 0
        else
          @pattern += 1
        end
        pt = @pattern
        src_rect = Rect.new(cw * pt, 0, cw, ch)
      else
        @counter += 1
        #if $scene.lockerinput.active
        #  Audio.se_play("Audio/SE/" + "032-Switch01", 70, 50)
        #elsif $scene.lc.active
        #  Audio.se_play("Audio/SE/" + "032-Switch01", 70, 50)
        #end
        #$game_system.se_play("032-Switch01")
        pt = @pattern
        src_rect = Rect.new(cw * pt, 0, cw, ch)
      end
      self.contents.blt(x - cw * 1.5, y - ch, bitmap, src_rect)
    end
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
end
class Window_LockerInstructions < Window_Base
  attr_accessor :text
  def initialize
    super(155,85,350,45)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 14
    @text = ""
    self.x = 320 - self.width / 2
    self.contents.draw_text(4, 0, width, 17, @text,1)
  end
  def set_text(text)
    self.contents.clear
    @text = text
    self.contents.draw_text(4, 0, width, 17, @text,1)
  end
end
class Window_LockerInput < Window_Base
  attr_reader   :name
  attr_reader   :index
  attr_accessor :max_char
  attr_accessor :face_frame
  #--------------------------------------------------------------------------
  def initialize(actor, max_char)
    super(155,130,350,200)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.x = 320 - self.width / 2
    #self.contents = Bitmap.new(width - 32, height - 32)
    #@actor = $game_party.actors[actor]
    @name = ""#@actor.name
    @max_char = max_char
    name_array = @name.split(//)[0...@max_char]
    @name = ""
    for i in 0...name_array.size
      @name += name_array[i]
    end
    @default_name = @name
    @index = name_array.size
    @sprite_size = 0 # 0 for small sprites, 1 for bigger sprites
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  def restore_default
    @name = @default_name
    @index = @name.split(//).size
    refresh
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  def add(character)
    if @index < @max_char and character != ""
      @name += character
      @index += 1
      refresh
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  def back
    if @index > 0
      name_array = @name.split(//)
      @name = ""
      for i in 0...name_array.size-1
        @name += name_array[i]
      end
      @index -= 1
      refresh
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    name_array = @name.split(//)
    for i in 0...@max_char
      c = name_array[i]
      if c == nil
        c = "_"
      end
      if $scene.template == true
        x = 320 - 16 * 14 + i * 28
      else
        x = 320 - 16 * 14 + i * 28 - width / 4
      end
      self.contents.draw_text(x, 49, 28, 32, c, 1)
    end
    #if @sprite_size == 0
    #  draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 92)
    #else
    #  draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 112)
    #end
  end
  def draw_locker_graphic
    @bitmap = 0
    if @bitmap != nil
      @bitmap = nil
    end
    #self.contents2.clear
    @bitmap = RPG::Cache.picture("locker")
    @timing = 4
    @counter = 0
    @pattern = 0
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if $scene.template == true
      if @index < @max_char-1
        self.cursor_rect.set(-96 + @max_char * 25 + @index * 28, 48, 28, 32)#16
      else
        self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28, 48, 28, 32)
      end
    else
      if @index < @max_char-1
        self.cursor_rect.set(-96 + @max_char * 25 + @index * 28 - width / 4, 48, 28, 32)#16
      else
        self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28 - width / 4, 48, 28, 32)
      end
    end
  end
  #--------------------------------------------------------------------------
  def update
    super
    if $scene.template == true
      bitmap = @bitmap
      cw = bitmap.width / 4
      ch = bitmap.height
      if @counter == @timing
        @counter = 0
        if @pattern == 3
          @pattern = 0
        else
          @pattern += 1
        end
        pt = @pattern
        src_rect = Rect.new(cw * pt, 0, cw, ch)
      else
        @counter += 1
        if $scene.se == true
          if $scene.lockerinput.active
            Audio.se_play("Audio/SE/" + $scene.sename, 70, 50)
          elsif $scene.lc.active
            Audio.se_play("Audio/SE/" + $scene.sename, 70, 50)
          end
        end
        #$game_system.se_play("032-Switch01")
        pt = @pattern
        src_rect = Rect.new(cw * pt, 0, cw, ch)
      end
      self.contents.blt(x - cw * 1.5, y - ch, bitmap, src_rect)
    end
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
end
class Scene_Load < Scene_File
  alias save_data read_save_data
  def read_save_data(file)
    save_data(file)
    $game_locker        = Marshal.load(file)
  end
end
class Scene_Save < Scene_File
  alias save_data write_save_data
  def write_save_data(file)
    save_data(file)
    Marshal.dump($game_locker, file)
  end
end
class Scene_Title
  alias newgame command_new_game
  def command_new_game
    newgame
    $game_locker = Game_Locker.new
  end
end

Code:
#==============================================================================
# Item Inventory
#--------------------------------------------------------------------------
# Created By SephirothSpawn (12.02.05)
# Last Updated: 12.02.05
#==============================================================================

#==============================================================================
# ** Window_RefreshCommand
#==============================================================================
class Window_RefreshCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
# Compute window height from command quantity
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(commands = @commands)
@commands = commands
@item_max = commands.size
if self.contents != nil
self.contents.dispose
self.contents = nil
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end

#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
attr_accessor :inventory_items
#--------------------------------------------------------------------------
# * Alias Initialization
#--------------------------------------------------------------------------
alias inventory_int initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
inventory_int
@inventory_items = []
end
#--------------------------------------------------------------------------
# * Move to Inventory
#--------------------------------------------------------------------------
def move_to_inventory(type, item_id)
case type
when 0
@inventory_items.push($data_items[item_id])
lose_item(item_id, 1)
when 1
@inventory_items.push($data_weapons[item_id])
lose_weapon(item_id, 1)
when 2
@inventory_items.push($data_armors[item_id])
lose_armor(item_id, 1)
end
update_inventory
end
#--------------------------------------------------------------------------
# * Remove from Inventory
#--------------------------------------------------------------------------
def remove_from_inventory(index)
item = @inventory_items[index]
@inventory_items.delete_at(index)
case item
when RPG::Item
gain_item(item.id, 1)
when RPG::Weapon
gain_weapon(item.id, 1)
when RPG::Armor
gain_armor(item.id, 1)
end
update_inventory
end
#--------------------------------------------------------------------------
# * Update Inventory
#--------------------------------------------------------------------------
def update_inventory
items, weapons, armors = [], [], []
for item in @inventory_items
case item
when RPG::Item
items.push(item)
when RPG::Weapon
weapons.push(item)
when RPG::Armor
armors.push(item)
end
end
items.sort! {|a, b| a.name<=>b.name}
weapons.sort! {|a, b| a.name<=>b.name}
armors.sort! {|a, b| a.name<=>b.name}
@inventory_items.clear
@inventory_items << items << weapons << armors
@inventory_items.flatten!
end
end

#==============================================================================
# ** Scene_Inventory_Items
#==============================================================================
class Scene_Inventory_Items
  attr_accessor :template
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
  @template = false
# Make sprite set
@spriteset = Spriteset_Map.new
# Help Window
@help_window = Window_Help.new
@help_window.set_text("Select Item to Transfer", 1)
@help_window.opacity = 175
# Items Window
@items_window = Window_RefreshCommand.new(272, get_item_commands)
@items_window.x, @items_window.y = 32, 80
@items_window.opacity = 175
@items_window.height = 384
# Inventory Window
@inventory_window = Window_RefreshCommand.new(272, get_inventory_commands)
@inventory_window.x, @inventory_window.y = 336, 80
@inventory_window.opacity = 175
@inventory_window.height = 384
@inventory_window.active = false
# Scene Objects
@objects = [@spriteset, @help_window, @items_window, @inventory_window]
@cmd_windows = [@items_window, @inventory_window]
# Transition run
Graphics.transition
# Main loop
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Updates Objects
@objects.each {|x| x.update unless x == @items_window || x == @inventory_window}
@cmd_windows.each {|x| x.update if x.active}
# Frame update
update
end
# Prepare for transition
Graphics.freeze
# Disposes Objects
@objects.each {|x| x.dispose}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Updates Help Window
if @items_window.active
@help_window.set_text("Select Item to Transfer", 1)
else
@help_window.set_text("Select Item to Withdraw", 1)
end
# Return to Map
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
elsif Input.trigger?(Input::L) || Input.trigger?(Input::R) ||
Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
@items_window.active = @items_window.active ? false : true
@inventory_window.active = @inventory_window.active ? false : true
elsif Input.trigger?(Input::C)
if @items_window.active
item = @commands[@items_window.index]
if item == "Back"
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
else
$game_system.se_play($data_system.decision_se)
case item
when RPG::Item
type = 0
when RPG::Weapon
type = 1
else
type = 2
end
$game_party.move_to_inventory(type, item.id)
@items_window.refresh(get_item_commands)
@inventory_window.refresh(get_inventory_commands)
end
else
if @inventory_window.index == @inventory_size - 1
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
else
$game_party.remove_from_inventory(@inventory_window.index)
@items_window.refresh(get_item_commands)
@inventory_window.refresh(get_inventory_commands)
end
end
end
end
#--------------------------------------------------------------------------
# * Get Item Commands
#--------------------------------------------------------------------------
def get_item_commands
# Commands For Command Window
commands = []
$game_party.items.each_key {|item| $game_party.items[item].times {commands.push($data_items[item].name)}}
$game_party.weapons.each_key {|item| $game_party.weapons[item].times {commands.push($data_weapons[item].name)}}
$game_party.armors.each_key {|item| $game_party.armors[item].times {commands.push($data_armors[item].name)}}
commands.push("Back")
# Commands For Selecting
@commands = []
$game_party.items.each_key {|item| $game_party.items[item].times {@commands.push($data_items[item])}}
$game_party.weapons.each_key {|item| $game_party.weapons[item].times {@commands.push($data_weapons[item])}}
$game_party.armors.each_key {|item| $game_party.armors[item].times {@commands.push($data_armors[item])}}
@commands.push("Back")
return commands
end
#--------------------------------------------------------------------------
# * Get Inventory Commands
#--------------------------------------------------------------------------
def get_inventory_commands
commands = []
$game_party.inventory_items.each {|item| commands.push(item.name)}
commands.push("Back")
@inventory_size = commands.size
return commands
end
end

Thanks for the help in advance. :thumb:

Please always place code in code tags and spoilers, thank you. Arbiter~
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top