Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Sell Shop
#1
Simple Sell Shop

Leon Blade
Dec 16, 2006

This is a locked, single-post thread from Creation Asylum.  Archived here to prevent its loss.
No support is given.  If you are the owner of the thread, please contact administration.


Hello this is Leon and I got a simple Sell Shop script without needing SDK. Now I dont know if there already is one. But im posting it anyway just so more people can here about it.

Below is the sell shop command window... place this above main...
Code:
#====================================================================
# ■ Window_ShopCommand2
#------------------------------------------------------------------------------
#  ショップ画面で、用件を選択するウィンドウです。
#====================================================================

class Window_ShopCommand2 < Window_Selectable
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 480, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype  # "Shop Commands" window font
    self.contents.font.size = $defaultfontsize
    @item_max = 2
    @column_max = 2
    @commands = ["Sell", "Leave"]
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    x = 4 + index * 240
    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  end
end

Then after that paste this below ShopCommand2 and above Main...

Code:
#====================================================================
# ■ Scene_Sell_Shop
#------------------------------------------------------------------------------
#  ショップ画面の処理を行うクラスです。
#====================================================================

class Scene_Sell_Shop
  #--------------------------------------------------------------------------
  # ● メイン処理
  #--------------------------------------------------------------------------
  def main
    # ヘルプウィンドウを作成
    @help_window = Window_Help.new
    # コマンドウィンドウを作成
    @command_window = Window_ShopCommand2.new
    # ゴールドウィンドウを作成
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
    # ダミーウィンドウを作成
    @dummy_window = Window_Base.new(0, 128, 640, 352)
    # 売却ウィンドウを作成
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
    # 個数入力ウィンドウを作成
    @number_window = Window_ShopNumber.new
    @number_window.active = false
    @number_window.visible = false
    # ステータスウィンドウを作成
    @status_window = Window_ShopStatus.new
    @status_window.visible = false
    # トランジション実行
    Graphics.transition
    # メインループ
    loop do
      # ゲーム画面を更新
      Graphics.update
      # 入力情報を更新
      Input.update
      # フレーム更新
      update
      # 画面が切り替わったらループを中断
      if $scene != self
        break
      end
    end
    # トランジション準備
    Graphics.freeze
    # ウィンドウを解放
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @sell_window.dispose
    @number_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    # ウィンドウを更新
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @sell_window.update
    @number_window.update
    @status_window.update
    # コマンドウィンドウがアクティブの場合: update_command を呼ぶ
    if @command_window.active
      update_command
      return
    end
    # 売却ウィンドウがアクティブの場合: update_sell を呼ぶ
    if @sell_window.active
      update_sell
      return
    end
    # 個数入力ウィンドウがアクティブの場合: update_number を呼ぶ
    if @number_window.active
      update_number
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (コマンドウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_command
    # B ボタンが押された場合
    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 @command_window.index
      when 0  # 売却する
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # ウィンドウの状態を売却モードへ
        @command_window.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
      when 1  # やめる
        # 決定 SE を演奏
        $game_system.se_play($data_system.decision_se)
        # マップ画面に切り替え
        $scene = Scene_Map.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (売却ウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_sell
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # ウィンドウの状態を初期モードへ
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.item = nil
      # ヘルプテキストを消去
      @help_window.set_text("")
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # アイテムを取得
      @item = @sell_window.item
      # ステータスウィンドウのアイテムを設定
      @status_window.item = @item
      # アイテムが無効の場合、または価格が 0 (売却不可) の場合
      if @item == nil or @item.price == 0
        # ブザー SE を演奏
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # 決定 SE を演奏
      $game_system.se_play($data_system.decision_se)
      # アイテムの所持数を取得
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end
      # 最大売却個数 = アイテムの所持数
      max = number
      # ウィンドウの状態を個数入力モードへ
      @sell_window.active = false
      @sell_window.visible = false
      @number_window.set(@item, max, @item.price / 2)
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 (個数入力ウィンドウがアクティブの場合)
  #--------------------------------------------------------------------------
  def update_number
    # B ボタンが押された場合
    if Input.trigger?(Input::B)
      # キャンセル SE を演奏
      $game_system.se_play($data_system.cancel_se)
      # 個数入力ウィンドウを非アクティブ・不可視に設定
      @number_window.active = false
      @number_window.visible = false
      # コマンドウィンドウのカーソル位置で分岐
      case @command_window.index
      when 0  # 売却する
        # ウィンドウの状態を売却モードへ
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      end
      return
    end
    # C ボタンが押された場合
    if Input.trigger?(Input::C)
      # ショップ SE を演奏
      $game_system.se_play($data_system.shop_se)
      # 個数入力ウィンドウを非アクティブ・不可視に設定
      @number_window.active = false
      @number_window.visible = false
      # コマンドウィンドウのカーソル位置で分岐
      case @command_window.index
      when 0 # 売却する
        # 売却処理
        $game_party.gain_gold(@number_window.number * (@item.price / 2))
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
        end
        # 各ウィンドウをリフレッシュ
        @gold_window.refresh
        @sell_window.refresh
        @status_window.refresh
        # ウィンドウの状態を売却モードへ
        @sell_window.active = true
        @sell_window.visible = true
        @status_window.visible = false
      end
      return
    end
  end
end

There you go now to open the sell shop put this line of code in a call script command in an event...

Code:
$scene = Scene_Sell_Shop.new
Like I said I'm not sure if anyone has made this or not but im posting it anyway...
You don't need to give any credit...

Leon Blade
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Beastary! bchimself 0 2,415 07-01-2007, 01:00 PM
Last Post: bchimself
  FFTA Shop Menu Chrono Cry 0 2,117 04-25-2007, 01:00 PM
Last Post: Chrono Cry



Users browsing this thread: