- Joined
- Jul 14, 2012
- Messages
- 231
- Reaction score
- 61
- First Language
- English
- Primarily Uses
- RMMV
Translated by: Lankaino
IntroductionA custom shop that uses visual images to look fancy.
Features
- Easy to use.
- Allows you to have full body portrait NPC shops.
- Allows you to have NPC bubble dialogues.
Screenshots
How to Use
Place the script above main and below everything else.
Requires images from Demo. System/Graphics
English Demo / Improved Instructions
Direct Link
Script
#==============================================================================# Scene_Shop# Made by: Mepps | Luky Maker# Release: 9/15/2013# ~ ~ Translated 9/29/2013# ~ ~ ~ Translated by: Levi Stepp## Visit www.arquivosnerd1.wordpress.oom# Visit www.realmrgsstudios.weebly.com/index.html#==============================================================================# Module Animations# RegularExpression REGXP...module MeppsANIMATED_EXP = [] # Don't TouchANIMATED_EXP[0] = ["RegularExpression1"] # Don't Touchend # Don't Touch#=============================================================================## - - - BEGIN CUSTOMIZATION - - - ##=============================================================================## Set as default shop keeper portrait.# "Shop Keeper" <- Name of the image in Graphics/System $clerk_image = "Shop Keeper" # Default Image when no script calls.# SCROLL TO THE VERY BOTTOM, If you want to edit the "Dialogue Text"# during the shop scene.#=============================================================================## - - - END CUSTOMIZATION - - - ## - - - DO NOT EDIT PASS HERE UNLESS YOU KNOW WHAT YOU'RE DOING! - - - ##=============================================================================## Scene Shopclass Scene_Shop < Scene_MenuBase# Main Processdef start;supercreate_imagecreate_message_windowcreate_gold_windowcreate_help_windowcreate_command_windowcreate_false_windowcreate_numericalcreate_status_windowcreate_purchase_windowcreate_category_windowcreate_sale_windowend# Creates the shop keeper image.def create_image # Don't touch # Background@background = Plane::new@background.bitmap = Cache.system(%Q<background>)@background.opacity = 255# Top Border@border1 = Sprite::new@border1.bitmap = Cache.system(%Q<Border1>)@border1.opacity = 180# Bottom Border @border2 = Sprite::new@border2.bitmap = Cache.system(%Q<Border2>)@border2.opacity = 180bottom_edge(@border2)# Clerk Image (Shop Keeper)@clerk = Sprite::new@clerk.bitmap = Cache.system($clerk_image)@clerk.mirror = -1image_left(@clerk)# Item Background@item_background = Sprite::new@item_background.bitmap = Cache.system(%Q<items>)@item_background.opacity = 180@item_background.z = 1item_bg1(@item_background)# Status Background@item_background2 = Sprite::new@item_background2.bitmap = Cache.system(%Q<item2>)@item_background2.opacity = 180@item_background2.z = 1item_bg2(@item_background2)# Sell Border@sell_border = Sprite::new@sell_border.bitmap = Cache.system(%Q<BorderSell>)@sell_border.opacity = 180@sell_border.z = 1sell_fund(@sell_border)# Message@message = Sprite::new@message.bitmap = Cache.system(%Q<Message>)bottom_of_message(@message)@message.opacity = 180end# Preparedef prepare(goods, purchase_only)@goods = goods; @purchase_only = purchase_onlyenddef central_sprite(sprite)sprite.ox = sprite.bitmap.width / 2sprite.oy = sprite.bitmap.height / 2sprite.x = Graphics.width / 2sprite.y = Graphics.height / 2enddef bottom_edge(sprite)sprite.oy = sprite.bitmap.height - 2sprite.y = Graphics.height - 2enddef image_left(sprite)#sprite.x = Graphics.width / 40sprite.y = Graphics.height - 350enddef item_bg1(sprite)sprite.ox = sprite.bitmap.width / 2sprite.x = Graphics.width - 127#sprite.oy = sprite.bitmap.height + 100sprite.y = Graphics.height - 385enddef item_bg2(sprite)sprite.ox = sprite.bitmap.width / 2sprite.x = Graphics.width - 127#sprite.oy = sprite.bitmap.height + 100sprite.y = Graphics.height - 295enddef sell_fund(sprite)sprite.ox = sprite.bitmap.width / 2sprite.x = Graphics.width - 395sprite.oy = sprite.bitmap.height / 2sprite.y = Graphics.height - 44enddef bottom_of_message(sprite)sprite.ox = sprite.bitmap.width / 2sprite.x = Graphics.width - 380sprite.oy = sprite.bitmap.height / 2sprite.y = Graphics.height - 140end# Animated Backgrounddef updatesuper@background.ox += 1enddef dispose_background@background.dispose@border1.dispose@border2.dispose@clerk.dispose@item_background.dispose@item_background2.dispose@sell_border.dispose@message.disposeend # Create Window Commands# Buy = Purchase# Sell = Sell# Cancel = Canceldef create_command_window@command_window = Command_Window::new(@gold_window.x, @purchase_only)@command_window.viewport = @viewport@command_window.x = @help_window.height@command_window.set_handler
buy, method
command_buy))@command_window.set_handler
sell, method
command_sell))@command_window.set_handler
cancel, method
return_scene))enddef create_false_windowwy = @command_window.y + @command_window.heightwh = Graphics.height - wy@dummy_window = Window_Base::new(0, wy, Graphics.width, wh)@dummy_window.opacity = 0@dummy_window.viewport = @viewportenddef create_numericalwy = @dummy_window.ywh = @dummy_window.height@number_window = Window_Shop_Numero.new(0, wy, wh)@number_window.viewport = @viewport@number_window.hide@number_window.set_handler
ok, method
on_number_ok))@number_window.set_handler
cancel, method
on_number_cancel))end def create_status_windowwx = @number_window.widthwy = @dummy_window.yww = Graphics.width - wxwh = @dummy_window.height@status_window = Window_Shop_Status.new(wx,wy,ww,wh)@status_window.viewport = @viewport@status_window.hide@status_window.z = 1enddef create_purchase_windowwy = @dummy_window.ywh = @dummy_window.height@buy_window = Window_Shop_De_Compra.new(0, wy, wh, @goods)@buy_window.opacity = 0@buy_window.viewport = @viewport@buy_window.help_window = @help_window@buy_window.status_window = @status_window@buy_window.hide@buy_window.set_handler
ok, method
on_buy_ok))@buy_window.set_handler
cancel, method
on_buy_cancel))@buy_window.z = 1enddef create_category_window@category_window = Category_Window.new@category_window.viewport = @viewport@category_window.help_window = @help_window@help_window.opacity = 0@category_window.y = 350@category_window.x = + 0@category_window.hide.deactivate@category_window.set_handler
ok, method
on_category_ok))@category_window.set_handler
cancel, method
on_category_cancel))end def create_sale_windowwy = @category_window.y + @category_window.heightwh = Graphics.height - wy@sell_window = Window_Shop_Venda::new(0, wy, Graphics.width, wh)@sell_window.viewport = @viewport@sell_window.help_window = @help_window@help_window.opacity = 0@sell_window.hide@sell_window.set_handler
ok, method
on_sell_ok))@sell_window.set_handler
cancel, method
on_sell_cancel))@category_window.item_window = @sell_windowenddef activate_buy_window@buy_window.money = money@buy_window.show.activate@status_window.showenddef activate_sell_window@category_window.show@sell_window.refresh@sell_window.show.activate@status_window.hideend#=============================================================================# * Commands#=============================================================================def command_buy@dummy_window.hideactivate_buy_windowenddef command_sell@dummy_window.hide@category_window.show.activate@sell_window.show@sell_window.unselect@sell_window.refreshenddef on_buy_ok@item = @buy_window.item@buy_window.hide@number_window.set(@item, max_buy, buying_price, currency_unit)@number_window.show.activateend def on_buy_cancel@command_window.activate@dummy_window.show@buy_window.hide@status_window.hide@status_window.item = nil@help_window.clearend def on_category_okactivate_sell_window@sell_window.select(0)end def on_category_cancel@command_window.activate@dummy_window.show@category_window.hide@sell_window.hideenddef on_sell_ok@item = @sell_window.item@status_window.item = @item@category_window.hide@sell_window.hide@number_window.set(@item, max_sell, selling_price, currency_unit)@number_window.show.activate@status_window.showend def on_sell_cancel@sell_window.unselect@category_window.activate@status_window.item = nil@help_window.clearenddef on_number_okSound.play_shopcase @command_window.current_symbolwhen :buydo_buy(@number_window.number)when :selldo_sell(@number_window.number)endend_number_input@gold_window.refresh@status_window.refreshend def on_number_cancelSound.play_cancelend_number_inputend def do_buy(number)$game_party.lose_gold(number * buying_price)$game_party.gain_item(@item, number)enddef do_sell(number)$game_party.gain_gold(number * selling_price)$game_party.lose_item(@item, number)enddef end_number_input@number_window.hidecase @command_window.current_symbolwhen :buyactivate_buy_windowwhen :sellactivate_sell_windowendend def max_buymax = $game_party.max_item_number(@item) - $game_party.item_number(@item)buying_price == 0 ? max : [max, money / buying_price].minend def max_sell$game_party.item_number(@item)end def money@gold_window.valueend def currency_unit@gold_window.currency_unitend def buying_price@buy_window.price(@item)end def selling_price@item.price / 2end#=============================================================================# * Create Windows#=============================================================================def create_help_window@help_window = Janela_De_Ajuda::new@help_window.viewport = @viewportenddef create_gold_window@gold_window = Janela_De_Dinheiro::newend;enddef create_message_window@message_window = RNT::newend#=============================================================================# * Create Gold Windows#=============================================================================class Janela_De_Dinheiro < Window_Base def initializesuper(360,-10,200,200)self.opacity = 0refreshenddef refreshself.contents.clearcontents.cleardraw_icon(260, 140, -2)draw_currency_value(value, currency_unit, -34, 0, contents.width - 8)end def value$game_party.goldend def currency_unitVocab::currency_unitend def openrefreshsuper;end;end#=============================================================================# * Help Window#=============================================================================class Janela_De_Ajuda < Window_Base def initialize(line_number = 2)super(0, -10, Graphics.width, fitting_height(line_number))self.opacity = 255end def set_text(text)if text != @text@text = textrefreshend;end def clearset_text("")end def set_item(item)set_text(item ? item.description : "")end def refreshcontents.cleardraw_icon(140,-2,0)draw_text_ex(30, 0, @text)end;end#=============================================================================# * Window_ShopCommand#=============================================================================#(-10,378) Baseclass Command_Window < Window_HorzCommand def initialize(window_width, purchase_only)@window_width = window_width@window_height = window_height@purchase_only = purchase_onlysuper(-0,378)self.opacity = 0end def window_width@window_widthend def col_maxreturn 3end def make_command_listadd_command(Vocab::ShopBuy, :buy)add_command(Vocab::ShopSell, :sell, !@purchase_only)add_command(Vocab::ShopCancel, :cancel)end;end#=============================================================================# * Window_Shop#=============================================================================class Window_Shop_De_Compra < Window_Selectable attr_reader :status_window def initialize(x, y, height, shop_goods)super(x+275, y-400, window_width-20, height+120)self.opacity = 0@shop_goods = shop_goods@money = 0refreshselect(0)end def window_widthreturn 304end def item_max@data ? @data.size : 1end def item@data[index]end def money=(money)@money = moneyrefreshend def current_item_enabled?enable?(@data[index])end # item : itemdef price(item)@price[item]end # item : itemdef enable?(item)item && price(item) <= @money && !$game_party.item_max?(item)end def refreshmake_item_listcreate_contentsdraw_all_itemsend def make_item_list@data = []@price = {}@shop_goods.each do |goods|case goods[0]when 0; item = $data_items[goods[1]]when 1; item = $data_weapons[goods[1]]when 2; item = $data_armors[goods[1]]endif item@data.push(item)@price[item] = goods[2] == 0 ? item.price : goods[3]endendend def draw_item(index)item = @data[index]rect = item_rect(index)draw_item_name(item, rect.x, rect.y, enable?(item))rect.width -= 4draw_text(rect, price(item), 2)end def status_window=(status_window)call_update_help@status_window = status_windowend def update_help@help_window.set_item(item) if @help_window@status_window.item = item if @status_windowendend#=============================================================================# * Shop Status#=============================================================================class Window_Shop_Status < Window_Base def initialize(x, y, width, height)super(x, y-320, width-20, height+300)self.opacity = 0@item = nil@page_index = 0refreshenddef refreshcontents.cleardraw_possession(4, 0)draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)end def item=(item)@item = itemrefreshend def draw_possession(x, y)rect = Rect.new(x, y, contents.width - 4 - x, line_height)change_color(system_color)draw_text(rect, Vocab:
ossession)change_color(normal_color)draw_text(rect, $game_party.item_number(@item), 2)end def draw_equip_info(x, y)status_members.each_with_index do |actor, i|draw_actor_equip_info(x, y + line_height * (i * 2.4), actor)endend def status_members$game_party.members[@page_index * page_size, page_size]end def page_sizereturn 4enddef page_max($game_party.members.size + page_size - 1) / page_sizeend def draw_actor_equip_info(x, y, actor)enabled = actor.equippable?(@item)change_color(normal_color, enabled)draw_text(x, y, 112, line_height, actor.name)item1 = current_equipped_item(actor, @item.etype_id)draw_actor_param_change(x, y, actor, item1) if enableddraw_item_name(item1, x, y + line_height, enabled)end def draw_actor_param_change(x, y, actor, item1)rect = Rect.new(x, y, contents.width - 4 - x, line_height)change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0)change_color(param_change_color(change))draw_text(rect, sprintf("%+d", change), 2)end def param_id@item.is_a?(RPG::Weapon) ? 2 : 3end def current_equipped_item(actor, etype_id)list = []actor.equip_slots.each_with_index do |slot_etype_id, i|list.push(actor.equips) if slot_etype_id == etype_idendlist.min_by {|item| item ? item.params[param_id] : 0 }enddef updatesuperupdate_pageend def update_pageif visible && Input.trigger?
A) && page_max > 1@page_index = (@page_index + 1) % page_maxrefreshendendend#=============================================================================# * Item Window List#=============================================================================class Window_Item_Lista < Window_Selectable def initialize(x, y, width, height)super(x,y+70,width,height)self.opacity = 255@category = :none@data = []end def category=(category)return if @category == category@category = categoryrefreshself.oy = 0end def col_maxreturn 1end def item_max@data ? @data.size : 1end def item@data && index >= 0 ? @data[index] : nilend def current_item_enabled?enable?(@data[index])enddef include?(item)case @categorywhen :itemitem.is_a?(RPG::Item) && !item.key_item?when :weaponitem.is_a?(RPG::Weapon)when :armoritem.is_a?(RPG::Armor)when :key_itemitem.is_a?(RPG::Item) && item.key_item?elsefalseendend def enable?(item)$game_party.usable?(item)end def make_item_list@data = $game_party.all_items.select {|item| include?(item) }@data.push(nil) if include?(nil)end def select_lastselect(@data.index($game_party.last_item.object) || 0)end def draw_item(index)item = @data[index]if itemrect = item_rect(index)rect.width -= 4draw_item_name(item, rect.x, rect.y, enable?(item))draw_item_number(rect, item)endenddef draw_item_number(rect, item)draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)end def update_help@help_window.set_item(item)enddef refreshmake_item_listcreate_contentsdraw_all_itemsend;end#=============================================================================# * Shop Item Select#=============================================================================class Window_Shop_Venda < Window_Item_Lista def initialize(x, y, width, height)super(x+300, y-350, width-300, height+200)self.opacity = 0end def current_item_enabled?enable?(@data[index])end def enable?(item)item && item.price > 0endend#=============================================================================# * Create Numbers#=============================================================================class Window_Shop_Numero < Window_Selectable attr_reader :number # Number Digits def initialize(x, y, height)super(x+275, y-400, window_width-20, height+120)self.opacity = 0@item = nil@max = 1@price = 0@number = 1@currency_unit = Vocab::currency_unitend def window_widthreturn 304end def set(item, max, price, currency_unit = nil)@item = item@max = max@price = price@currency_unit = currency_unit if currency_unit@number = 1refreshend def currency_unit=(currency_unit)@currency_unit = currency_unitrefreshend def refreshcontents.cleardraw_item_name(@item, 0, item_y)draw_numberdraw_total_priceend def draw_numberchange_color(normal_color)draw_text(cursor_x - 28, item_y, 22, line_height, "×")draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)end def draw_total_pricewidth = contents_width - 8draw_currency_value(@price * @number, @currency_unit, 4, price_y, width)end def item_ycontents_height / 2 - line_height * 3 / 2end def price_ycontents_height / 2 + line_height / 2end def cursor_widthfigures * 10 + 12end def cursor_xcontents_width - cursor_width - 4end def figuresreturn 2end def updatesuperif activelast_number = @numberupdate_numberif @number != last_numberSound.play_cursorrefreshend;end;end def update_numberchange_number(1) if Input.repeat?
RIGHT)change_number(-1) if Input.repeat?
LEFT)change_number(10) if Input.repeat?
UP)change_number(-10) if Input.repeat?
DOWN)end def change_number(amount)@number = [[@number + amount, @max].min, 1].maxend def update_cursorcursor_rect.set(cursor_x, item_y, cursor_width, line_height)end;end#=============================================================================# * Category Windows#=============================================================================class Category_Window < Window_HorzCommand attr_reader :item_window def initializesuper(0, 0)self.opacity = 0end def window_widthGraphics.width - 240end def col_maxreturn 3enddef updatesuper@item_window.category = current_symbol if @item_windowend def make_command_listadd_command(Vocab::item, :item)add_command(Vocab::weapon, :weapon)add_command(Vocab::armor, :armor)#~ add_command(Vocab::key_item, :key_item)end def item_window=(item_window)@item_window = item_windowupdateend;end#==============================================================================class RNT < Window_Basedef initializesuper(60,200,300,300)self.opacity = 0refreshenddef refreshself.contents.clear#=============================================================================## - - - BEGIN CUSTOMIZATION - - - ## * This is where you can edit where the NPC/Shop Keeper Speaks * ##=============================================================================#self.contents.draw_text(2,10,200,60,%Q<Welcome!>)self.contents.draw_text(3,30,200,60,%Q<take your time and >)self.contents.draw_text(3,50,200,60,%Q<browse around for>)self.contents.draw_text(3,70,200,60,%Q<whatever you like.>)self.contents.font.color = Color::new(245,134,10)self.contents.draw_text(20,94,200,60,%Q<Revenant Stories>)#=============================================================================## - - - END CUSTOMIZATION - - - ##=============================================================================##Endend;end
FAQ
No questions asked yet.
Credit and Thanks
- All the credit goes to Aarticus for giving me permission to release the translated version of his script.
- Proof that I was given permission
I translated this since the original script was a tad confusing for some people to edit.

