RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

I Found Storage Script !

Started by akuya, January 03, 2010, 12:46:55 AM

0 Members and 1 Guest are viewing this topic.

akuya

I found storage or warehouse script

#==============================================================================
# Vampyr Warehouse
#==============================================================================
class Game_Party < Game_Unit
 
  alias vampyr_warehouse_initialize initialize
 
  attr_reader :wgold
 
  def initialize
    vampyr_warehouse_initialize
    @witems = {}
    @wweapons = {}
    @warmors = {}
    @wgold = 0
  end
 
  def witems
    result = []
    for i in @witems.keys.sort
      result.push($data_items[i]) if @witems[i] > 0
    end
    for i in @wweapons.keys.sort
      result.push($data_weapons[i]) if @wweapons[i] > 0
    end
    for i in @warmors.keys.sort
      result.push($data_armors[i]) if @warmors[i] > 0
    end
    return result
  end
 
  def store_gold(n)
    @wgold = [[@wgold + n, 0].max, 9999999].min
  end

  def withdraw_gold(n)
    store_gold(-n)
  end
 
  def witem_number(item)
    case item
    when RPG::Item
      number = @witems[item.id]
    when RPG::Weapon
      number = @wweapons[item.id]
    when RPG::Armor
      number = @warmors[item.id]
    end
    return number == nil ? 0 : number
  end
 
  def store_item(item, n)
    number = witem_number(item)
    case item
    when RPG::Item
      @witems[item.id] = [[number + n, 0].max, 99].min
    when RPG::Weapon
      @wweapons[item.id] = [[number + n, 0].max, 99].min
    when RPG::Armor
      @warmors[item.id] = [[number + n, 0].max, 99].min
    end
    n += number
  end

  def withdraw_item(item, n)
    store_item(item, -n)
  end
 
end

#------------------------------------------------------------------------------
class Window_Warehouse < Window_Selectable
 
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @column_max = 2
    self.index = 0
    refresh
  end
 
  def item
    return @data[self.index]
  end
 
  def refresh
    @data = []
    $game_party.witems.each { |i| @data.push(i) }
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
 
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      number = $game_party.witem_number(item)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y)
      self.contents.draw_text(rect, sprintf(":%2d", number), 2)
    end
  end
 
  def update_help
    if $scene.is_a?(Scene_VampyrWarehouse) and $scene.description_delay > 0
      @help_window.set_text("Item Retirado!")
    else
      @help_window.set_text(item == nil ? "" : item.description)
    end
  end
 
end

#------------------------------------------------------------------------------
class Window_Item < Window_Selectable
 
  def update_help
    if $scene.is_a?(Scene_VampyrWarehouse) and $scene.description_delay > 0
      @help_window.set_text("Item Depositado!")
    else
      @help_window.set_text(item == nil ? "" : item.description)
    end
  end
 
end

#------------------------------------------------------------------------------
class Window_MyGold < Window_Base
 
  def initialize
    super(0, 0, 256, 56)
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(contents.rect, "Meu #{Vocab.gold}:")
    self.contents.font.color = normal_color
    self.contents.draw_text(contents.rect, $game_party.gold, 2)
  end
 
end

#------------------------------------------------------------------------------
class Window_WareGold < Window_Base
 
  def initialize
    super(0, 0, 256, 56)
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(contents.rect, "#{Vocab.gold} do Baú:")
    self.contents.font.color = normal_color
    self.contents.draw_text(contents.rect, $game_party.wgold, 2)
  end
 
end

#------------------------------------------------------------------------------
class Window_TypeGold < Window_Command
 
  attr_reader :value
  attr_reader :commands
 
  def initialize
    super(256, ["0", "0", "0", "0", "0", "0", "0"], 7, 0, 0)
    @index = 6
  end
 
  def reset
    for i in 0...@commands.size
      @commands[i] = "0"
    end
    refresh
  end
 
  def update
    super
    value = @commands[@index].to_i
    if Input.press?(Input::UP) and Graphics.frame_count % 7 <= 0
      Sound.play_cursor
      @commands[@index] = (value < 9 ? value+1 : 9).to_s
      refresh
    elsif Input.press?(Input::DOWN) and Graphics.frame_count % 7 <= 0
      Sound.play_cursor
      @commands[@index] = (value > 0 ? value-1 : 0).to_s
      refresh
    end
  end
 
end

