This is my first script! This script allows you to show details for your Items, Weapons, Armors, and Skills. This is just a very basic system. Features
Show Item details!
Show Armor details!
Show Weapon details!
Show Skill details!
Display 10 lines of text!
#===============================================================================
# Expanded Details
# by: Xuroth
# v0.7
#-------------------------------------------------------------------------------
# Intro: This script allows you to display details for any selected item.
# You can use this for adding a bit more depth to your game. To view
# details, just go to your Item Menu and press the Shift key!
#
#
# Features:
# - Display 10 lines of text for more info than other similar scripts
# - Reads data from text files
# - Skill Details
#
# Planned Future Features:
# - Unlimited lines
# - Optional Detailed Stats
# - and more!
#
#-------------------------------------------------------------------------------
# How to set up:
# You will need 3 text files named 'Item_Detail.rxdata',
# 'Weapon_Detail.rxdata', and 'Armor_Detail.rxdata'. Each of these are
# just simple text files renamed with the extension. Inside each file,
# every 10 lines is used for each item. In those 10 lines, write what-
# ever strikes your fancy. Thats it! The system will read the files and
# display your text in a window
#
#-------------------------------------------------------------------------------
# Version History
# -0.5 Initial Completion
# -0.6 Updated some code, bug fixes
# -0.7 Added Skill Descriptions
#
#-------------------------------------------------------------------------------
# Credits:
# - Xuroth (for script)
# - game_guy (for help with alias)
# - DerVVulfman (help with basic coding and original idea)
# - Blizzard
# - ForeverZer0
#
# Thanks to all the above scripters! Just by making your awesome scripts, you
# all have inspired me to take up the art. Thanks for helping me with various
# problems, and I hope to learn more from all of you!
#
#===============================================================================
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
##
## Configuration
##
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# For now, there are only a few constants that can be edited to customize the
# the look. In future versions, there will be more to change as I add new
# features.
# D_FONTTYPE -Define which font to use
# D_FONTSIZE -font size
# D_ITEMCOLOR -Item name color (R, G, B, O)
# D_DESCCOLOR -Description text color
# Thats it for now. Enjoy!
#-------------------------------------------------------------------------------
D_FONTTYPE = 'Tahoma'
D_FONTSIZE = 20
D_ITEMCOLOR = Color.new(255, 255, 255, 255) #White
D_DESCCOLOR = Color.new(255, 255, 255, 255) #White
#-------------------------------------------------------------------------------
#
# End of Configuration
#
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_Details < Window_Base
#--------------------------------------------------
# => Sets up the window
#--------------------------------------------------
def initialize
super(0, 0, 640, 480) #call from Window_Base to create a window
self.contents = Bitmap.new(width - 32, height - 32) #set up the text
self.contents.font.name = D_FONTTYPE
self.contents.font.size = D_FONTSIZE
self.contents.font.color = D_ITEMCOLOR
#z-layer makes the detail window appear overtop all the item windows
self.z += 10
@details = [] #declares a variable to hold the details information later
#call the refresh_reset method
refresh_reset
end
#--------------------------------------------------
# => Resets the window so text doesn't get messy
#--------------------------------------------------
def refresh_reset
#clears the window
self.contents.clear
end
#--------------------------------------------------
# => Refreshes the window with details
#--------------------------------------------------
def refresh
#set a local variable to the global $selected_item value
item = $selected_item.id
#tests to see if item is an Item
if $selected_item.is_a?(RPG::Item)
#get the item's name
item_name = $data_items[item].name
#get the item's icon
item_icon = $data_items[item].icon_name
#and set a variable to hold the file name. named the same as other
#detail scripts in case you want to use this one (for some reason)
#and dont want to re-write all your lore (though your formatting
#will likely need to be edited.)
@detail_file = File.open("Data/Item_Detail.rxdata")
#tests to see if the item is a Weapon
elsif $selected_item.is_a?(RPG::Weapon)
#get the name, icon, and file name as before
item_name = $data_weapons[item].name
item_icon = $data_weapons[item].icon_name
@detail_file = File.open("Data/Weapon_Detail.rxdata")
#tests to see if the item is an Armor
elsif $selected_item.is_a?(RPG::Armor)
#and again, fetch name and icon
item_name = $data_armors[item].name
item_icon = $data_armors[item].icon_name
@detail_file = File.open("Data/Armor_Detail.rxdata")
elsif $selected_item.is_a?(RPG::Skill)
item_name = $data_skills[item].name
item_icon = $data_skills[item].icon_name
@detail_file = File.open("Data/Skill_Detail.rxdata")
end
#sets a variable to hold the icon
bitmap = RPG::Cache.icon(item_icon)
#now draw the icon!
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
self.contents.draw_text(32, 8, 256, 24, item_name)
#now call the method that actually gets and displays the detailed info!
fetch_details(item)
show_details(3, 72)
end
#--------------------------------------------------
# => Gets Details and stores them into an array
#--------------------------------------------------
def fetch_details(item)
#array that holds details:
description =
[
item * 10,
item * 10 + 1,
item * 10 + 2,
item * 10 + 3,
item * 10 + 4,
item * 10 + 5,
item * 10 + 6,
item * 10 + 7,
item * 10 + 8,
item * 10 + 9
]
#stores all lines into variable
@details = @detail_file.readlines
#now set up !?Another?! variable used for processing the data.
@desc = []
#now set it to hold only 10 lines at a time!
for i in 0..9
@desc[i] = @details[description[i]]
end
#finished! now run the display details method!
return
end
#--------------------------------------------------
# => Displays the contents of the array as text
#--------------------------------------------------
def show_details(x, y)
#draw the Description title (next version this will be easier to change!)
self.contents.font.color = normal_color
self.contents.draw_text(x, y - 32, 640, 32, "Description:")
self.contents.font.color = normal_color
#draw all 10 lines normally
for i in 0..9
if @desc[i] == nil #checks if i is nil. if so, fixes it!
@desc[i] = ' '
else
self.contents.draw_text(x, y, 640, 32, @desc[i])
y += 20
end
end
#method end
end
#class end
end
#===================================================================
# >>> Scene_Item
#===================================================================
# This edits several methods via alias
# and adds a new method for checking
# input.
alias detail_update update
def update
detail_update
$selected_item = @item_window.item
if @item_window.active
update_item
return
end
if @detail_window.active
update_details
return
end
end
def update_details
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless $game_party.item_can_use?(@item.id)
@item_window.refresh
end
@item_window.active = true
@detail_window.visible = false
@detail_window.active = false
@detail_window.refresh_reset
return
end
end
alias new_update_item update_item
def update_item
new_update_item
if Input.trigger?(Input::A)
# Below if-then statement checks for blank item, and cancels
# the input.
if $selected_item == nil
return
end
$game_system.se_play($data_system.decision_se)
@detail_window.refresh
@item_window.active = false
@detail_window.visible = true
@detail_window.active = true
end
end
end
alias skill_detail_main main
def main
@detail_window = Window_Details.new
@detail_window.visible = false
@detail_window.active = false
skill_detail_main
@detail_window.dispose
end
alias detail_update update
def update
detail_update
$selected_item = @skill_window.skill
if @skill_window.active
update_skill
return
end
if @detail_window.active
update_details
return
end
end
def update_details
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
unless @actor.skill_can_use?(@skill.id)
@skill_window.refresh
end
@skill_window.active = true
@detail_window.visible = false
@detail_window.active = false
@detail_window.refresh_reset
return
end
end
alias new_update_skill update_skill
def update_skill
new_update_skill
if Input.trigger?(Input::A)
if $selected_item == nil
return
end
$game_system.se_play($data_system.decision_se)
@detail_window.refresh
@skill_window.active = false
@detail_window.visible = true
@detail_window.active = true
end
end
end
Instructions
You need 4 text files to make this work. They have to be named "Armor_Detail.rxdata", "Item_Detail.rxdata", "Skill_Detail.rxdata", and "Weapon_Detail.rxdata" (without the quotes). Place these in your /Data folder.
Also, due to my scripting ability (or lack thereof), each item starts every 11th line. The first armor will display from line 11 to line 20 of the text file. The first ten lines of each file should be either empty or contain the placeholder text I included in the demo.
I will try to update this later to allow the script to automagically determine the number of lines, and possibly make the window scrollable. But for now, this is it.
To use this, just insert above main. It only edits Scene_Item and Scene_Skill so as long as its below those, it should work just fine. Compatibility
Probably won't work with custom item windows or skill windows such as those used by fancy CMS'. This was designed from the DMS, and I am a n00b scripter after all. I may figure out a way to increase compatibility with CMS' later
Also, this script uses aliased methods and does not rewrite any existing methods, only adds to them. Credits and Thanks
Xuroth (for making this script)
Jackatrades (for the original idea)
game_guy (for help with alias)
DerVVulfman (for help with basic coding and the original idea)
Blizzard (Inspiration)
ForeverZer0 (Inspiration and help with coding)
Thanks to you guys, I was able to complete this system. You guys Rock! Author's Notes
Remember: You need the text files re-named as .rxdata files. You can grab mine from the demo and edit them to match your game (if you use it)
This is a VERY basic system. It has potential for more, but it is only my FIRST script.
Post any bugs you find here, and I will try to fix them... if I can.
This is actually really handy, think I might put this to use. Not sure about using for what it's shown as here though but it's given me something to think about.
@Holder2: When I "finish" this system, it can be used for much more than just item/armor/weapon/skill. I plan on updating the interface, adding compatibility with some CMS' and adding some other features. Glad it could help you!
@MetalRenard: Thanks! This was just an idea for a first script, and I'm glad people seem to like it.
Somebody was needing details in the shop menu as well, so I wrote this addition up real quick. You can view the detail window by pressing Input::A (the Shift button by default).
class Scene_Shop
alias_method :itemdetails_scnshop_main, :main
def main
# Create window, turn off visibility and active
@detail_window = Window_Details.new
@detail_window.visible = false
@detail_window.active = false
# The usual
itemdetails_scnshop_main
# Dispose of window when main loop finished
@detail_window.dispose
end
alias_method :itemdetails_scnshop_update, :update
def update
# The usual
itemdetails_scnshop_update
# Update the window
@detail_window.update
end
alias_method :itemdetails_scnshop_updatebuy, :update_buy
def update_buy
# The usual
itemdetails_scnshop_updatebuy
# Set item
$selected_item = @buy_window.item
# Call update details
update_details
end
alias_method :itemdetails_scnshop_updatesell, :update_sell
def update_sell
# The usual
itemdetails_scnshop_updatesell
# Set item
$selected_item = @sell_window.item
# Call update details
update_details
end
def update_details
if Input.trigger?(Input::A)
# End method if selected item is nil
return if $selected_item.nil?
# Refresh detail window
@detail_window.refresh_reset
@detail_window.refresh
# Reverse visibility and activity of detail window
@detail_window.visible = !@detail_window.visible
@detail_window.active = !@detail_window.active
end
end
end
It was kind of a rush job so if you find any bugs just post here to let us know :D