- Joined
- Oct 26, 2013
- Messages
- 53
- Reaction score
- 51
- First Language
- German
- Primarily Uses
Tinys Trade System (TTS) + Addons
Script Name : Tinys Trade System 1.15
Creator name : TinyMine
Introduction
Trading with goods like in Elder Scrolls or Gothic? Now it is possible. This script extends your game by a complete new shop system.
Screenshots :

Script :
New Versions :
Update 1.15 :
- Floats look nicer, if needed
- Added new vendor commands to exclude items individually
Update 1.1 "That's sheer robbery" :
- Added a Configpoint to change the item maximum number
- Added a new vendor command to change the vendors buy prices individually
- Added a new vendor command to change the vendors sell prices individually
- Changed the size and shape of number input window
- Fixed a minor calculation bug
- Fixed that amount scrolling was not effected by item_max in buy sequence
ADDONS :
The "Currency Addon"
Features :
- Makes it possible to trade with currencies
- makes it possible to add new currencies
- create your very own currencies and make them tradeable
Known Issues :
-
Planned Features :
- Share your wishes/suggestions with me!
Demo (New 1.15) inlc. Currency Addon :
Tiny Trade System 1.15.zip
Script Name : Tinys Trade System 1.15
Creator name : TinyMine
Introduction
Trading with goods like in Elder Scrolls or Gothic? Now it is possible. This script extends your game by a complete new shop system.
Screenshots :

