TRIHAN'S PROFILE

Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Sidhe Quest
When everything goes wrong, it's up to our heroes to go and do a bunch of other stuff!

Search

Filter

[VXA] Script help: Message boxes in scenes other than map

It wasn't that, GRS; it was that the sell window was being reactivated right after the message box. I've done it as a custom window now and it all works perfectly.

[VXA] Script help: Message boxes in scenes other than map

Okay, this is driving me absolutely nuts so hopefully someone will know the answer.

I'm currently working on a script request for a friend where he needs shops to track what items are sold, and unlock new items depending on what you've sold to the shop. That part works perfectly, yay!

However, I also added a message box that tells you which items were unlocked (so that you know what shiny new toys you just got, obviously). The problem is that although the message box appears, the shop is still active and pressing enter doesn't get rid of the message. I need input for the shop to wait until the message box is done with, but no matter what I try I can't seem to figure out how.

Here's the code I have so far:

$imported = {} if $imported.nil?
$imported['cshop'] = true

puts 'Load: Shop script by Clyve'

module CSHOP
  
  module REGEXP
    ITEM_REQ = /<require ([IWA])(\d+), (\d+)>/i
  end
  
end

class RPG::ShopSales
  #------------------------
  attr_accessor :item_sales
  attr_accessor :weapon_sales
  attr_accessor :armor_sales
  #------------------------
  def initialize
    # arrys that track how many each item has been sold. index = item id
    @item_sales   = []
    @weapon_sales = []
    @armor_sales  = []
  end
end
    
class Scene_Shop < Scene_MenuBase
    
  alias :shopsales_prepare :prepare
  def prepare(goods, purchase_only)
    shopsales_prepare(goods, purchase_only)
    add_available_goods
  end
  
  alias :shopsales_start :start
  def start
    shopsales_start
    @message_window = Window_Message.new
  end
    
  def add_available_goods
    # CHECK NOTETAGS AND WHETHER $data_shopsales's DATA IS ENOUGH
    # FOR THE ITEMS TO BE AVAILABLE OR NOT, THEN ADD THE ITEM TO @goods
    # IF ITS AVAILABLE.
    # @goods is an array with three values
    # @goods[0] is either 0, 1, or 2.
    #    0 is Items ($data_items)
    #    1 is Weapons ($data_weapons)
    #    2 is Armors ($data_armors)
    # @goods[1] is the index of the item.
    # @goods[2] is a different price than the one in the database, it needs to
    # be set to 0 for it to use the price in the database
    for i in 1...$data_items.size
      if !$data_items[i].sell_req.empty?
        include = true
        for req in $data_items[i].sell_req
          if req[0] == 0
            if $data_shopsales.item_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 1
            if $data_shopsales.weapon_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 2
            if $data_shopsales.armor_sales[req[1]] < req[2]
              include = false
            end
          end
        end
        @goods.push([0, i, 0]) if include == true
      end
      # This is where you'll use @goods[0]
    end
    for i in 1...$data_weapons.size
      if !$data_weapons[i].sell_req.empty?
        include = true
        for req in $data_weapons[i].sell_req
          if req[0] == 0
            if $data_shopsales.item_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 1
            if $data_shopsales.weapon_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 2
            if $data_shopsales.armor_sales[req[1]] < req[2]
              include = false
            end
          end
        end
        @goods.push([1, i, 0]) if include == true
      end
      # This is where you'll use @goods[1]
    end
    for i in 1...$data_armors.size
      if !$data_armors[i].sell_req.empty?
        include = true
        for req in $data_armors[i].sell_req
          if req[0] == 0
            if $data_shopsales.item_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 1
            if $data_shopsales.weapon_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 2
            if $data_shopsales.armor_sales[req[1]] < req[2]
              include = false
            end
          end
        end
        @goods.push([2, i, 0]) if include == true
      end
      # This is where you'll use @goods[2]
    end
  end
    
  # Increase Items of Type Sold
  alias :shopsales_do_sell :do_sell
  def do_sell(number)
    shopsales_do_sell(number)
    added_items = []
    case item_type
    when 0
      $data_shopsales.item_sales[@item.id] += number
      # This is where you'll use @goods[0]
    when 1
      $data_shopsales.weapon_sales[@item.id] += number
      # This is where you'll use @goods[1]
    when 2
      $data_shopsales.armor_sales[@item.id] += number
      # This is where you'll use @goods[2]
    end
    for i in 1...$data_items.size
      if !$data_items[i].sell_req.empty?
        include = true
        for req in $data_items[i].sell_req
          if req[0] == 0
            if $data_shopsales.item_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 1
            if $data_shopsales.weapon_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 2
            if $data_shopsales.armor_sales[req[1]] < req[2]
              include = false
            end
          end
        end
        if include == true && !@goods.include?([0, i, 0])
          @goods.push([0, i, 0])
          added_items.push($data_items[i].name)
        end
      end
    end
    for i in 1...$data_weapons.size
      if !$data_weapons[i].sell_req.empty?
        include = true
        for req in $data_weapons[i].sell_req
          if req[0] == 0
            if $data_shopsales.item_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 1
            if $data_shopsales.weapon_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 2
            if $data_shopsales.armor_sales[req[1]] < req[2]
              include = false
            end
          end
        end
        if include == true && !@goods.include?([1, i, 0])
          @goods.push([1, i, 0])
          added_items.push($data_weapons[i].name)
        end
      end
    end
    for i in 1...$data_armors.size
      if !$data_armors[i].sell_req.empty?
        include = true
        for req in $data_armors[i].sell_req
          if req[0] == 0
            if $data_shopsales.item_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 1
            if $data_shopsales.weapon_sales[req[1]] < req[2]
              include = false
            end
          elsif req[0] == 2
            if $data_shopsales.armor_sales[req[1]] < req[2]
              include = false
            end
          end
        end
        if include == true && !@goods.include?([2, i, 0])
          @goods.push([2, i, 0])
          added_items.push($data_armors[i].name)
        end
      end
    end
    if !added_items.empty?
      $game_message.add("Thanks! I can now sell you the following items:")
      added_items.each_with_index do |item, i|
        if i < added_items.size - 1
          $game_message.add("#{item}, ")
        else
          $game_message.add("#{item}")
        end
      end
      @message_window.update
    end
  end
    
  # Checks Item Type of @item
  def item_type
    if @item.is_a?(RPG::Item)
      return 0
    elsif @item.is_a?(RPG::Weapon)
      return 1
    elsif @item.is_a?(RPG::Armor)
      return 2
    end
  end
