The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: Seiryuki on April 30, 2011, 08:51:20 PM

Title: Enelvon/Seiryuki Sell-Only Shop Script
Post by: Seiryuki on April 30, 2011, 08:51:20 PM
Sell-Only Shop Script
Version: 1.0
Author: Enelvon/Seiryuki
Date: 2011/04/30

Version History


Version 1.0: 2011.04.30 - only version so far

Planned Future Versions

No plans yet.

Description


This script allows for sell-only shops by disabling the "buy" option. My intention was to combine that feature with Mithran's LimitShopBuy (http://www.rpgmakervx.net/index.php?showtopic=18021&st=0&p=155988&#entry155988) script to create a shop that would only buy certain items from your party's inventory whilst hiding all other items. E.g. Using both scripts, a Loot shop would have the ability to buy Loot, and only Loot, from your party's inventory and would be unable to sell Loot back to you.

Features

Check the instructions in the script for an example on how to easily create a sell-only shop. Using that example makes it easy to run buy/sell shops, buy-only shops and sell-only shops without problems.

Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.mediafire.com%2Fimgbnc.php%2Fc4e5d0cb47dd2432b2f6df4fbab580ad2f48ee6e9c8277d5cd46130897138cd06g.jpg&hash=bc959c6a9aa3bb883cd43173e2d94ddf639a9dc2)
    Notice the "Buy" option disabled. This screenshot was also taken with Mithran's LimitShopBuy script ON.

Instructions

      Uses the Script command in an event:
       To make your shops sell-only:
         $game_temp.shop_sell_only = true

       To undo it, use this:
         $game_temp.shop_sell_only = false

Script


Code: [Select]
###############################################################################
###############################################################################
# ~~~~~~~~~~~~~~~~~~~~~~SELL-ONLY SHOP SCRIPT v1.0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~by Enelvon~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~concept, assistance by Seiryuki~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~Last Update: 2011.04.30~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# site: rpgmakervx.net~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# post: http://www.rpgmakervx.net/index.php?showtopic=45007~~~~~~~~~~~~~~~~~~~~
###############################################################################
# This script allows you to have shops that can only sell items by disabling
# the "Buy" option. Remember, you must enter at least one item to create the
# shop.
###############################################################################
#------------------------------------------------------------------------------
# COMPATIBILITY:
# This script is compatible with Mithran's LimitShopBuy script.
# This script has not been tested with other shop scripts.
#------------------------------------------------------------------------------
# INSTRUCTIONS:
# Place this script above Main and above any other scripts that modify the
# command window of Scene_Shop.
# Rather than using a switch, this uses a script command in an event.
#
#   To make your shops sell-only:
#     $game_temp.shop_sell_only = true
#
#   To undo it, use this:
#     $game_temp.shop_sell_only = false
#
#------------------------------------------------------------------------------
# EXAMPLE OF A SELL-ONLY SHOP EVENT:
#
# @> Script: $game_temp.shop_sell_only = true
# @> Shop Processing: [Potion]
# :                 : [Hi-Potion]
# @> Script: $game_temp.shop_sell_only = false
#
#------------------------------------------------------------------------------
###############################################################################
###############################################################################

class Game_Temp
  attr_accessor :shop_sell_only
  alias enelvon_seiryuki_temp_init initialize
  def initialize
    enelvon_seiryuki_temp_init
    @shop_sell_only = false
  end
end

class Scene_Shop < Scene_Base

  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  alias enelvon_seiryuki_shop_window create_command_window
    def create_command_window
      enelvon_seiryuki_shop_window
      if $game_temp.shop_sell_only
       @command_window.draw_item(0, false)
      end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0 # buy
        if $game_temp.shop_sell_only
          Sound.play_buzzer
        else
          Sound.play_decision
          @command_window.active = false
          @dummy_window.visible = false
          @buy_window.active = true
          @buy_window.visible = true
          @buy_window.refresh
          @status_window.visible = true
        end
      when 1 # sell
        if $game_temp.shop_purchase_only
          Sound.play_buzzer
        else
          Sound.play_decision
          @command_window.active = false
          @dummy_window.visible = false
          @sell_window.active = true
          @sell_window.visible = true
          @sell_window.refresh
        end
      when 2 # Quit
        Sound.play_decision
        $scene = Scene_Map.new
      end
    end
  end
end
#END OF SCRIPT

Credit



Thanks

Thanks to Enelvon (rpgmakervx.net) for the prompt assistance in getting my idea into code.

Support


Send me a PM and I'll try my best to assist.

Known Compatibility Issues

This code should be compatible with scripts that do not modify the command window for Scene_Shop. I haven't tested this script with any custom shop scripts.

Demo


I see no need to release a demo as the script is really easy to setup and use. However, if problems occur and a demo is needed, I will do up one.

Author's Notes


Do not forget that you can not create a shop without entering at least one item to be sold by the shop, even if the shop would not be selling anything. In any case, you would be forced to enter an item when creating the shop.

Restrictions

Do not post this script in any other forum. If you must share the script, link to this topic or to the one at this link: http://www.rpgmakervx.net/index.php?showtopic=45007 (http://www.rpgmakervx.net/index.php?showtopic=45007)
If using this script in either commercial games, please credit Enelvon and Seiryuki.
Feel free to modify the code if you got ideas; but I'd love to see it so post it here.
Title: Re: Enelvon/Seiryuki Sell-Only Shop Script
Post by: yuyu! on April 30, 2011, 09:17:03 PM
Great job! +rep

I tested it out and it works wells! Very easy to use. :)
Title: Re: Enelvon/Seiryuki Sell-Only Shop Script
Post by: pacdiggity on May 01, 2011, 07:10:47 AM
A very neat idea for a simple script. Nice job.
I was gonna make this script, actually. Great.