Kingdom Ablaze
Sponsor
ok so im working on modifying my Chest data script to run off comments in events instead of my old format. i have the data processing part down. but i have no idea how to make it so when the player talks to an event the chest window will open. so to clarify im asking some one to show me what i have to do to make it so when a event is selected that has my comment in it i can open a window, i think from there i can figure everything else out.
here is what i have done in my script in case you need it for what ever reason, i didn't include my window because im still rewriting it to work better.
[rgss]#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event
alias_method :game_event_initialize, :initialize
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :chestdata # chestdata
#--------------------------------------------------------------------------
# * Object Initialization
# map_id : map ID
# event : event (RPG::Event)
#--------------------------------------------------------------------------
def initialize(map_id, event)
game_event_initialize(map_id, event)
@items,@weaps,@armor = check_comments
@chestdata = []
@chest_counter = 0
@has_items = false
if @chestdata.size > 0
@has_items = true
end
end
#--------------------------------------------------------------------------
# * Determine if event has items
#--------------------------------------------------------------------------
def has_items?
return @has_items
end
#--------------------------------------------------------------------------
# * Combine chest data for display
#--------------------------------------------------------------------------
def all_data
# Erase old combined chest data because data may have been edited since
# last data creation.
@has_items = false
@chest_counter = 0
for i in 0...chestdata.size
@chestdata.delete(i)
end
# Make new combinied chest data
for i in 0...@items.size
@chestdata[@chest_counter] = @items.to_i
@chest_counter += 1
end
for i in 0...@weaps.size
@chestdata[@chest_counter] = @items.to_i
@chest_counter += 1
end
for i in 0...@armor.size
@chestdata[@chest_counter] = @items.to_i
@chest_counter += 1
end
# Set has_items to true if there are any items
if @chestdata.size > 0
@has_items = true
end
end
#--------------------------------------------------------------------------
# * Check for chest comments
#--------------------------------------------------------------------------
def check_comments
@items = []
@weaps = []
@armor = []
@cut = 2
@count = 0
for ec in @list
# Skip if not comment or not comment next line
next unless [108, 408].include?(ec.code)
# Read Event Comment & Turn Downcase
comment = ec.parameters[0].downcase
# If Comment Include Parameters
if comment.include?('item|')
# Remove starting info
@data = comment.split("|")
# Grab Items data
@data = @data[1].split("[")[1].split("]")[0]
# Loop through each item. good to know it counts how many loop based on
# the number of commas. was a pain for me get the right number to loop
# untill i remembered the count method.
for i in 0...(@data.count(","))+1
@items = @data.split(",")[0]
@data = @data.slice!(@cut...@data.length)
@count += 1
# account for double digits.
if @count == 9
@cut = 3
end
end
end
# end items start weapons, reset @cut and @count
@cut = 2
@count = 0
if comment.include?('wep|')
# Remove starting info
@data = comment.split("|")
# Grab Weapons data
@data = @data[1].split("[")[1].split("]")[0]
# Loop through each weapon. good to know it counts how many loop based
# on the number of commas. was a pain for me get the right number to
# loop untill i remembered the count method.
for i in 0...(@data.count(","))+1
@weaps = @data.split(",")[0]
@data = @data.slice!(@cut...@data.length)
@count += 1
# account for double digits.
if @count == 9
@cut = 3
end
end
end
# end weapons start armor, reset @cut and @count
@cut = 2
@count = 0
if comment.include?('armor|')
# Remove starting info
@data = comment.split("|")
# Grab Armor data
@data = @data[1].split("[")[1].split("]")[0]
# Loop through each armor. good to know it counts how many loop based
# on the number of commas. was a pain for me get the right number to
# loop untill i remembered the count method.
for i in 0...(@data.count(","))+1
@armor = @data.split(",")[0]
@data = @data.slice!(@cut...@data.length)
@count += 1
# account for double digits.
if @count == 9
@cut = 3
end
end
end
end
return @items,@weaps,@armor
end
end
[/rgss]
here is what i have done in my script in case you need it for what ever reason, i didn't include my window because im still rewriting it to work better.
[rgss]#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event
alias_method :game_event_initialize, :initialize
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :chestdata # chestdata
#--------------------------------------------------------------------------
# * Object Initialization
# map_id : map ID
# event : event (RPG::Event)
#--------------------------------------------------------------------------
def initialize(map_id, event)
game_event_initialize(map_id, event)
@items,@weaps,@armor = check_comments
@chestdata = []
@chest_counter = 0
@has_items = false
if @chestdata.size > 0
@has_items = true
end
end
#--------------------------------------------------------------------------
# * Determine if event has items
#--------------------------------------------------------------------------
def has_items?
return @has_items
end
#--------------------------------------------------------------------------
# * Combine chest data for display
#--------------------------------------------------------------------------
def all_data
# Erase old combined chest data because data may have been edited since
# last data creation.
@has_items = false
@chest_counter = 0
for i in 0...chestdata.size
@chestdata.delete(i)
end
# Make new combinied chest data
for i in 0...@items.size
@chestdata[@chest_counter] = @items.to_i
@chest_counter += 1
end
for i in 0...@weaps.size
@chestdata[@chest_counter] = @items.to_i
@chest_counter += 1
end
for i in 0...@armor.size
@chestdata[@chest_counter] = @items.to_i
@chest_counter += 1
end
# Set has_items to true if there are any items
if @chestdata.size > 0
@has_items = true
end
end
#--------------------------------------------------------------------------
# * Check for chest comments
#--------------------------------------------------------------------------
def check_comments
@items = []
@weaps = []
@armor = []
@cut = 2
@count = 0
for ec in @list
# Skip if not comment or not comment next line
next unless [108, 408].include?(ec.code)
# Read Event Comment & Turn Downcase
comment = ec.parameters[0].downcase
# If Comment Include Parameters
if comment.include?('item|')
# Remove starting info
@data = comment.split("|")
# Grab Items data
@data = @data[1].split("[")[1].split("]")[0]
# Loop through each item. good to know it counts how many loop based on
# the number of commas. was a pain for me get the right number to loop
# untill i remembered the count method.
for i in 0...(@data.count(","))+1
@items = @data.split(",")[0]
@data = @data.slice!(@cut...@data.length)
@count += 1
# account for double digits.
if @count == 9
@cut = 3
end
end
end
# end items start weapons, reset @cut and @count
@cut = 2
@count = 0
if comment.include?('wep|')
# Remove starting info
@data = comment.split("|")
# Grab Weapons data
@data = @data[1].split("[")[1].split("]")[0]
# Loop through each weapon. good to know it counts how many loop based
# on the number of commas. was a pain for me get the right number to
# loop untill i remembered the count method.
for i in 0...(@data.count(","))+1
@weaps = @data.split(",")[0]
@data = @data.slice!(@cut...@data.length)
@count += 1
# account for double digits.
if @count == 9
@cut = 3
end
end
end
# end weapons start armor, reset @cut and @count
@cut = 2
@count = 0
if comment.include?('armor|')
# Remove starting info
@data = comment.split("|")
# Grab Armor data
@data = @data[1].split("[")[1].split("]")[0]
# Loop through each armor. good to know it counts how many loop based
# on the number of commas. was a pain for me get the right number to
# loop untill i remembered the count method.
for i in 0...(@data.count(","))+1
@armor = @data.split(",")[0]
@data = @data.slice!(@cut...@data.length)
@count += 1
# account for double digits.
if @count == 9
@cut = 3
end
end
end
end
return @items,@weaps,@armor
end
end
[/rgss]