#------------------------------------------------------------------------------
class Scene_VampyrWarehouse < Scene_Base
 
  attr_reader :description_delay
 
  def start
    super
    create_menu_background
    @description_delay = 0
    @store_gold = false
    @withdraw_gold = false
    s1 = "Depositar Itens "
    s2 = "Retirar Itens"
    s3 = "Depositar Dinheiro"
    s4 = "Retirar Dinheiro"
    s5 = "Cancelar"
    @command_window = Window_Command.new(208, [s1, s2, s3, s4, s5])
    @command_window.x = (544-@command_window.width)/2
    @command_window.y = (416-@command_window.height)/2
    @command_window.visible = @command_window.active = true
    @help_window = Window_Help.new
    @help_window.visible = @help_window.active = false
    @item_window = Window_Item.new(0, 56, 544, 360)
    @item_window.help_window = @help_window
    @item_window.visible = @item_window.active = false
    @warehouse_window = Window_Warehouse.new(0, 56, 544, 360)
    @warehouse_window.help_window = @help_window
    @warehouse_window.visible = @warehouse_window.active = false
    @typegold_window = Window_TypeGold.new
    @typegold_window.x = (544-@typegold_window.width)/2
    @typegold_window.y = ((416-@typegold_window.height)/2)
    @typegold_window.visible = @typegold_window.active = false
    @mygold_window = Window_MyGold.new
    @mygold_window.visible = @mygold_window.active = false
    @mygold_window.x = (544-@mygold_window.width)/2
    @mygold_window.y = ((416-@mygold_window.height)/2)-56
    @waregold_window = Window_WareGold.new
    @waregold_window.visible = @waregold_window.active = false
    @waregold_window.x = (544-@waregold_window.width)/2
    @waregold_window.y = ((416-@waregold_window.height)/2)+56
  end
 
  def update
    super
    update_menu_background
    @description_delay -= 1 if @description_delay > 0
    @command_window.update
    @item_window.update
    @warehouse_window.update
    @help_window.update
    @mygold_window.update
    @waregold_window.update
    @typegold_window.update if @typegold_window.active
    if @command_window.active
      update_selection
    elsif @item_window.active
      update_store
    elsif @warehouse_window.active
      update_whitedraw
    elsif @typegold_window.active and @store_gold
      update_store_gold
    elsif @typegold_window.active and @withdraw_gold
      update_whitdraw_gold
    end
  end
 
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @item_window.dispose
    @warehouse_window.dispose
    @help_window.dispose
    @typegold_window.dispose
    @mygold_window.dispose
    @waregold_window.dispose
  end
 
  def update_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @command_window.visible = @command_window.active = false
      case @command_window.index
      when 0
        @item_window.visible = @item_window.active = true
        @help_window.visible = @help_window.active = true
        @warehouse_window.visible = @warehouse_window.active = false
      when 1
        @item_window.visible = @item_window.active = false
        @help_window.visible = @help_window.active = true
        @warehouse_window.visible = @warehouse_window.active = true
      when 2
        @store_gold = true
        @withdraw_gold = false
        @typegold_window.visible = @typegold_window.active = true
        @mygold_window.visible = @mygold_window.active = true
        @waregold_window.visible = @waregold_window.active = true
      when 3
        @store_gold = false
        @withdraw_gold = true
        @typegold_window.visible = @typegold_window.active = true
        @mygold_window.visible = @mygold_window.active = true
        @waregold_window.visible = @waregold_window.active = true
      when 4
        $scene = Scene_Map.new
      end
    end
  end
 
  def update_store
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @item_window.visible = @item_window.active = false
      @help_window.visible = @help_window.active = false
      @command_window.visible = @command_window.active = true
    elsif Input.trigger?(Input::C)
      if @item_window.item == nil
        Sound.play_buzzer
      elsif @item_window.item.note.include?("Dont't Store")
        Sound.play_buzzer
      else
        Sound.play_decision
        $game_party.lose_item(@item_window.item, 1)
        $game_party.store_item(@item_window.item, 1)
        @item_window.refresh
        @warehouse_window.refresh
        @description_delay = 90
      end
    end
  end
 
  def update_whitedraw
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @warehouse_window.visible = @warehouse_window.active = false
      @help_window.visible = @help_window.active = false
      @command_window.visible = @command_window.active = true
    elsif Input.trigger?(Input::C)
      if @warehouse_window.item == nil
        Sound.play_buzzer
      else
        Sound.play_decision
        $game_party.gain_item(@warehouse_window.item, 1)
        $game_party.withdraw_item(@warehouse_window.item, 1)
        @item_window.refresh
        @warehouse_window.refresh
        @description_delay = 90
      end
    end
  end
 
  def update_store_gold
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @typegold_window.visible = @typegold_window.active = false
      @typegold_window.reset
      @mygold_window.visible = @mygold_window.active = false
      @waregold_window.visible = @waregold_window.active = false
      @command_window.visible = @command_window.active = true
    elsif Input.trigger?(Input::C)
      return if @typegold_window.commands.to_s.to_i <= 0
      if $game_party.gold < @typegold_window.commands.to_s.to_i
        Sound.play_buzzer
      else
        Sound.play_shop
        $game_party.lose_gold(@typegold_window.commands.to_s.to_i)
        $game_party.store_gold(@typegold_window.commands.to_s.to_i)
        @mygold_window.refresh
        @waregold_window.refresh
      end
    end
  end
 
  def update_whitdraw_gold
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @typegold_window.visible = @typegold_window.active = false
      @typegold_window.reset
      @mygold_window.visible = @mygold_window.active = false
      @waregold_window.visible = @waregold_window.active = false
      @command_window.visible = @command_window.active = true
    elsif Input.trigger?(Input::C)
      return if @typegold_window.commands.to_s.to_i <= 0
      if $game_party.wgold < @typegold_window.commands.to_s.to_i
        Sound.play_buzzer
      else
        Sound.play_shop
        $game_party.withdraw_gold(@typegold_window.commands.to_s.to_i)
        $game_party.gain_gold(@typegold_window.commands.to_s.to_i)
        @mygold_window.refresh
        @waregold_window.refresh
      end
    end
  end
 
end

But i don't know how to used it please help me  ;D

A B C D E F G H I J K ..... And after that .........
L .... M .... N .... O P.... hey !


What do you read !?

Grafikal

I actually saw this as well and it came with no instructions either. I can't help you, but maybe someone else can.

Falcon

#2
Well, for starters, you may want it translated to English, unless you want the commands in Spanish.

Try
$scene = Scene_VampyrWarehouse.new

ldkraven

#3
Just tried that and it didn't work. This does though:

$game_warehouse.open


Sorry i was using the one for net gaming. >.<

akuya

A B C D E F G H I J K ..... And after that .........
L .... M .... N .... O P.... hey !


What do you read !?

nemrog

Sorry for NecroPosting.

This Evented Bank Link has an Interest / Loan System. Does any one know how to Implement that to this? I've been trying to Carve out the Bank Event, I can't seem to get the Interest Rate to take a hold.

Basically this is what I want in a Bank System, but it's missing the ability to Gain Interest in the Bank Version of the Script. And giving out Loans would be epic.