end
    
module DataManager
    
  # Initialize Shop Sales data
  class <<self; alias shopsales_load_database load_database; end
  def self.load_database
    shopsales_load_database
    $data_shopsales = RPG::ShopSales.new
    load_item_notetags
    init_shopsales_data
  end
  
  def self.load_item_notetags
		groups = [$data_items, $data_weapons, $data_armors]
		for group in groups
			for obj in group
				next if obj.nil?
				obj.load_item_notetags
			end
		end
		puts "Read: Item Requirements Notetags"
	end
    
  def self.init_shopsales_data
    for index in 0..$data_items.size
      $data_shopsales.item_sales[index] = 0
    end
    for index in 0..$data_weapons.size
      $data_shopsales.weapon_sales[index] = 0
    end
    for index in 0..$data_armors.size
      $data_shopsales.armor_sales[index] = 0
    end
  end
    
  # Dump Shop Sales data into save file
  class <<self; alias shopsales_make_save_contents make_save_contents; end
  def self.make_save_contents
    shopsales_make_save_contents
    contents[:shopsales] = $data_shopsales
    contents
  end
    
  # Load Shop Sales data from save file
  class <<self; alias shopsales_extract_save_contents extract_save_contents; end
  def self.extract_save_contents(contents)
    shopsales_extract_save_contents(contents)
    if contents[:shopsales]
      $data_shopsales = contents[:shopsales]
    else
      $data_shopsales = RPG::ShopSales.new
      init_shopsales_data
    end
  end
end

class RPG::BaseItem
  attr_reader :sell_req
  def load_item_notetags
    @sell_req = []
		@note.split(/[\r\n]+/).each do |line|
			case line
			when CSHOP::REGEXP::ITEM_REQ
        case $1
        when "I"
          @sell_req.push([0, $2.to_i, $3.to_i])
        when "W"
          @sell_req.push([1, $2.to_i, $3.to_i])
        when "A"
          @sell_req.push([2, $2.to_i, $3.to_i])
        end
      end
		end
	end
end

If anyone can offer any insight on how to suppress input for a scene while a message is showing (and for that matter how to get the message box to recognise input) I would be really appreciative.

Paper Mafia

Shinan: 6
CAVE_DOG_IS_BACK
Zeuzio
Gourd_Clae
chana
Lily
MrChearlie
Yellow Magic
Little Wing Guy
???

Gourd_Clae: 0
Dudesoft

ldida1: 4
MrChearlie
rabitZ
MirrorMasq
chana
MrChearlie

Marrend: 1
Dudesoft

Zeuzio: 1
Shinan

------

"Guys, I'm totally not a villain!" protests Shinan.

"Well...that sounds pretty believable," agree some others, switching to ldida1.

When all is said and done, the votes are tied! This means that today's ejection from the theatre will be determined by the benevolent overlord, who is overseeing proceeding from his throne on high.

The Benevolent Overlord spins his Wand of Russian Roulette, which lands squarely on...Shinan!

Shinan's fans unfortunately aren't enough to save him.

Shinan has been ejected. He was a hero.

"Fuck this, I'm off." says Lily suddenly.

Lily has ejected herself. She was a villain.

Villain phase 2 has begun. It will end at 6:00PM GMT on May 7th.

All fandom has been reset.

Paper Mafia

Hero phase has ended and no further posting is allowed. End of phase flavour incoming.

Paper Mafia

Shinan: 4
CAVE_DOG_IS_BACK
Zeuzio
Gourd_Clae
chana
Lily
MrChearlie

Gourd_Clae: 0
Dudesoft

ldida1: 3
MrChearlie
rabitZ
MirrorMasq
chana

Marrend: 1
Dudesoft

Hero phase ends in 24 hours and 10 minutes. As it stands, Shinan will be ejected.

Paper Mafia

Okay, I sent Ark a role PM and he read it. I'm not going to faff about with trying to get a replacement, nor do I think it's worth sending him a reminder.

Suddenly, Pirahna Plants burst from nowhere and drag Ark screaming from the theatre!

It's cool though, he was only an audience member.

Votals incoming.

Paper Mafia

Sorry guys, I didn't realise there were people who hadn't been posting.

I'll give it until today's update and if there are still absent players I'll modkill them.

Paper Mafia

author=Gourd_Clae
Whoops nevermind Marrend.

I'm not sure how Trihan got Marrend out of Shinan. I don't even think Marrend is suspicious.


It was because in the post where you voted for Shinan, you were saying something to Marrend directly before it. I saw Marrend's name and somehow in my mind that's where your vote was.

Paper Mafia

Disregard that, I misread Gourd's post.

Yeah, Shinan has 3 votes.

Paper Mafia

Marrend, Gourd voted for you. You haven't voted yet.