Posts: 32
Threads: 4
Joined: Apr 2016
Ok I've been rearranging and tinkering with LittleDraco's limited Shop Inventory V2
http://littledrago.blogspot.com/2013/05/...op-v2.html
Neat little script, but I've come across a few issues when redesigning the layout and here's the main issue I'm finding (see pic) Also note, I'm not a scripter but I can tinker with scripts up to a certain point ^^;;;
shopprob.png (Size: 469.78 KB / Downloads: 13)
The graphics are still in the works but I managed to get it to mostly look/setup the way we want. And as you can see on the right, I'm having problems locating the code area to effect the appearance of icons when going into the buy/sell middle area where you select how many you are selling and buying. Now for buying we actually don't need it, because there will always be one of each item in the shop to sell. But it's still useful for the selling part since you may have more of the same items for sell. So in this case two questions:
1. How to remove or bypass the "multiple buying" section in the script?
Cause really it's not needed there or if anything...
2. Where is the code/section to edit this particular section? (I've looked through the code so many time my eyes cross and was not able to see things that resembles the code that works so well on the others >< so I'm assuming it doesn't look the same or it calls it from elsewhere (like maybe from the default/core scripts).
3. Also the windowskin for the main game would be differ from the shops. I've tried tinkering with it but it changes to default or gets an error. So how can I make this have it's own windowskin?
Also I've noticed the code has an incredibly simple setup to make it where items don't show back up in the buying area after you sell to the merchant, which is great but the problem I find is that it also doesn't show anything for sale either, even though it's been setup to have things on sale X_x;;
If anyone got a fix for this it'll be great, but if not, it's alright as this isn't the most major concern (we can deal with having the ability to rebuy items back :P). Thank you ahead of time ^_^
______・*。☆彡Ƹ̵̡Ӝ̵̨̄Ʒ*~゚・。 )O( 。・゚~*Ƹ̵̡Ӝ̵̨̄Ʒミ☆。*・______
MoonFaerie Studio: (Formerly LunarBerry Studio)
http://www.moonfaeriestudio.com
Deviantart gallery: https://www.deviantart.com/moonfaeriestudio
--------------・*。☆*~゚・。Ƹ̵̡Ӝ̵̨̄Ʒ。・゚~*☆。*・--------------
Current Game Project(s):
In collaboration w/Siletrea:
----------------------------------
My Personal Project(s):
I do all sorts of arts and crafts :P ... and randomly too
Posts: 4,634
Threads: 554
Joined: Dec 2009
The problem is that we shouldn't really help you with all of your requests unless you let us see what changes you made to the code. One thing would be to tell you what little drago's script offers like where the icons are placed or called from, and another to tell you what you did wrong while modifying it. We shouldn't start guessing but reading what's not working in the actual code. I hope you understand what I mean here or else I'd think I'm still falling asleep. XD
On the other hand I can easily tell you that any window would let you change its windowskin at any time by calling the following method:
@my_window.windowskin = RPG::Cache.windowskin('My Custom Windowskin')
It's probable that the script might sometimes need you to change another variable namely @windowskin_name that should be equal to a string like 'My Custom Windowskin'. The thing is that you should only call it from within the corresponding window initialize method. The self.windowskin method might also be called there but both of them will only work if placed beneath super or super(any arguments). The number of lines below the super is called doesn't really matter, but you gotta be careful, both of them need to be placed before a refresh is called.
Code: class Window_MyWindow < Window_Selectable
def initialize(x, y)
super(x, y, width, height)
# anything might go here or not
@windowskin_name = 'Guess What Skin Goes Here'
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
# anything might go here or not
refresh
end
# more code
end
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 32
Threads: 4
Joined: Apr 2016
Ah I see, sorry about that hadn't though to post the code since the changes are mainly just for size, position and visibility. Would ya believe me when I say for some reason I've had to attempt this post several times cause my browser either crashed or connection had issues, lol >_< Oh and thanks for the windowskin suggestion I'll give it a shot.
Here's the current code ^^
Code: #==============================================================================
# ** DRG - Limited Shop
# Version : 2.00
# Author : LiTTleDRAgo
#==============================================================================
#
# How To Use :
#
# Use Script Command :
#
# Script :
# Script :
# $limited_shop = {
# 0 => ['i1','i2','i3','i4'], # This means item 1,2,3,4 didn't have limit
# 1 => ['w1','w2','a1'], # This means weapon 1,2 and armor 1 can only
# # bought 1 times
# 2 => ['a2'] # This means armor 2 can be bought 2 times
#
# # This option won't do anything if SHOP_HAS_GOLD is false
# "G" => 3000 # This means the shop is have 3000 gold
# # you can't sell anything if shop have 0 gold
# # if ommitted, the shop gold is set as 0
# }
#
# To change the item inside the shop
# Script :
# shop = [@map_id, @event_id]
# item = $data_items[x] # set 'Gold' to change the shop gold
# limit = 90 # set '-' for unlimited
# limit_shop_item(shop,item,limit)
#
#==============================================================================
module LiTTleDRAgo
SCENE_LIMITED_SHOP = {
# Command , Condition for Enabled
0 => ['Buy', '$game_party.gold > 0'],
1 => ['Sell',],
}
SHOP_HAS_GOLD = true
# basically if false, you can sell anything as you please
GET_SOLD_ITEM = 1
# 0 : Item sold won't be added into buy list
# 1 : Item sold will added into buy list
# (you sold x items outside the list and that item will appeared in the
# buy list with limit of x)
# 2 : Item sold will added into buy list unlimitedly
# (you sold at least 1 items outside the list and that item will appeared
# in the buy list without limit and can be bought as many as possible)
SHOP_LAYOUT = 'Item_Lay'
SHOP_BACK = 'Mn_Back'
# Image Related Constant
# (all images must be in Graphics/Pictures or Graphics/Windowskin
SHOP_GOLD_TEXT = "Seller's Gold"
OWN_TEXT = "Own %02d"
#---------------------------------------------------------------------------
# From Falcon's Tax Script
#---------------------------------------------------------------------------
TAXRATE_TEXT = "Tax Rate"
DISCOUNT_TEXT = "Discount Rate"
TAX_COLOR = Color.new(0,25,228)
# String Related Constant
STARTING_TAX = 0
# Tax in the shop
# can be changed by $game_system.tax = (Numeric)
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :tax
#--------------------------------------------------------------------------
# * Alias Method
#--------------------------------------------------------------------------
alias init_tax initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
init_tax
@tax = LiTTleDRAgo::STARTING_TAX
end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# This class performs shop screen processing.
#==============================================================================
class Scene_LimitedShop
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
create_arrow
create_layout
create_background
create_menu
create_windows
Graphics.transition
update_premenu
update while $scene == self
dispose_premenu
Graphics.freeze
@all_windows.flatten.each {|s| s.dispose if !s.disposed?}
@all_sprite.flatten.each {|s| s.dispose if !s.disposed?}
@spriteset.dispose
end
#--------------------------------------------------------------------------
# ● update_premenu
#--------------------------------------------------------------------------
def update_premenu
while @sprite_menu[-1].x < 50 && $scene == self
@sprite_menu.each {|s| s.x = [s.x+40,50].min }
@sprite_arrow.x = [@sprite_arrow.x+3,5].min
@sprite_arrow.y = 130
update_grafis
end
update_arrow
end
#--------------------------------------------------------------------------
# ● dispose_premenu
#--------------------------------------------------------------------------
def dispose_premenu
while @sprite_menu[-1].x > -200
@sprite_menu.each_with_index {|s,i| s.x = s.x-(40+i*10) }
@sprite_arrow.x -= 15
@buy_window.x = [@buy_window.x+10,@resolution[0]].min
@sell_window.x = [@sell_window.x+10,@resolution[0]].min
update_grafis
end
end
#--------------------------------------------------------------------------
# ● create_layout
#--------------------------------------------------------------------------
def create_layout
@spriteset = Spriteset_Map.new
@layout = Sprite.new
@layout.bitmap = RPG::Cache.picture(LiTTleDRAgo::SHOP_LAYOUT).dup rescue
RPG::Cache.windowskin(LiTTleDRAgo::SHOP_BACK).dup
s = Window_Help.new
tax = ($game_system.tax||0).to_s+"%"
w = @layout.bitmap.text_size(tax).width
if tax.to_f > 0 # If there is tax
@layout.bitmap.font.color = LiTTleDRAgo::TAX_COLOR
@layout.bitmap.draw_text(0,44,@resolution[0]-(28+w),32,LiTTleDRAgo::TAXRATE_TEXT,2)
@layout.bitmap.font.color = s.normal_color
@layout.bitmap.draw_text(0,44,@resolution[0]-24,32,tax,2)
elsif tax.to_f < 0 # If there is a discount rate
@layout.bitmap.font.color = LiTTleDRAgo::TAX_COLOR
@layout.bitmap.draw_text(0,44,@resolution[0]-(28+w),32,LiTTleDRAgo::DISCOUNT_TEXT,2)
@layout.bitmap.font.color = s.normal_color
@layout.bitmap.draw_text(0,44,@resolution[0]-24,32,tax,2)
end
s.dispose
@layout.z = 100
@all_sprite << [@layout]
end
#--------------------------------------------------------------------------
# ● Draw Hemming Text
#--------------------------------------------------------------------------
def draw_hemming_text(obj, x, y, w, h, text, align = 0)
original_color = obj.font.color.dup
obj.font.color = Color.new(0,0,0,255)
obj.draw_text(x , y , w, h, text.to_s, align)
obj.draw_text(x , y+2, w, h, text.to_s, align)
obj.draw_text(x+2, y+2, w, h, text.to_s, align)
obj.draw_text(x+2, y , w, h, text.to_s, align)
obj.font.color = original_color
obj.draw_text(x+1, y+1, w, h, text.to_s, align)
end
#--------------------------------------------------------------------------
# ● create_background
#--------------------------------------------------------------------------
def create_background
@mnback = Plane.new
@mnback.bitmap = RPG::Cache.picture(LiTTleDRAgo::SHOP_BACK) rescue
RPG::Cache.windowskin(LiTTleDRAgo::SHOP_BACK)
@mnback.opacity = 255
@mnback.blend_type = 0
@all_sprite << [@mnback]
end
#--------------------------------------------------------------------------
# * Create Menu
#--------------------------------------------------------------------------
def create_menu(type = 0)
@sprite_menu.each {|s| s.dispose } if !@sprite_menu.nil?
@sprite_menu = []
temp = @index
@index = 0
@column_max = 1
@menu = LiTTleDRAgo::SCENE_LIMITED_SHOP
@menu.each {|a| b = @menu[@index]
@sprite_menu[@index] = type == 1 ? Window_Base.new(50,(48*@index)+120,160,48) :
Window_Base.new(-200-50*@index,(48*@index)+120,160,48)
@sprite_menu[@index].contents = Bitmap.new(160-32,16)
@sprite_menu[@index].back_opacity = 180
@sprite_menu[@index].contents.font.size = 20
@sprite_menu[@index].contents.font.bold = true
@sprite_menu[@index].contents.font.color =
@sprite_menu[@index].disabled_color if (b[1] && !condition_eval(b[1]))
@sprite_menu[@index].contents.draw_text(0,0,160-32,16,b[0].to_s,1)
@sprite_menu[@index].z = @layout.z + 100
@index += 1}
@index = (temp||0)
@column_max = 1
@item_max = @sprite_menu.size
@all_sprite << [@sprite_menu]
end
#--------------------------------------------------------------------------
# * Create Windows
#--------------------------------------------------------------------------
def create_windows
@all_windows = [
@help_window = Window_Help.new,
@gold_window = Window_Gold.new,
#@dummy_window = Window_Base.new(0, 128, 640, 352),
@buy_window = Window_ShopBuyLimited.new,
@sell_window = Window_ShopSellLimited.new,
@number_window = Window_ShopNumber.new,
@status_window = Window_ShopStatusLimited.new]
@help_window.opacity = 0
@help_window.y = 420
@help_window.x = -200
@gold_window.x = 480
@gold_window.y = 0
@gold_window.opacity = 0
@gold_window.back_opacity = 0
@buy_window.x = @resolution[0]-@buy_window.width
@sell_window.x = @resolution[0]-@sell_window.width
@number_window.x = @buy_window.x
@number_window.y = @buy_window.y
@buy_window.x = @resolution[0]
@sell_window.x = @resolution[0]
@all_windows.each_with_index {|s,i|
s.z = @layout.z - 2
s.active = false if [2,3,4].include?(i)
s.visible = false if [4].include?(i)}
@status_window.visible = false
@buy_window.help_window = @help_window
@sell_window.help_window = @help_window
@command_window_active = true
end
#--------------------------------------------------------------------------
# * Create Arrow
#--------------------------------------------------------------------------
VX = false
def create_arrow
@resolution = VX ? [Graphics.width,Graphics.height] : [640,480]
@all_sprite = []
@sprite_arrow = Sprite.new
if $arrow_drg_menu.nil? || $arrow_drg_menu.disposed?
bit = $game_system.windowskin_name if !VX
bit = [RPG::Cache.windowskin(bit),Rect.new(160,96,32,32)] if !VX
bit = [Cache.system("Window"),Rect.new(96,80,16,16)] if VX
@sprite_arrow.bitmap = Bitmap.new(40, 40)
@sprite_arrow.bitmap.stretch_blt(@sprite_arrow.bitmap.rect,bit[0],bit[1])
bit = @sprite_arrow.bitmap
copy = bit.clone
(0...bit.height).each{|i|(0...bit.width).each{|j|
bit.set_pixel(bit.width-i-1,j,copy.get_pixel(j,i))}}
$arrow_drg_menu = bit.dup
else
@sprite_arrow.bitmap = $arrow_drg_menu.dup
end
@sprite_arrow.mirror = true if VX
@sprite_arrow.x -= 100
@sprite_arrow.z = 7
@all_sprite << @sprite_arrow
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
update_layout_position
update_arrow
update_grafis
@all_windows.flatten.each {|s| s.update}
return update_index if @command_window_active
return update_buy if @buy_window.active
return update_sell if @sell_window.active
return update_number if @number_window.active
end
#--------------------------------------------------------------------------
# * Update Grafis
#--------------------------------------------------------------------------
def update_grafis
[Graphics,Input].each {|s|s.update}
end
#--------------------------------------------------------------------------
# * Update Layout Position
#--------------------------------------------------------------------------
def update_layout_position
@help_window.x = [@help_window.x+10,0].min
@sprite_menu.each {|s| s.y -= 10} if @sprite_arrow.y > @resolution[1]-(40+34)
@sprite_menu.each {|s| s.y += 10} if @sprite_arrow.y < 0+10
@buy_window.visible = @sell_window.visible = !@number_window.visible
if @buy_window.active
@buy_window.x = [@buy_window.x-10,@resolution[0]-@buy_window.width].max
@buy_window.x = @resolution[0] if @number_window.visible
elsif !@number_window.visible
@buy_window.x = [@buy_window.x+10,@resolution[0]].min
end
if @sell_window.active
@sell_window.x = [@sell_window.x-10,@resolution[0]-@sell_window.width].max
@sell_window.x = @resolution[0] if @number_window.visible
elsif !@number_window.visible
@sell_window.x = [@sell_window.x+10,@resolution[0]].min
end
# this is to make the background scroll/panorama
@mnback.ox -= 0
@mnback.oy -= 0
end
#--------------------------------------------------------------------------
# * Update Arrow
#--------------------------------------------------------------------------
def update_arrow
@sprite_arrow.x = [@sprite_arrow.x-10, 5].max
@sprite_arrow.y = @sprite_menu[@index].y + 10
end
#--------------------------------------------------------------------------
# ● condition_eval
#--------------------------------------------------------------------------
def condition_eval(ev='')
return true if ev.nil?
return ev if !ev.is_a?(String)
return eval (ev)
end
#--------------------------------------------------------------------------
# ● update_index
#--------------------------------------------------------------------------
def update_index
if Input.repeat?(Input::DOWN)
if (@column_max == 1 && Input.trigger?(Input::DOWN)) ||
@index < @item_max - @column_max
se_play(:cursor)
@index = (@index + @column_max) % @item_max
end
return
end
if Input.repeat?(Input::UP)
if (@column_max == 1 && Input.trigger?(Input::UP)) ||
@index >= @column_max
se_play(:cursor)
@index = (@index - @column_max) % @item_max
end
return
end
if Input.trigger?(Input::B)
se_play(:cancel)
$limited_shop = nil
$scene = Scene_Map.new
end
if Input.trigger?(Input::C)
return se_play(:buzzer) if !condition_eval(@menu[@index][1])
case @index
when 0
se_play(:decision)
@command_window_active = false
@buy_window.active = true
@buy_window.refresh
@status_window.visible = true
when 1
se_play(:decision)
@command_window_active = false
@sell_window.active = true
@sell_window.refresh
end
end
end
#--------------------------------------------------------------------------
# ● se_play
#--------------------------------------------------------------------------
def se_play(type)
a = [$game_system,$data_system]
case type
when :cursor : VX ? Sound.play_cursor : a[0].se_play(a[1].cursor_se)
when :decision : VX ? Sound.play_decision : a[0].se_play(a[1].decision_se)
when :cancel : VX ? Sound.play_cancel : a[0].se_play(a[1].cancel_se)
when :buzzer : VX ? Sound.play_buzzer : a[0].se_play(a[1].buzzer_se)
end
end
#--------------------------------------------------------------------------
# * Frame Update (when buy window is active)
#--------------------------------------------------------------------------
def update_buy
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window_active = true
@buy_window.active = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
price = @item.is_a?(RPG::Skill) ? @item.sp_cost : @item.price if !@item.nil?
if @item.nil? or price > $game_party.gold
return $game_system.se_play($data_system.buzzer_se)
end
number = case @item
when RPG::Item then $game_party.item_number(@item.id)
when RPG::Weapon then $game_party.weapon_number(@item.id)
when RPG::Armor then $game_party.armor_number(@item.id)
end || 0
return $game_system.se_play($data_system.buzzer_se) if number == 99
$game_system.se_play($data_system.decision_se)
t = @item.is_a?(RPG::Weapon) ? 1 : @item.is_a?(RPG::Armor) ? 2 :
@item.is_a?(RPG::Item) ? 0 : -1
lim = @buy_window.item_bought(@item)
d = (@buy_window.limited_shopping["#{t} #{@item.id}"]||{})['#3x53d323']||0
s = (!d.nil? && lim.nil? ? d - lim : d) || 99
max = price == 0 ? s : $game_party.gold / price
max = [max, s].min if d.abs != 999999999
max = [max, 99 - number].min
max = 1 if @item.is_a?(RPG::Skill)
@buy_window.active = false
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
end
end
#--------------------------------------------------------------------------
# * Frame Update (when sell window is active)
#--------------------------------------------------------------------------
def update_sell
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window_active = true
@sell_window.active = false
@status_window.item = nil
@help_window.set_text("")
@sell_window.instance_variable_set(:@gold, '')
return
end
if Input.trigger?(Input::C)
@item = @sell_window.item
@status_window.item = @item
gold = @buy_window.item_bought('Gold')
price = @item.nil? ? 0 : @item.price / 2
cond = LiTTleDRAgo::SHOP_HAS_GOLD ? gold < price : false
if @item == nil or @item.price == 0 || cond
return $game_system.se_play($data_system.buzzer_se)
end
$game_system.se_play($data_system.decision_se)
number = case @item
when RPG::Item then $game_party.item_number(@item.id)
when RPG::Weapon then $game_party.weapon_number(@item.id)
when RPG::Armor then $game_party.armor_number(@item.id)
end
max = number
@sell_window.active = false
(0..max).each {|s| @can_sell = s if s*price <= gold }
max = [max, @can_sell].min if LiTTleDRAgo::SHOP_HAS_GOLD
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
#--------------------------------------------------------------------------
# * Frame Update (when quantity input window is active)
#--------------------------------------------------------------------------
def update_number
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@number_window.active = false
@number_window.visible = false
case @index
when 0
@buy_window.active = true
when 1
@sell_window.active = true
@status_window.visible = false
end
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.shop_se)
@number_window.active = false
@number_window.visible = false
number = @number_window.number
case @index
when 0 # buy
price = @item.is_a?(RPG::Skill) ? @item.sp_cost : @item.price if !@item.nil?
$game_party.lose_gold(number * price)
case @item
when RPG::Item : $game_party.gain_item(@item.id, number)
when RPG::Weapon : $game_party.gain_weapon(@item.id, number)
when RPG::Armor : $game_party.gain_armor(@item.id, number)
when RPG::Skill : $game_party.actors[0].learn_skill(@item.id)
end
t = @item.is_a?(RPG::Weapon) ? 1 : @item.is_a?(RPG::Armor) ? 2 :
@item.is_a?(RPG::Item) ? 0 : -1
d = (@buy_window.limited_shopping["#{t} #{@item.id}"]||{})['#3x53d323']||0
number.times {@buy_window.item_bought(@item,1)} if d != -999999999
@buy_window.item_bought('Gold',number*price)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
create_menu(1)
when 1 # sell
$game_party.gain_gold(number * (@item.price / 2))
case @item
when RPG::Item : $game_party.lose_item(@item.id, number)
when RPG::Weapon : $game_party.lose_weapon(@item.id, number)
when RPG::Armor : $game_party.lose_armor(@item.id, number)
end
t = @item.is_a?(RPG::Weapon) ? 1 : @item.is_a?(RPG::Armor) ? 2 :
@item.is_a?(RPG::Item) ? 0 : -1
d = (@buy_window.limited_shopping["#{t} #{@item.id}"]||{})['#3x53d323']||0
number.times {@buy_window.item_bought(@item,-1)} if d != -999999999
@buy_window.item_bought('Gold',-number*@item.price/2)
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
create_menu(1)
@status_window.visible = false
end
return
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
alias drg1732013_update update
def update
drg1732013_update
unless $game_player.moving?
if !$limited_shop.nil?
all = []
$game_system.class.send(:attr_accessor ,:limited_shop)
$limited_shop.dup.each_pair {|t,i|
r = []
i = i.split(/,/) if i.is_a?(String)
i.collect.each {|s|
d = s[/i(\d+)/i] ? $data_items[$1.to_i] :
s[/w(\d+)/i] ? $data_weapons[$1.to_i] :
s[/a(\d+)/i] ? $data_armors[$1.to_i] :
s[/s(\d+)/i] ? $data_skills[$1.to_i] : 0
r << d} if i.is_a?(Array)
all << r.unshift (t)}
$limited_shop_process = all
$scene = Scene_LimitedShop.new
end
end
end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * limit_shop_item
#--------------------------------------------------------------------------
def limit_shop_item(shop,item,limit=nil)
$game_system.class.send(:attr_accessor ,:limited_shop)
map = [[@map_id, @event_id]]
map = shop if shop.is_a?(Array)
t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
item.is_a?(RPG::Item) ? 0 : -1
t = item.is_a?(String) ? item : "#{t} #{item.id}"
$game_system.limited_shop = {} if $game_system.limited_shop.nil?
$game_system.limited_shop[map] = {} if $game_system.limited_shop[map].nil?
$game_system.limited_shop[map]["#{t}"] = {} if
$game_system.limited_shop[map]["#{t}"].nil?
result = $game_system.limited_shop[map]["#{t}"]
return result['Get']||0 if limit.nil?
return result['Get'] = -limit if limit.is_a?(Integer)
return result['Get'] = 999999999
end
end
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
# This window displays number of items in possession and the actor's equipment
# on the shop screen.
#==============================================================================
class Window_ShopStatusLimited < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 200, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
self.opacity = 0
self.back_opacity = 0
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
return if @item == nil
return if @item.is_a?(RPG::Skill)
return if @item.is_a?(RPG::Item)
$game_party.actors.each_with_index {|actor,i|
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
face = sprite_character(actor)
self.contents.blt(4,64-60+face.height*i,face,face.rect)
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
elsif @item.kind == 3
item1 = $data_armors[actor.armor4_id]
else
return
end
if actor.equippable?(@item)
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
a= self.contents.font.color
self.contents.font.color = change > 0 ? Color.new(128,255,128) :
change < 0 ? Color.new(255,28,28) : normal_color
self.contents.draw_text(110, 42-32 + face.height * i, 112, 32,
sprintf("%+d", change), 2)
end
if item1 != nil
x = 4+face.width
y = 42 -64+ face.height * i + 32
bitmap = RPG::Cache.icon(item1.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y - 9, bitmap, Rect.new(0, 0, 80, 80), opacity)
# self.contents.draw_text(x + 45, y, 212, 32, item1.name)
end }
end
#--------------------------------------------------------------------------
# ● sprite_character
#--------------------------------------------------------------------------
def sprite_character(actor)
if false
bit = cache.character(actor.character_name)
sign = actor.character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = [bit.width / 3,bit.height / 4]
else
cw = [bit.width / 12,bit.height / 8]
end
index = actor.character_index
pattern = (@pattern||0) < 3 ? (@pattern||0) : 1
sx = [(index % 4 * 3 + pattern) * cw[0],
(index / 4 * 4 + (2 - 2) / 2) * cw[1]]
rect = Rect.new(sx[0], sx[1], cw[0], cw[1])
bitmap = Bitmap.new(*cw)
bitmap.blt(0,0,bit,rect)
return bitmap
end
bit = RPG::Cache.character(actor.character_name,0)
cw = [bit.width / 4, bit.height / 4]
sx = [(@pattern||0) * cw[0], (2 - 2) / 2 * cw[1]]
rect = Rect.new(sx[0], sx[1], cw[0], cw[1])
bitmap = Bitmap.new(*cw)
bitmap.blt(0,0,bit,rect)
return bitmap
end
#--------------------------------------------------------------------------
# * Set Item
# item : new item
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
#==============================================================================
# ** Window_ShopBuyLimited
#------------------------------------------------------------------------------
# This window displays buyable goods on the shop screen.
#==============================================================================
class Window_ShopBuyLimited < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# shop_goods : goods
#--------------------------------------------------------------------------
def initialize
super(0, 295, 310, 195)
@column_max = 3
self.opacity = 0
self.back_opacity = 0
@shop_goods = $limited_shop_process.dup
@get_sold = LiTTleDRAgo::GET_SOLD_ITEM
@shop_goods.each {|s| t = s[0]
next if limited_shopping['#3x53d324']
if t == 'G'
limited_shopping['#3x53d324'] = true
item_bought('Gold',$limited_shop[t])
next
end
s.each {|i| next if i.is_a?(Integer) || !t.is_a?(Integer)
d = i.is_a?(RPG::Weapon) ? 1 : i.is_a?(RPG::Armor) ? 2 :
i.is_a?(RPG::Item) ? 0 : -1
limited_shopping["#{d} #{i.id}"] = {} if limited_shopping["#{d} #{i.id}"].nil?
limited_shopping["#{d} #{i.id}"]['Get'] = -t
limited_shopping["#{d} #{i.id}"]['Get'] = 999999999 if t == 0}}
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Item Acquisition
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * update_item
#--------------------------------------------------------------------------
def item_bought(item,val=nil)
t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
item.is_a?(RPG::Item) ? 0 : -1
t = item.is_a?(String) ? item : "#{t} #{item.id}"
limited_shopping[t] = {} if limited_shopping[t].nil?
limited_shopping[t]['Get'] = 0 if limited_shopping[t]['Get'].nil?
return limited_shopping[t]['Get'] += val if !val.nil?
return limited_shopping[t]['Get']
end
#--------------------------------------------------------------------------
# * limited_shopping
#--------------------------------------------------------------------------
def limited_shopping
int = $game_system.map_interpreter.instance_variable_get(:@event_id)
map = $game_system.map_interpreter.instance_variable_get(:@map_id)
lin = [map,int]#,"#{$limited_shop}"]
$game_system.limited_shop = {} if $game_system.limited_shop.nil?
lim = $game_system.limited_shop[lin]
$game_system.limited_shop[lin] = {} if lim.nil?
return $game_system.limited_shop[lin]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = Array.new(4){[]}
limited_shopping.each_pair {|k,r| d = k.split(' ')
d.size != 2 ? next : d.map! {|s| s.to_i}
i = d[0] == 0 ? $data_items[d[1]] : d[0] == 1 ? $data_weapons[d[1]] :
d[0] == 2 ? $data_armors[d[1]] : $data_skills[d[1]]
r.each_pair {|m,v|
next if m != 'Get' || i.nil? || (v.to_i >= 0 && v != 999999999)
r['#3x53d323']= -v
r['#3x53d323']= -999999999 if v == 999999999 || @get_sold == 2
@data[d[0]+1] << i }} if @get_sold != 0
@data = @data.each {|s|s.sort!{|b,c|b.id<=>c.id}}.flatten.collect {|s|s}
@item_max = @data.size
return unless @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 80)
@data.each_index {|i| draw_item(i)}
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
item.is_a?(RPG::Item) ? 0 : -1
number = case t
when 0 : $game_party.item_number(item.id)
when 1 : $game_party.weapon_number(item.id)
when 2 : $game_party.armor_number(item.id)
end || 0
can_buy = (limited_shopping["#{t} #{item.id}"]||{})['#3x53d323']||0
can_buy = '' if can_buy <= 0
price = item.is_a?(RPG::Skill) ? item.sp_cost : item.price
conds = (price <= $game_party.gold && number.to_i < 99)
self.contents.font.color = conds ? normal_color : disabled_color
number = number > 0 ? sprintf(LiTTleDRAgo::OWN_TEXT, number) : ''
number.gsub!(' 0',' ')
pos = [4 + index % @column_max * (95),index / @column_max * 50]
rect = Rect.new(x, y, self.width / @column_max - 80, 80)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bit = RPG::Cache.icon(item.icon_name)
opc = self.contents.font.color == normal_color ? 255 : 128
con = self.contents.font.size
self.contents.blt(pos[0], pos[1], bit, Rect.new(0, 0, 80, 80), opc)
# self.contents.draw_text(pos[0]+58, pos[1], 212, 32, item.name, 0)
# self.contents.draw_text(pos[0]+25, pos[1], 88, 35, price.to_s, 2)
# self.contents.font.size = 18
# self.contents.draw_text(pos[0]+30, pos[1], 88, 32, number.to_s, 2)
# self.contents.font.size = 25
# self.contents.font.bold = true
# self.contents.draw_text(pos[0]+15, pos[1]+25, 80, 80, can_buy.to_s, 2)
# self.contents.font.size = con
# self.contents.font.bold = false
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ** Window_ShopSellLimited
#------------------------------------------------------------------------------
# This window displays items in possession for selling on the shop screen.
#==============================================================================
class Window_ShopSellLimited < Window_ShopBuyLimited
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
@data = $data_items.map{|i| i if $game_party.item_number(i.id) > 0 }.compact
@data += $data_weapons.map{|i| i if $game_party.weapon_number(i.id) > 0 }.compact
@data += $data_armors.map{|i| i if $game_party.armor_number(i.id) > 0 }.compact
# If item count is not 0, make a bitmap and draw all items
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 80)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
t = item.is_a?(RPG::Weapon) ? 1 : item.is_a?(RPG::Armor) ? 2 :
item.is_a?(RPG::Item) ? 0 : -1
number = case t
when 0 : $game_party.item_number(item.id)
when 1 : $game_party.weapon_number(item.id)
when 2 : $game_party.armor_number(item.id)
end || 0
gold = item_bought('Gold')
gold = gold >= item.price/2 if LiTTleDRAgo::SHOP_HAS_GOLD
gold = (item.price>0&&gold)
self.contents.font.color = gold ? normal_color : disabled_color
pos = [4 + index % @column_max * (95),index / @column_max * 50]
rect = Rect.new(x, y, self.width / @column_max - 80, 80)
# self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bit = RPG::Cache.icon(item.icon_name)
opc = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(pos[0], pos[1]+4, bit, Rect.new(0, 0, 80, 80), opc)
# self.contents.draw_text(pos[0]+28, pos[1], 212, 32, item.name, 0)
self.contents.draw_text(pos[0]+70, pos[1], 16, 80, "x", 1)
self.contents.draw_text(pos[0]+75, pos[1], 24, 80, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
return if @gold == item_bought('Gold') && @old_item == self.item
return unless LiTTleDRAgo::SHOP_HAS_GOLD
@old_item = self.item
@gold = item_bought('Gold')
s = @help_window.width - 40
@help_window.contents.fill_rect(Rect.new(420,0,s,32),Color.new(0,0,0,0))
@help_window.contents.font.size -= 4
@help_window.contents.draw_text(420, 0, s, 32, LiTTleDRAgo::SHOP_GOLD_TEXT)
@help_window.contents.draw_text(4, 0, s, 32, item_bought('Gold').to_s, 2)
@help_window.contents.font.size += 4
end
end
#==============================================================================
# ** RPG::Something
#------------------------------------------------------------------------------
# This module handles data item, weapon, and armor
#==============================================================================
['Item','Weapon','Armor'].each {|clas| eval "
module RPG
class #{clas}
alias tax price unless method_defined?(:tax)
def price() (tax + tax*($game_system.tax||0) / 100).to_i end
end
end#"}
______・*。☆彡Ƹ̵̡Ӝ̵̨̄Ʒ*~゚・。 )O( 。・゚~*Ƹ̵̡Ӝ̵̨̄Ʒミ☆。*・______
MoonFaerie Studio: (Formerly LunarBerry Studio)
http://www.moonfaeriestudio.com
Deviantart gallery: https://www.deviantart.com/moonfaeriestudio
--------------・*。☆*~゚・。Ƹ̵̡Ӝ̵̨̄Ʒ。・゚~*☆。*・--------------
Current Game Project(s):
In collaboration w/Siletrea:
----------------------------------
My Personal Project(s):
I do all sorts of arts and crafts :P ... and randomly too
Posts: 4,634
Threads: 554
Joined: Dec 2009
In lines 429 through 432...
Code: @buy_window.active = false
@number_window.set(@item, max, price)
@number_window.active = true
@number_window.visible = true
You would need to replace it with...
Code: $game_party.gain_item(@item.id, 1)
$game_party.lose_gold(price)
So you would buy a single item at a time and lose gold, but you wouldn't stop watching the buy window at all. If you don't need to purchase a single item at a time but 10, then replace 1 with 10 or any other number you'd need to be there.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Posts: 32
Threads: 4
Joined: Apr 2016
Heya, I've tried both your suggestions and I thank you for your time to help me ^^
The windowskin didn't turn out as I'd hoped (all windowskin in script actually called on the background image, so when I was matching things up it made the custom windowskin tile everywhere or otherwise had no effect, lol) but ironically I figured out a weird trick to get it to work the way I wanted. So that issue is resolved for now.
For the "amount window", it did give the item when buying and kept on the buying screen but it didn't remove the item from the shop after purchase (which enables one to keep buying the same item in unlimited amounts, though one at a time) and also the selector graphic from the windowskin wasn't present so it would be tricky to see what you are actually buying until you check inventory.
So, what I tried since that's the area for the effect... (after changing all the true/false to see what happens, lol)
I changed this to false in the buy section
@number_window.visible = false
And this "removed" that window and allowed the buying of items as usual and stay on that window, which was great, but items still scroll on and off the scene as if it's still switching over (as in items roll in, select one to buy, it rolls out and you reconfirm the selection again and everything but that "bought" item rolls in again.)
I found the area that seems to effect the scrolling in/out:
Code: #--------------------------------------------------------------------------
# * Update Layout Position
#--------------------------------------------------------------------------
def update_layout_position
@help_window.x = [@help_window.x+10,0].min
@sprite_menu.each {|s| s.y -= 10} if @sprite_arrow.y > @resolution[1]-(40+34)
@sprite_menu.each {|s| s.y += 10} if @sprite_arrow.y < 0+10
@buy_window.visible = @sell_window.visible = !@number_window.visible
if @buy_window.active
@buy_window.x = [@buy_window.x-10,@resolution[0]-@buy_window.width].max
@buy_window.x = @resolution[0] if @number_window.visible
elsif !@number_window.visible
@buy_window.x = [@buy_window.x+10,@resolution[0]].min
end
if @sell_window.active
@sell_window.x = [@sell_window.x-10,@resolution[0]-@sell_window.width].max
@sell_window.x = @resolution[0] if @number_window.visible
elsif !@number_window.visible
@sell_window.x = [@sell_window.x+10,@resolution[0]].min
end
when I do adjust the buy_window.x to "0"
elsif !@number_window.visible
@buy_window.x = [@buy_window.x+0,@resolution[0]].min
It would roll items in (which was fine) and did keep the items on screen (though you still have to double select to make a purchase) but then once you leave the buy mode the items don't clear out or if there isn't any items, the selector graphic doesn't clear. So if you switch to sell mode, the items in inventory to sell will overlap the buy items. At least until you actually leave shop and then it starts to roll out/clears. But other than that, it's sooo close to being functionally done >_<
So now essentially I'm hoping to have two things happen.
1. Preferably not scroll in and out each time you buy something and clear out when leaving buy mode. I actually don't mind the double confirmation, as that can give players a sort of "buffer" to help prevent accidental buying, etc.
2. GET_SOLD_ITEM = 1
Item sold won't be added into buy list when set to "0" but buy list doesn't even appear at all even when there are items setup for sale in the call script. This is pretty much the case even on a clean script/demo. Would like to have it setup to where the buy list will show up if there are items setup for sale. This would actually be great because the creator of this game project wants to setup some shops that are sell only and having this work like this will allow for that. Or maybe if there's another way around to make the buy and sell ability separate so that one shop can be buy only and one sell only.
Again any help would be very appreciated ^^;
______・*。☆彡Ƹ̵̡Ӝ̵̨̄Ʒ*~゚・。 )O( 。・゚~*Ƹ̵̡Ӝ̵̨̄Ʒミ☆。*・______
MoonFaerie Studio: (Formerly LunarBerry Studio)
http://www.moonfaeriestudio.com
Deviantart gallery: https://www.deviantart.com/moonfaeriestudio
--------------・*。☆*~゚・。Ƹ̵̡Ӝ̵̨̄Ʒ。・゚~*☆。*・--------------
Current Game Project(s):
In collaboration w/Siletrea:
----------------------------------
My Personal Project(s):
I do all sorts of arts and crafts :P ... and randomly too
|