Script :
#╔═=══════════════════════════════════════════════════════════════════════════=##║ Tinys Trade System#║ By TinyMine#║#║ First Published/Erstveröffentlicht 22.11.2013#║#║ Visit : http://rpgmaker-vx-ace.de/ for further Information#║#║ Suggestions? Support? Bugs? Contact me in http://rpgmaker-vx-ace.de/#║#║ Credits required : TinyMine#║ Commercial Use? : Contact me in http://rpgmaker-vx-ace.de/#║ Editable? : Only by original editor TinyMine#║#║#║ Version : 1.15 // 02.12.2013#╚═=═=════════════════════════════════════════════════════════════════════════=#$imported ||= {}$imported[:TINY_TTS] = 1.15#╔═=══════════════════════════════════════════════════════════════════════════=##║ ** FEATURES **#║#║ - Complete new shop scene#║ - Trading with items#║ - Define your vendors#║ - Vendor will loose bought items#║ - Vendor will get sold items#║ - Define your windows#║ - Define the scene sounds#║ - Define the scene font#║ - Penalty for player when trading#║#╚═=═=════════════════════════════════════════════════════════════════════════=##╔═=══════════════════════════════════════════════════════════════════════════=##║ ** UPDATES **#║#║ █ 1.15#║#║ - Added a new vendor command to exclude items individually#║#║ █ 1.11#║#║ - Added Float compatibility in text visualization#║#║ █ 1.1 "Thats's sheer robbery"#║#║ - Added a Configpoint to change the item maximum number#║ - Added a new vendor command to change the vendors buy prices individually#║ - Added a new vendor command to change the vendors sell prices individually#║ - Changed the size and shape of number input window#║ - Fixed a minor calculation bug#║ - Fixed that amount scrolling was not effected by item_max in buy sequence#║#║ █ 1.01#║#║ - Fixed double items overrite each other#║#║#╚═=═=════════════════════════════════════════════════════════════════════════=##╔═=══════════════════════════════════════════════════════════════════════════=##║ ** USAGE INSTRUCTIONS **#║#║ For calling the new shop scene, use...#║ █ open_shop(symbol)#║ Where symbol should be your defined vendor under vendor section.#║#║ For adding items to a specified vendor during game progress, use...#║ █ add_vendor_item(symbol, item)#║ Where symbol should be your defined vendor under vendor section and#║ where item should be something like "item,id,amount"#║#║ For example#║ add_vendor_item
myvendor, "armor,2,1")#║#║ For exclude items/weapons/armors from trading scene, write...#║ █ <not sellable>#║ Into your items/weapons/armors note#║#║#╚═=═=════════════════════════════════════════════════════════════════════════=#module TINY # Do not touchmodule TTS_GENERAL # Do not touch#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** EDITABLE REGION ** Defining TTS GENERAL Settings ** EDITABLE REGION **#╚═=═=════════════════════════════════════════════════════════════════════════=##█ General Settings# Defines the max amount for each item a player can haveMAX_ITEM = 999#█ Sound Settings# Defines sound when scrolling with cursor by filename in SESCROLL_SOUND = "Cursor1"# Defines sound when pressing menu points by filename in SEOK_SOUND = "Equip1"# Defines sound when canceling command/number window by filename in SECANCEL_SOUND = "Cancel1"#█ Window Settings# Defines used Window_Skin for all tts windowsWINDOWSKIN = "Window"# Defines the font used in all tts windowsWINDOWFONT = "VL Gothic"# Defines the Windowopacity (Frame + Skin) 0 - 255 (255 = fully visible)OPACITY = 255# Defines the Window Backopacity (Frame is untouched) 0 - 255 (255 = fully visible)BACKOPACITY = 255#█ Scene Settings# Creates a background by image name in system folder ( "" is no picture )BACKGROUND = ""#█ Vendor Settings# Defines global trade penalty in % // Calcs player values by % if no vendor command is givenPENALTY = 80#═=═=═════════════════════════════════════════════════════════════════════════=#end # TTS_GENERALmodule TTS_VOCAB # Do not touch#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** EDITABLE REGION ** Defining TTS Vocab ** EDITABLE REGION **#╚═=═=════════════════════════════════════════════════════════════════════════=## Headername for own Inventory in Shop SceneVOC_GOODS = "My stuff"# Description of amount when choosing amount of item to buy/sellVOC_AMOUNT = "Amount"# Names of commands in command windowVOC_TRADE = "Trade listed items "VOC_CANCEL = "Cancel trading"# Currencyunit used in your Game * Use VOCAB::currency_unit for DataBase currencyVOC_CURRENCY = "Gold"# Description of items price for info windowVOC_VALUE = "Value"#═=═=═════════════════════════════════════════════════════════════════════════=#end # TTS_VOCABmodule TTS_VENDOR # Do not touchVENDORS = { # Do not touch#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** EDITABLE REGION ** Defining TTS Vendors ** EDITABLE REGION **#╚═=═=════════════════════════════════════════════════════════════════════════=##╔═=═══════════════════════════════════════════════════════════════════════════##║ ** FULL ITEM/COMMAND LIST FOR VENDORS BELOW **#║#║#║ █ adding items/armors/weapons#║#║ - "weapon,id,amount"#║ - "armor,id,amount"#║ - "item,id,amount"#║#║ You will find the id of each item type (item,armor,weapon) you want#║ to add to your vendors inventory in your database, where you#║ find all your items and their configurations.#║#║ █ defining individual prices when selling/buying for each vendor#║#║ - "buy,percentage"#║ - "sell,percentage"#║#║ Recalulates the prices of each item. For example a vendor with#║ "sell,10" configuration will sell all his items to a discount of 90%.#║ If no "buy,percentage" command is given to a vendor the global player#║ penalty will take affect.#║#║ █ excluding specified items individually for each vendor#║#║ - "no item ID"#║ - "no armor ID"#║ - "no weapon ID"#║#║ The ID represents, as always, the item id from your database.#║ If you are excluding an item it won't appear in the trade list if#║ trading to the configurated vendor.#║#║#║ █ also take a look on TTS Addons to get new vendor commands#║#╚=════════════════════════════════════════════════════════════════════════════##█ EXAMPLE VENDORS# Vendor_ID and Name SEE LIST ABOVE FOR ALL COMMANDS:santa => ["weapon,1,1","sell,120","item,2,1","item,2,1", "no weapon 8","armor,4,2","item,6,3","item,5,2"],:klaus => ["weapon,1,1","item,2,1","item,2,1","sell,90", "no item 4", "no armor 8","armor,4,2","buy,10", "item,6,3","item,5,2"], # Use comma when a another vendor follows:harrison => ["item,2,1","items,2,19","buy,50", "sell,90", "armor,1,10","armor,4,2","item,6,3","item,5,2"] # Don't use comma when it is the last configurated vendor#█ OWN VENDORS (If you are comfortable with the settings you can remove the examples)# Add your own here#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** END OF EDITABLE REGION ** BEWARE ** END OF EDITABLE REGION ** DONT! **#║ █ ** Dont edit below this line, except... just don't **#╚═=═=════════════════════════════════════════════════════════════════════════=#} # end of vendors hash# Loadgame or Newgame?@vendors ||= VENDORS# Method for setting @vendorsdef self.vendors=(args)@vendors = argsend# Method for getting @vendorsdef self.vendors@vendorsend# Method for adding value to @vendors keydef self.add_vendors_item(key, value)@vendors[key] << valueend# Method for refreshing value to @vendors keydef self.refresh_vendors(key, new_value)@vendors[key] = new_valueendend # Module TTS_VENDORend # Module TINY#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Module DataManager#╚═=═=════════════════════════════════════════════════════════════════════════=#module DataManager# Aliasclass << selfalias_method :make_save_contents_tiny_tts_124145, :make_save_contentsalias_method :extract_save_contents_tiny_tts_88342, :extract_save_contentsend# Alias save contents for saving vendor inventoriesdef self.make_save_contentscontents = make_save_contents_tiny_tts_124145contents[:tts_vendors] = TINY::TTS_VENDOR.vendorscontentsend# Alias extract contents for extracting saved vendor inventoriesdef self.extract_save_contents(contents)extract_save_contents_tiny_tts_88342(contents)TINY::TTS_VENDOR.vendors = contents[:tts_vendors]endend # Module DataManager#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Module SceneManager#╚═=═=════════════════════════════════════════════════════════════════════════=#module SceneManager# Calls a scene with argumentsdef self.call_args(scene_class, *args)@stack.push(@scene)@scene = scene_class.new(*args)endend # Module SceneManager#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class Game_Interpreter#╚═=═=════════════════════════════════════════════════════════════════════════=#class Game_Interpreter# Command for opening the TTS Scenedef open_shop(symbol)SceneManager.call_args(TTS_Scene, symbol)end# Command for adding items to configured vendorsdef add_vendor_item(symbol, item)TINY::TTS_VENDOR.add_vendors_item(symbol, item)endend # Game_Interpreter#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class Game_Party#╚═=═=════════════════════════════════════════════════════════════════════════=#class Game_Party# Attrattr_reader :vendor_price, :vendor_penalty# Aliasalias_method :initialize_tiny_tts_13141 , :initialize# Alias initialize for defining tts hashsdef initializeinitialize_tiny_tts_13141clear_all_tts_inventoriesend# Overwriting the item_max methoddef max_item_number(item)return TINY::TTS_GENERAL::MAX_ITEMend# Method for hash inventory sharingdef share_buffer_item(item, amount, index)container = get_inventory(item.class, index)return unless containerlast_number = container[item.id] || 0new_number = last_number + amountcontainer[item.id] = [new_number, 0].maxcontainer.delete(item.id) if container[item.id] == 0end# Method for hash inventory amountdef item_number_tts(item, index)container = get_inventory(item.class, index)container ? container[item.id] || 0 : 0end# Method for returning the actual hash inventorydef get_inventory(klass, index)case indexwhen 0return @items if klass == RPG::Itemreturn @weapons if klass == RPG::Weaponreturn @armors if klass == RPG::Armorwhen 1return @items_buffer_player if klass == RPG::Itemreturn @weapons_buffer_player if klass == RPG::Weaponreturn @armors_buffer_player if klass == RPG::Armorwhen 2return @items_buffer_vendor if klass == RPG::Itemreturn @weapons_buffer_vendor if klass == RPG::Weaponreturn @armors_buffer_vendor if klass == RPG::Armorwhen 3return @items_vendor if klass == RPG::Itemreturn @weapons_vendor if klass == RPG::Weaponreturn @armors_vendor if klass == RPG::Armorendfalseend# Method for calc price of bought itemsdef calc_price_vendorvalue_buffer = 0@items_buffer_vendor.keys.each { |id| value_buffer += ($data_items[id].price * (@items_buffer_vendor[id])) }@weapons_buffer_vendor.keys.each { |id| value_buffer += ($data_weapons[id].price * (@weapons_buffer_vendor[id])) }@armors_buffer_vendor.keys.each { |id| value_buffer += ($data_armors[id].price * (@armors_buffer_vendor[id])) }value_buffer = (value_buffer*@vendor_price).ceil.to_ivalue_bufferend# Method for calc price of sold itemsdef calc_price_playervalue_buffer = 0@items_buffer_player.keys.each { |id| value_buffer += ($data_items[id].price * (@items_buffer_player[id])) }@weapons_buffer_player.keys.each { |id| value_buffer += ($data_weapons[id].price * (@weapons_buffer_player[id])) }@armors_buffer_player.keys.each { |id| value_buffer += ($data_armors[id].price * (@armors_buffer_player[id])) }value_buffer = (value_buffer*@vendor_penalty).ceil.to_ivalue_bufferend# Method to remove non sellable items from party hash itemsdef get_sellable_itemsitem_list = {}@items.each { |item, quant|next if $data_items[item].note.include?("<not sellable>")next if @vendor_denies.include?("no item #{item}")item_list[item] = quant}item_listend# Method to remove non sellable items from party hash weaponsdef get_sellable_weaponsweapon_list = {}@weapons.each { |weapon, quant|next if $data_weapons[weapon].note.include?("<not sellable>")next if @vendor_denies.include?("no weapon #{weapon}")weapon_list[weapon] = quant}weapon_listend# Method to remove non sellable items from party hash armorsdef get_sellable_armorsarmor_list = {}@armors.each { |armor, quant|next if $data_armors[armor].note.include?("<not sellable>")next if @vendor_denies.include?("no armor #{armor}")armor_list[armor] = quant}armor_listend# Method for reading vendor stringsdef set_buyable_items(vendor)TINY::TTS_VENDOR.vendors[vendor].each { |item|item =~ /sell,(\d+)/ ? adjust_vendor_prices($1.to_i) :item =~ /buy,(\d+)/ ? adjust_vendor_penalty($1.to_i) :item =~ /no (\w+) \W*(\w+)/ ? set_vendor_denies($1, $2) :item =~ /(\w+)s*,\s*\W*(\w+)\s*,\s*(\d+)/ ? fill_vendor_inventory($1, $2, $3) : nil}end# Method for adjusting the vendors sell pricesdef adjust_vendor_prices(int)@vendor_price = int/100.0end# Method for adjusting the vendors buy pricesdef adjust_vendor_penalty(int)@vendor_penalty = int/100.0end# Method for creating vendor hash inventoriesdef fill_vendor_inventory(type, id, amount)amount_int = amount.to_icase type.downcasewhen /item\w*/@items_vendor[id.to_i] ||= 0@items_vendor[id.to_i] += amount_intwhen /weapon\w*/@weapons_vendor[id.to_i] ||= 0@weapons_vendor[id.to_i] += amount_intwhen /armor\w*/@armors_vendor[id.to_i] ||= 0@armors_vendor[id.to_i] += amount_intend0end# Method for filling up the denied items of each vendordef set_vendor_denies(type, id)case type.downcasewhen /item\w*/@vendor_denies += "no #{type} #{id}"when /weapon\w*/@vendor_denies += "no #{type} #{id}"when /armor\w*/@vendor_denies += "no #{type} #{id}"end0end# Method for creating new vendor stringsdef get_new_vendor_valuevalue = []value << "penalty,#{@vendor_penalty*100}"value << "price,#{@vendor_price*100}"for i in 0..@items_vendor.sizevalue << "item,#{@items_vendor.keys},#{@items_vendor.values}"endfor i in 0..@weapons_vendor.sizevalue << "weapon,#{@weapons_vendor.keys},#{@weapons_vendor.values}"endfor i in 0..@armors_vendor.sizevalue << "armor,#{@armors_vendor.keys},#{@armors_vendor.values}"endfor i in 0..@items_buffer_player.sizevalue << "item,#{@items_buffer_player.keys},#{@items_buffer_player.values}"endfor i in 0..@weapons_buffer_player.sizevalue << "weapon,#{@weapons_buffer_player.keys},#{@weapons_buffer_player.values}"endfor i in 0..@armors_buffer_player.sizevalue << "armor,#{@armors_buffer_player.keys},#{@armors_buffer_player.values}"endvalueend# Method for getting all envolved data_base items/weapons/armorsdef get_all_items(index)all_items = []case indexwhen 0get_sellable_items.keys.sort.collect {|id| all_items << $data_items[id] }get_sellable_weapons.keys.sort.collect {|id| all_items << $data_weapons[id] }get_sellable_armors.keys.sort.collect {|id| all_items << $data_armors[id] }when 3@items_vendor.keys.sort.collect {|id| all_items << $data_items[id] }@weapons_vendor.keys.sort.collect {|id| all_items << $data_weapons[id] }@armors_vendor.keys.sort.collect {|id| all_items << $data_armors[id] }when 1@items_buffer_player.keys.sort.collect {|id| all_items << $data_items[id] }@weapons_buffer_player.keys.sort.collect {|id| all_items << $data_weapons[id] }@armors_buffer_player.keys.sort.collect {|id| all_items << $data_armors[id] }when 2@items_buffer_vendor.keys.sort.collect {|id| all_items << $data_items[id] }@weapons_buffer_vendor.keys.sort.collect {|id| all_items << $data_weapons[id] }@armors_buffer_vendor.keys.sort.collect {|id| all_items << $data_armors[id]}endall_itemsend# Method for defining/clearing all tts hash inventoriesdef clear_all_tts_inventories@vendor_denies = ""@vendor_penalty = adjust_vendor_penalty(TINY::TTS_GENERAL:
ENALTY)@vendor_price = adjust_vendor_prices(100)@items_vendor = {}@weapons_vendor = {}@armors_vendor = {}@items_buffer_player = {}@weapons_buffer_player = {}@armors_buffer_player = {}@items_buffer_vendor = {}@weapons_buffer_vendor = {}@armors_buffer_vendor = {}endend # Game_Party#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class Window_Base#╚═=═=════════════════════════════════════════════════════════════════════════=#class Window_Base# Defines configurations for all tts windowsdef tts_window_configurationsself.windowskin = Cache.system(TINY::TTS_GENERAL::WINDOWSKIN)self.opacity = TINY::TTS_GENERAL:
PACITYself.back_opacity = TINY::TTS_GENERAL::BACKOPACITYfont = Font.new([TINY::TTS_GENERAL::WINDOWFONT])font.bold = falsefont.shadow = falsefont.out_color = Color.new(0, 0, 0, 128)self.contents.font = fontendend # Window_Base#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** NEW Class TTS_Toprow_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Toprow_Window < Window_Base# Initializes the windowdef initialize(pos)@pos = possuper(@pos * 136, 0, 136, 48)self.z = 200tts_window_configurationsrefreshend# Method for returning a standard text rectdef text_rectrect = Rect.new(0, 0, contents_width, contents_height)rectend# Method for create the price/value textdef text_priceprice = $game_party.calc_price_player if @pos == 1price = $game_party.calc_price_vendor if @pos == 2neat_float = ""if price.is_a?(Float)neat_float = price.to_sneat_float.gsub!(".") {","}text_price = neat_floatelsetext_price = priceendtext_priceend# Method for refreshing the window contentsdef refreshcontents.clearreturn draw_text(text_rect,TINY::TTS_VOCAB::VOC_GOODS) if @pos == 0return draw_text(text_rect,text_price) if @pos == 1 || @pos == 2return draw_text(text_rect,SceneManager.scene.vendor.to_s.capitalize) if @pos == 3endend # TTS_Toprow_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** NEW Class TTS_Midrow_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Midrow_Window < Window_Selectable# Initializes the windowdef initialize(pos)@pos = possuper(@pos * 136, 48, 136, 272)self.z = 200tts_window_configurationsrefreshend# Method for activating the windowdef activatereturn if activeselect(0)SceneManager.scene.refresh_info_window(@index)superend# Method for returning a standard text rectdef text_rectrect = Rect.new(0, 0, contents_width, contents_height)rectend# Method for returning contents sizedef item_max$game_party.get_all_items(@pos).sizeend# Method for processing cursor movementdef process_cursor_movereturn unless cursor_movable?last_index = @indexcursor_down (Input.trigger?
DOWN)) if Input.repeat?
DOWN)cursor_up (Input.trigger?
UP)) if Input.repeat?
UP)Audio.se_play("Audio/SE/" + TINY::TTS_GENERAL::SCROLL_SOUND) if @index != last_indexSceneManager.scene.refresh_info_window(@index) if @index != last_indexend# Method for handling cursor movementdef process_handlingreturn unless open? && activereturn process_ok if ok_enabled? && Input.trigger?
C)return process_cancel if cancel_enabled? && Input.trigger?
return process_right if handle?
right) && Input.trigger?
RIGHT)return process_left if handle?
left) && Input.trigger?
LEFT)end# Method for handling canceldef process_cancelAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL::CANCEL_SOUND)Input.updatedeactivatecall_cancel_handlerend# Method for handling okdef process_okAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL:
K_SOUND)Input.updatecall_ok_handlerend# Method for handling rightdef process_rightAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL::SCROLL_SOUND)Input.updatecall_handler
right)end# Method for handling leftdef process_leftAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL::SCROLL_SOUND)Input.updatecall_handler
left)end# Method for refreshing the window contentsdef refreshcontents.clearfor i in 0..$game_party.get_all_items(@pos).size-1draw_icon($game_party.get_all_items(@pos).icon_index, 0, i * 24, true)draw_text(0, i * 24, contents_width, 24, ($game_party.item_number_tts($game_party.get_all_items(@pos), @pos)), 2)endendend # TTS_Midrow_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** NEW Class TTS_Botrow_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Botrow_Window < Window_Base# Initializes the windowdef initializesuper(0, 320, 544, 96)self.z = 200@textdata = niltts_window_configurationsend# Method for setting the @item datadef set_item(index_window, index_scene)@textdata = $game_party.get_all_items(index_scene)[index_window]index_scene == 1 || index_scene == 0 ? @multiplicator = $game_party.vendor_penalty : @multiplicator = $game_party.vendor_pricerefreshend# Method for create the price/value textdef text_priceneat_float = ""if @textdata.price.is_a?(Float)neat_float = (@textdata.price * @multiplicator).to_sneat_float.gsub!(".") {","}text_price = neat_floatelsetext_price = (@textdata.price*@multiplicator).to_iendtext_priceend# Method for refreshing the window contentsdef refreshreturn if @textdata.nil?contents.cleardraw_text(0, 0, contents_width, 24, @textdata.name, 0)draw_text(0, 0, contents_width, 24, "#{TINY::TTS_VOCAB::VOC_VALUE}: #{text_price} #{TINY::TTS_VOCAB::VOC_CURRENCY}", 2)draw_text_ex(0, 24, @textdata.description)endend # TTS_Botrow_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** NEW Class TTS_Command_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Command_Window < Window_Command# Initializes the windowdef initializesuper(0, 160)self.x = Graphics.width/2 - self.width/2self.z = 201tts_window_configurationsself.openness = 0deactivateend# Method for starting the windowdef startclear_command_listmake_command_listopenactivateend# Method for returning width of selfdef window_width200end# Method for defining commandlist commandsdef make_command_listadd_command(TINY::TTS_VOCAB::VOC_TRADE, :buy, get_buy_state)add_command(TINY::TTS_VOCAB::VOC_CANCEL, :close, true)end# Method for enabling cancel commanddef cancel_enabled?return trueend# Method for processing cancel commanddef process_okif current_item_enabled?Audio.se_play("Audio/SE/" + TINY::TTS_GENERAL:
K_SOUND)Input.updatedeactivatecall_ok_handlerelseAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL::CANCEL_SOUND)endend# Method for processing cancel commanddef process_cancelAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL::CANCEL_SOUND)Input.updateSceneManager.scene.refresh_all_windowsclosedeactivateend# Method for returing the buyable statedef get_buy_statereturn true if $game_party.calc_price_vendor <= $game_party.calc_price_player && $game_party.calc_price_player != 0return falseendend # TTS_Command_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** NEW Class TTS_Number_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Number_Window < Window_Selectable# Initializes the windowdef initializesuper(0, 160, 144, 72)self.x = Graphics.width/2 - self.width/2self.z = 201tts_window_configurations@index = 1self.openness = 0deactivateend# Method for starting the window and its max scroll numbersdef start(index_scene, index_window)@type, @item_id = index_scene, index_window@number = 1define_maximarefreshactivateopenend# Method for defining the maximum numbers of each item to buydef define_maxima@number_max = $game_party.item_number_tts($game_party.get_all_items(@type)[@item_id], @type) + 1@type == 3 ? @item_max = $game_party.max_item_number(nil) : @item_max = 99999999@item_max -= get_foreign_item_number if @type == 3@number = 0 if @item_max <= 0@item_max += 1end# Method for extracting item amounts of non selected windowsdef get_foreign_item_numberitem = $game_party.get_all_items(@type)[@item_id]items_given = 0for i in 0..2inventory = $game_party.get_all_items(i)item_pos = -1found = falseinventory.each { |val|item_pos += 1if val.id == item.id && val.class == item.classfound = truebreakend}items_given += $game_party.item_number_tts($game_party.get_all_items(i)[item_pos], i) unless found == falseenditems_givenend# Method for deactivating standard cursor processingdef process_cursor_movenilend# Method for returning and processing amount numberdef process_number_changereturn unless activeif Input.repeat?
UP) || Input.repeat?
DOWN) || Input.repeat?
RIGHT) || Input.repeat?
LEFT)return if @item_max == 0@number = (@number + 1) % @number_max % @item_max if Input.repeat?
UP)@number = (@number - 1) % @number_max % @item_max if Input.repeat?
DOWN)@number = (@number + 10) % @number_max % @item_max if Input.repeat?
RIGHT)@number = (@number - 10) % @number_max % @item_max if Input.repeat?
LEFT)refreshendend# Method for process handlingdef process_handlingreturn unless activereturn process_ok if Input.trigger?
C)return process_cancel if Input.trigger?
end# Method for process ok commanddef process_okAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL:
K_SOUND)share_itemsSceneManager.scene.refresh_all_windowsdeactivatecloseend# Method for process cancel commanddef process_cancelAudio.se_play("Audio/SE/" + TINY::TTS_GENERAL::CANCEL_SOUND)SceneManager.scene.refresh_all_windowsdeactivatecloseend# Method for sharing items between hash inventoriesdef share_itemstarget = @type == 0 ? 1 : @type == 1 ? 0 : @type == 2 ? 3 : @type == 3 ? 2 : 0$game_party.share_buffer_item($game_party.get_all_items(@type)[@item_id], @number, target)$game_party.share_buffer_item($game_party.get_all_items(@type)[@item_id], -@number, @type)end# Method for refreshing the window contentsdef refreshcontents.cleardraw_text(0, 0, contents_width, contents_height/2, "#{TINY::TTS_VOCAB::VOC_AMOUNT}", 1)draw_text(0, contents_height/2, contents_width, contents_height/2, "#{@number}", 1)end# Method for updating the windowdef updatesuperprocess_number_changeendend # TTS_Number_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** NEW Class TTS_Scene#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Scene < Scene_Base# Initializes the scenedef initialize(vendor)@vendor = vendorend# Method for starting the scenedef startsuperbegin$game_party.clear_all_tts_inventories$game_party.set_buyable_items(vendor)rescuemsgbox_p("This vendor does not exist. Closing scene")return SceneManager.returnendcreate_all_windowscreate_all_handler@background = Sprite.new@background.bitmap = Cache.system(TINY::TTS_GENERAL::BACKGROUND)select(0, 0)end# Method for returning actual vendor keydef vendor@vendorend# Method for creating all scene windowsdef create_all_windows@info_window = TTS_Botrow_Window.new()@tll_window = TTS_Toprow_Window.new(0)@tl_window = TTS_Toprow_Window.new(1)@tr_window = TTS_Toprow_Window.new(2)@trr_window = TTS_Toprow_Window.new(3)@mll_window = TTS_Midrow_Window.new(0)@ml_window = TTS_Midrow_Window.new(1)@mr_window = TTS_Midrow_Window.new(2)@mrr_window = TTS_Midrow_Window.new(3)@com_main = TTS_Command_Window.new()@number_window = TTS_Number_Window.new()end# Method for setting all scene window handlersdef create_all_handlerinstance_variables.each { |varname|ivar = instance_variable_get(varname)if ivar.is_a?(TTS_Midrow_Window)ivar.set_handler
cancel, method
start_command_window))ivar.set_handler
ok, method
start_number_window))ivar.set_handler
right, method
right_scene_index))ivar.set_handler
left, method
left_scene_index))end}@com_main.set_handler
close, method
close_scene))@com_main.set_handler
buy, method
accomplish_scene))end# Method for starting command windowdef start_command_window@depth = 1@com_main.startunselectend# Method for starting number inputdef start_number_windowwindow = nilinstance_variables.select { |varname|ivar = instance_variable_get(varname)if ivar.is_a?(TTS_Midrow_Window) && ivar.activewindow = ivarend}return if window.item_max == 0@depth = 1@number_window.start(@index,window.index)unselectend# Method for closing scene without inventory changesdef close_scenefor i in 0..$game_party.get_all_items(1).size-1$game_party.share_buffer_item($game_party.get_all_items(1), $game_party.item_number_tts($game_party.get_all_items(1), 1), 0)end$game_party.clear_all_tts_inventories@background.disposeSceneManager.returnend# Method for closing scene with inventory processesdef accomplish_scenefor i in 0..$game_party.get_all_items(2).size-1$game_party.share_buffer_item($game_party.get_all_items(2), $game_party.item_number_tts($game_party.get_all_items(2), 2), 0)endTINY::TTS_VENDOR.refresh_vendors(@vendor, $game_party.get_new_vendor_value)$game_party.clear_all_tts_inventories@background.disposeSceneManager.returnend# Method for selecting index, depth of scenedef select(index, depth)@index = index@depth = depthend# Method for selecting depth of scenedef depth(depth)@depth = depth@depthend# Method for unselecting all item listsdef unselectinstance_variables.each do |varname|ivar = instance_variable_get(varname)ivar.deactivate if ivar.is_a?(TTS_Midrow_Window)ivar.unselect if ivar.is_a?(TTS_Midrow_Window)endend# Method for selecting next item listdef right_scene_index@index = (@index + 1) % 4unselectend# Method for selecting next item listdef left_scene_index@index = (@index - 1) % 4unselectend# Method for refreshing all scene windowsdef refresh_all_windowsinstance_variables.each do |varname|ivar = instance_variable_get(varname)ivar.refresh if ivar.is_a?(Window)end@depth = 0end# Method for refreshing info window datadef refresh_info_window(index_window, index_scene = @index)@info_window.set_item(index_window, index_scene)end# Method for activating actual item listdef update_index@mll_window.activate if @index == 0@ml_window.activate if @index == 1@mr_window.activate if @index == 2@mrr_window.activate if @index == 3end# Method for updating the scenedef updatesuperupdate_index if @depth == 0endend # TTS_Scene#╔═=═══════════════════════════════════════════════════════════════════════════╗#╠══════════════════════════════▲ END OF SCRIPT ▲══════════════════════════════╣#╚═=═=═════════════════════════════════════════════════════════════════════════╝
New Versions :
Update 1.15 :
- Floats look nicer, if needed
- Added new vendor commands to exclude items individually
Update 1.1 "That's sheer robbery" :
- Added a Configpoint to change the item maximum number
- Added a new vendor command to change the vendors buy prices individually
- Added a new vendor command to change the vendors sell prices individually
- Changed the size and shape of number input window
- Fixed a minor calculation bug
- Fixed that amount scrolling was not effected by item_max in buy sequence
ADDONS :
The "Currency Addon"
Features :
- Makes it possible to trade with currencies
- makes it possible to add new currencies
- create your very own currencies and make them tradeable
#╔═=══════════════════════════════════════════════════════════════════════════=##║ Tinys TTS Currency Addon#║ By TinyMine#║#║ First Published/Erstveröffentlicht 27.11.2013#║#║ Visit : http://rpgmaker-vx-ace.de/ for further Information#║#║ Suggestions? Support? Bugs? Contact me in http://rpgmaker-vx-ace.de/#║#║ Credits required : TinyMine#║ Commercial Use? : Contact me in http://rpgmaker-vx-ace.de/#║ Editable? : Only by original editor TinyMine#║#║#║ Version : 1.0 // 30.11.2013#╚═=═=════════════════════════════════════════════════════════════════════════=##╔═=══════════════════════════════════════════════════════════════════════════=##║ ** ADDED USAGE INSTRUCTIONS **#║#║ For adding new currencies to player, use...#║ █ give_currency(type, amount)#║ Where type should be your defined currency in a string.#║ where amount should be the amount.#║#║ For example#║ give_currency("silver", 10000)#║ or#║ give_currency(":silver", 10000)#║ or#║ give_currency(1, 10000)#║#╚═=═=════════════════════════════════════════════════════════════════════════=##╔═=═══════════════════════════════════════════════════════════════════════════##║ ** NEW ITEM/COMMANDS FOR VENDORS BELOW **#║#║#║ █ adding currencies to vendors#║#║ - "currency,id,amount"#║#║ You will configurate the ids by yourself.#║#║ █ adding default gold to vendors#║#║ - "currency,0,amount"#║ or#║ - "gold, amount"#║#║ 0 will always be the ID for the default currency, which is defined#║ in database. Value will always be 1.#║#║ █ excluding specified currencies individually for each vendor#║#║ - "no currency ID"#║#╚=════════════════════════════════════════════════════════════════════════════## Check for compatibil version of main scriptif $imported[:TINY_TTS] == nilmsgbox_p("You need to install *TTS (Tinys Trade System)* to use *TTS Currency Addon*")elsif $imported[:TINY_TTS] < 1.15msgbox_p("You need to install TTS Version 1.11 or higher to run TTS Currency Addon")else$imported[:TINY_TTSCA] = 1.0#═=═=═════════════════════════════════════════════════════════════════════════=#module TINYmodule TTS_CURRENCY#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** EDITABLE REGION ** Currency Addon General ** EDITABLE REGION **#╚═=═=════════════════════════════════════════════════════════════════════════=## Defining the max gold/purse space for each currencyMAX_GOLD = 99999999# Defining the name which will be used for the default goldDEFAULT_NAME = "Gold"# Defining the icon which will be used for the default goldDEFAULT_ICON = 360# Defining the description which will be used for the default goldDEFAULT_DESCRIPTION = "The common gold bricekts from the northern kingdoms."#═=═=═════════════════════════════════════════════════════════════════════════=#CURRENCIES = { # Do not touch#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** EDITABLE REGION ** Adding more Currencies for TTS ** EDITABLE REGION **#╚═=═=════════════════════════════════════════════════════════════════════════=##█ EXAMPLE CURRENCIES# ID of your currency # Always use the symbols
name...etc.):silver => { :name => "Silver Rock",:icon_index => 350,:description => "These rocks are used along the southern countries\nfor trading.",
rice => 0.5},:khadra => { :name => "Khadra Coin",:icon_index => 361,:description => "Coins from the east countires. Very rare.",
rice => 4}#█ OWN CURRENCIES# Add your own here#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** END OF EDITABLE REGION ** BEWARE ** END OF EDITABLE REGION ** DONT! **#║ █ ** Dont edit below this line, except... just don't **#╚═=═=════════════════════════════════════════════════════════════════════════=#} # end of currency hash# Method for filling the new data $data_currencydef self.setup_currency_datadata_currency = []default_currency = RPG::Currency.newdefault_currency.id = 0default_currency.name = DEFAULT_NAMEdefault_currency.icon_index = DEFAULT_ICONdefault_currency.description = DEFAULT_DESCRIPTIONdefault_currency.price = 1data_currency << default_currencyfor i in 0..CURRENCIES.size-1 donew_currency = RPG::Currency.newnew_currency.id = i + 1new_currency.name = CURRENCIES[CURRENCIES.keys][:name]new_currency.icon_index = CURRENCIES[CURRENCIES.keys][:icon_index]new_currency.description = CURRENCIES[CURRENCIES.keys][:description]new_currency.price = CURRENCIES[CURRENCIES.keys][
rice]data_currency << new_currencyenddata_currencyendend # TTS_CURRENCYend # TINY#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Module RPG::Currency#╚═=═=════════════════════════════════════════════════════════════════════════=#class RPG::Currency# Attrattr_accessor :id, :name, :icon_index, :description,
rice# Initializes items of classdef initialize@id = 0@name = ""@icon_index = 0@description = ""@price = 0endend # RPG::Currency#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Module DataManager#╚═=═=════════════════════════════════════════════════════════════════════════=#module DataManager#Aliasclass << selfalias_method :load_normal_database_tts_curr_tiny_1480, :load_normal_databaseend# Alias load_normal_database for creating a new data itemdef self.load_normal_databaseload_normal_database_tts_curr_tiny_1480$data_currency = TINY::TTS_CURRENCY.setup_currency_dataendend # DataManager#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class Game_Interpreter#╚═=═=════════════════════════════════════════════════════════════════════════=#class Game_Interpreter# Command for adding new currencies to playerdef give_currency(type, amount)if type.is_a?(Integer) || type =~ /\d+/type = type.to_ielsetype = TINY::TTS_CURRENCY::CURRENCIES.keys.index(type.downcase.to_sym).to_i+1end$game_party.purse[type.to_i] ||= 0$game_party.purse[type.to_i] += amount.to_iendend # Game_Interpreter#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class Game_Party#╚═=═=════════════════════════════════════════════════════════════════════════=#class Game_Party# Attrattr_accessor
urse# Aliasalias_method :get_inventory_curr_addon_tiny_1898, :get_inventoryalias_method :fill_vendor_inventory_curr_addon_tiny_00, :fill_vendor_inventoryalias_method :calc_price_vendor_curr_addon_tiny_774, :calc_price_vendoralias_method :calc_price_player_curr_addon_tiny_2314, :calc_price_playeralias_method :get_new_vendor_value_curr_addon_tiny_11, :get_new_vendor_valuealias_method :get_all_items_curr_addon_tiny_777, :get_all_itemsalias_method :clear_all_tts_inventories_curr_add_8, :clear_all_tts_inventoriesalias_method :init_all_items_curr_addon_tiny_14, :init_all_itemsalias_method :set_buyable_items_curr_addon_tiny_188, :set_buyable_itemsalias_method :set_vendor_denies_curr_addon_tiny_400, :set_vendor_denies# Overwrite max_golddef max_goldreturn TINY::TTS_CURRENCY::MAX_GOLDend# Alias get_inventory method for finding pursesdef get_inventory(klass, index)case indexwhen 0return @purse if klass == RPG::Currencywhen 1return @purse_buffer_player if klass == RPG::Currencywhen 2return @purse_buffer_vendor if klass == RPG::Currencywhen 3return @purse_vendor if klass == RPG::Currencyendget_inventory_curr_addon_tiny_1898(klass, index)end# Method for calc price of bought itemsdef calc_price_vendorvalue_buffer = calc_price_vendor_curr_addon_tiny_774@purse_buffer_vendor.keys.each { |id| value_buffer += ($data_currency[id].price * (@purse_buffer_vendor[id])) }value_bufferend# Method for calc price of sold itemsdef calc_price_playervalue_buffer = calc_price_player_curr_addon_tiny_2314@purse_buffer_player.keys.each { |id| value_buffer += ($data_currency[id].price * (@purse_buffer_player[id])) }value_bufferend# Alias set_buyable_items for checking for deniesdef set_buyable_items(vendor)set_buyable_items_curr_addon_tiny_188(vendor)TINY::TTS_VENDOR.vendors[vendor].each { |item|item =~ /gold, (\d+)/ ? fill_vendor_inventory("currency", "0", $1) : nil}end# Alias fill_vendor_inventory method for adding currenciesdef fill_vendor_inventory(type, id, amount)fill_vendor_inventory_curr_addon_tiny_00(type, id, amount)case type.downcasewhen /currency\w*/if id =~ /\d+/id = id.to_ielseid = TINY::TTS_CURRENCY::CURRENCIES.keys.index(id.to_sym).to_i+1end@purse_vendor[id.to_i] ||= 0@purse_vendor[id.to_i] += amount.to_iend0end# Alias for filling up the denied currencies of each vendordef set_vendor_denies(type, id)set_vendor_denies_curr_addon_tiny_400(type, id)case type.downcasewhen /currency\w*/if id =~ /\d+/id = id.to_ielseid = TINY::TTS_CURRENCY::CURRENCIES.keys.index(id.to_sym).to_i+1end@vendor_denies += "no #{type} #{id}"end0end# Alias get_new_vendor_value method for adding pursesdef get_new_vendor_valuevalue = get_new_vendor_value_curr_addon_tiny_11for i in 0..@purse_vendor.sizevalue.unshift("currency,#{@purse_vendor.keys},#{@purse_vendor.values}")endfor i in 0..@purse_buffer_player.sizevalue.unshift("currency,#{@purse_buffer_player.keys},#{@purse_buffer_player.values}")endvalueend# Method for excluding denied currencies for actual vendordef get_sellable_currenciesitem_list = {}@purse.each { |item, quant| item_list[item] = quant unless @vendor_denies.include?("no currency #{item}") }item_listend# Alias get_all_items method for adding purse hashdef get_all_items(index)all_items = get_all_items_curr_addon_tiny_777(index)case indexwhen 0get_sellable_currencies.keys.sort.collect {|id| all_items.unshift($data_currency[id]) }when 3@purse_vendor.keys.sort.collect {|id| all_items.unshift($data_currency[id]) }when 1@purse_buffer_player.keys.sort.collect {|id| all_items.unshift($data_currency[id]) }when 2@purse_buffer_vendor.keys.sort.collect {|id| all_items.unshift($data_currency[id]) }endall_itemsend# Method for fill up players gold after trade scenedef redefine_default_currency@purse[0].nil? ? @gold = 0 : @gold = @purse[0]@gold += + @purse_buffer_vendor[0] unless @purse_buffer_vendor[0].nil?@purse.delete(0) if @gold == 0end# Alias for defining/clearing all tts hash inventoriesdef clear_all_tts_inventories@purse[0] = @gold unless @gold == 0@purse_buffer_player = {}@purse_vendor = {}@purse_buffer_vendor = {}clear_all_tts_inventories_curr_add_8end# Alias init_all_items method for adding purse hashdef init_all_itemsinit_all_items_curr_addon_tiny_14@purse = {}endend # Game_Party#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class TTS_Number_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Number_Window#Aliasalias_method :define_maxima_curr_addon_tiny_87, :define_maxima# Alias define_maxima method changing the max item for currenciesdef define_maximadefine_maxima_curr_addon_tiny_87item = $game_party.get_all_items(@type)[@item_id]@item_max += (TINY::TTS_CURRENCY::MAX_GOLD - $game_party.max_item_number(nil) - 1) if item.class == RPG::Currency@number = 0 if @item_max <= 0@item_max += 1endend # TTS_Number_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class TTS_Botrow_Window#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Botrow_Window#Aliasalias_method :text_price_curr_addon_tiny_283499, :text_price# Alias text_price method for keep currency pricesdef text_price@multiplicator = 1 if @textdata.class == RPG::Currencytext_price_curr_addon_tiny_283499endend # TTS_Botrow_Window#╔═=══════════════════════════════════════════════════════════════════════════=##║ █ ** OLD Class TTS_Scene#╚═=═=════════════════════════════════════════════════════════════════════════=#class TTS_Scene#Aliasalias_method :accomplish_scene_curr_addon_tiny_1123, :accomplish_scene# Alias accomplish scene method for add/sub gold from player golddef accomplish_scene$game_party.redefine_default_currencyaccomplish_scene_curr_addon_tiny_1123endend # TTS_Sceneend # End of Version check#╔═=═══════════════════════════════════════════════════════════════════════════╗#╠══════════════════════════════▲ END OF SCRIPT ▲══════════════════════════════╣#╚═=═=═════════════════════════════════════════════════════════════════════════╝
Known Issues :
-
Planned Features :
- Share your wishes/suggestions with me!
Demo (New 1.15) inlc. Currency Addon :
Tiny Trade System 1.15.zip
Attachments
-
323 bytes Views: 340
Last edited by a moderator:

