It's this one
I want to display the HP and SP values there from that other script there.
I only need to know how to do it, everything else is doable by myself.
Something like this: self.contents.draw_text(x + 74, y + 98, 64, 24, p5 + item_hp, 2)
So I would need to save the HP values of Weapon/Armor ID "x" in item_hp
But I'm not sure how to do it.
Code:
class Window_ItemDetailView < Window_Base
# ---------------------------------------------------------
# Script v1.1
# by jackatrades
#
# Find me at http://www.dubealex.com/creation_asylum/forum/
# if you have questions/comments.
# ---------------------------------------------------------
# Creates the window for usage.
def initialize
super(100, 40, 440, 400)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Calibri"
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
# z acts as "layer order."
self.z += 10
@itemdetail = []
# ------------------------------
# @leadingcharacters is set for the script to delete X amount of
# characters in each line of the .rxdata
# In this case, the first 5 characters will be deleted in each line.
# ------------------------------
@leadingcharacters = 5
# Clears and resets the window everytime it is requested by Scene_Item.
refresh2
end
def refresh2
self.contents.font.name = "Calibri"
self.contents.font.size = $fontsize
self.contents.font.color = normal_color
self.contents.clear
end
def refresh
item_id = $currenthighlighteditem.id
# The three huge if-then statements check the current highlighted
# item and its property, and executes the appropriate script
# when it is true.
# <-----------------------------------ITEM---------------------------->
if $currenthighlighteditem.is_a?(RPG::Item)
item = $data_items[item_id]
item_name = $data_items[item_id].name
item_icon = $data_items[item_id].icon_name
item_amount = ($game_party.item_number(item_id)).to_s
item_price = ($data_items[item_id].price).to_s
getitem_scope = $data_items[item_id].scope
# The Item Scope descriptions can be edited if needed.
if getitem_scope == 0
getitem_scope = "No Use"
end
if getitem_scope == 1
getitem_scope = "One Enemy"
end
if getitem_scope == 2
getitem_scope = "All Enemies"
end
if getitem_scope == 3
getitem_scope = "One Ally"
end
if getitem_scope == 4
getitem_scope = "Party"
end
if getitem_scope == 5
getitem_scope = "Down Ally (HP = 0)"
end
if getitem_scope == 6
getitem_scope = "Down Allies (HP = 0)"
end
if getitem_scope == 7
getitem_scope = "User"
end
# </> #
self.contents.font.color = system_color
self.contents.draw_text(310, 44, 100, 24, "Usage:", 2)
self.contents.font.color = normal_color
self.contents.draw_text(426, 44, 250, 24, getitem_scope, 0)
end
# <-------------------------------------------------------------------->
# <-----------------------------------WEAPON---------------------------->
if $currenthighlighteditem.is_a?(RPG::Weapon)
item = $data_weapons[item_id]
item_name = $data_weapons[item_id].name
item_icon = $data_weapons[item_id].icon_name
item_amount = ($game_party.weapon_number(item_id)).to_s
item_price = ($data_weapons[item_id].price).to_s
# Initialize p# variables.
# These are used to display either plus sign or no sign depending on
# the weapon's attribute bonus.
# Negative sign originates from the value itself, so no need to check
# them with if-then statements.
p1 = ""
p2 = ""
p3 = ""
p4 = ""
p5 = ""
p6 = ""
# ---------------------------------------------------
# Start inserting appropriate variables from database.
# ---------------------------------------------------
item_atk = $data_weapons[item_id].atk.to_s
item_pdef = $data_weapons[item_id].pdef
if item_pdef > 0
p5 = "+"
end
item_pdef = item_pdef.to_s
item_mdef = $data_weapons[item_id].mdef
if item_mdef > 0
p6 = "+"
end
item_mdef = item_mdef.to_s
item_str = $data_weapons[item_id].str_plus
if item_str > 0
p1 = "+"
end
item_str = item_str.to_s
item_dex = $data_weapons[item_id].dex_plus
if item_dex > 0
p2 = "+"
end
item_dex = item_dex.to_s
item_agi = $data_weapons[item_id].agi_plus
if item_agi > 0
p3 = "+"
end
item_agi = item_agi.to_s
item_int = $data_weapons[item_id].int_plus
if item_int > 0
p4 = "+"
end
item_int = item_int.to_s
# Sets Elemental and Status attributes of weapon string along with
# suffix slashes when there are two or more attributes.
item_element = ""
flag = false
for i in $data_weapons[item_id].element_set
if flag
item_element += "/"
end
item_element += $data_system.elements[i]
flag = true
end
# Checks whether item_element is blank. If it is, then sets it
# to "None".
if item_element == ""
item_element = "None"
end
item_status = ""
flag = false
for i in $data_weapons[item_id].plus_state_set
if flag
item_status += "/"
end
item_status += $data_states[i].name
flag = true
end
if item_status == ""
item_status = "None"
end
# ------------------------------
# Start drawing attribute names.
# ------------------------------
# x and y can be changed to easily affect other attributes.
x = 33
y = 66
self.contents.font.color = system_color
self.contents.font.size = $fontsize - 4
self.contents.font.color = Color.new(255, 255, 0, 255)
self.contents.draw_text(x, y, 256, 24, $data_system.words.atk)
self.contents.font.color = system_color
self.contents.draw_text(x, y + 28, 256, 24, $data_system.words.str)
self.contents.draw_text(x, y + 42, 256, 24, $data_system.words.dex)
self.contents.draw_text(x, y + 56, 256, 24, $data_system.words.agi)
self.contents.draw_text(x, y + 70, 256, 24, $data_system.words.int)
self.contents.draw_text(x, y + 84, 256, 24, $data_system.words.pdef)
self.contents.draw_text(x, y + 98, 256, 24, $data_system.words.mdef)
self.contents.draw_text(x + 170, y, 256, 24, "Elemental Attack:")
self.contents.draw_text(x + 170, y + 42, 256, 24, "Status Attack:")
# ------------------------------
# Start drawing attribute values.
# ------------------------------
self.contents.font.color = normal_color
self.contents.draw_text(x + 74, y, 64, 24, item_atk, 2)
self.contents.draw_text(x + 74, y + 28, 64, 24, p1 + item_str, 2)
self.contents.draw_text(x + 74, y + 42, 64, 24, p2 + item_dex, 2)
self.contents.draw_text(x + 74, y + 56, 64, 24, p3 + item_agi, 2)
self.contents.draw_text(x + 74, y + 70, 64, 24, p4 + item_int, 2)
self.contents.draw_text(x + 74, y + 84, 64, 24, p5 + item_pdef, 2)
self.contents.draw_text(x + 74, y + 98, 64, 24, p6 + item_mdef, 2)
self.contents.draw_text(x + 170, y + 14, 420, 24, " " + item_element, 0)
self.contents.draw_text(x + 170, y + 56, 420, 24, " " + item_status, 0)
# Resets font size.
self.contents.font.size = $fontsize
end
# <-------------------------------------------------------------------->
# <-----------------------------------ARMOR---------------------------->
if $currenthighlighteditem.is_a?(RPG::Armor)
item = $data_armors[item_id]
item_name = $data_armors[item_id].name
item_icon = $data_armors[item_id].icon_name
item_amount = ($game_party.armor_number(item_id)).to_s
item_price = ($data_armors[item_id].price).to_s
# set variables
p1 = ""
p2 = ""
p3 = ""
p4 = ""
p5 = ""
p6 = ""
# Checks armor's type and inserts appropriate string.
type = $data_armors[item_id].kind
if type == 0
type = "Handschuhe"
end
if type == 1
type = "Helm"
end
if type == 2
type = "RĂ¼stung"
end
if type == 3
type = "Stiefel"
end
if type == 4
type = "Insigne"
end
if type == 5
type = "Amulett"
end
if type == 6
type = "Ring"
end
if type == 7
type = "Schwingen"
end
if type == 8
type = "Schild"
end
if type == 9
type = "Accessory"
end
if type == 10
type = "Accessory"
end
item_pdef = $data_armors[item_id].pdef
if item_pdef > 0
p5 = "+"
end
item_pdef = item_pdef.to_s
item_mdef = $data_armors[item_id].mdef
if item_mdef > 0
p6 = "+"
end
item_mdef = item_mdef.to_s
item_str = $data_armors[item_id].str_plus
if item_str > 0
p1 = "+"
end
item_str = item_str.to_s
item_dex = $data_armors[item_id].dex_plus
if item_dex > 0
p2 = "+"
end
item_dex = item_dex.to_s
item_agi = $data_armors[item_id].agi_plus
if item_agi > 0
p3 = "+"
end
item_agi = item_agi.to_s
item_int = $data_armors[item_id].int_plus
if item_int > 0
p4 = "+"
end
item_int = item_int.to_s
item_element = ""
flag = false
for i in $data_armors[item_id].guard_element_set
if flag
item_element += "/"
end
item_element += $data_system.elements[i]
flag = true
end
if item_element == ""
item_element = "None"
end
item_status = ""
flag = false
for i in $data_armors[item_id].guard_state_set
if flag
item_status += "/"
end
item_status += $data_states[i].name
flag = true
end
if item_status == ""
item_status = "None"
end
#draw attribute names
self.contents.font.color = system_color
self.contents.font.size = $fontsize - 4
x = 33
y = 66
self.contents.font.color = Color.new(255, 255, 0, 255)
self.contents.draw_text(x, y, 256, 24, "Type")
self.contents.draw_text(x, y + 14, 256, 24, $data_system.words.pdef)
self.contents.draw_text(x, y + 28, 256, 24, $data_system.words.mdef)
self.contents.font.color = system_color
self.contents.draw_text(x, y + 56, 256, 24, $data_system.words.str)
self.contents.draw_text(x, y + 70, 256, 24, $data_system.words.dex)
self.contents.draw_text(x, y + 84, 256, 24, $data_system.words.agi)
self.contents.draw_text(x, y + 98, 256, 24, $data_system.words.int)
self.contents.draw_text(x + 170, y, 256, 24, "Elemental Guard:")
self.contents.draw_text(x + 170, y + 42, 256, 24, "Status Guard:")
#draw attributes
self.contents.font.color = normal_color
self.contents.draw_text(x + 74, y, 64, 24, type, 2)
self.contents.draw_text(x + 74, y + 14, 64, 24, p5 + item_pdef, 2)
self.contents.draw_text(x + 74, y + 28, 64, 24, p6 + item_mdef, 2)
self.contents.draw_text(x + 74, y + 56, 64, 24, p1 + item_str, 2)
self.contents.draw_text(x + 74, y + 70, 64, 24, p2 + item_dex, 2)
self.contents.draw_text(x + 74, y + 84, 64, 24, p3 + item_agi, 2)
self.contents.draw_text(x + 74, y + 98, 64, 24, p4 + item_int, 2)
self.contents.draw_text(x + 170, y + 14, 420, 24, " " + item_element, 0)
self.contents.draw_text(x + 170, y + 56, 420, 24, " " + item_status, 0)
self.contents.font.size = $fontsize
end
# <-------------------------------------------------------------------->
# Stores item Price's string width.
item_price_width = item_price.size * 10
# Stores item's icon graphic.
bitmap = RPG::Cache.icon(item_icon + ".png")
# Draws item's icon.
self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
self.contents.font.color = drago_item_colors(item)
self.contents.draw_text(33, 8, 256, 24, item_name)
self.contents.font.color = system_color
self.contents.draw_text(310, 8, 100, 24, "Owned No.:", 2)
self.contents.draw_text(310, 26, 100, 24, "Value:", 2)
self.contents.font.color = normal_color
self.contents.draw_text(426, 8, 160, 24, item_amount, 0)
self.contents.draw_text(426, 26, 160, 24, item_price, 0)
# This if-then statement is pretty much unnecessary unless
# you're using the same idea: if user's party does not
# know the item's value and had not appraised the item,
# then don't draw text.
if item_price != "Unknown"
self.contents.font.color = system_color
self.contents.draw_text(432 + item_price_width, 26, 160, 24, $data_system.words.gold, 0)
end
self.contents.font.color = normal_color
# Two lines below calls the two definitions to write the item's
# detailed description.
get_item_detail(item_id)
write_item_detail(5, 223)
end
def get_item_detail(item_id)
# descarray stores the line numbers needed to call the right
# detail description into an array.
descarray =
[
item_id * 7,
item_id * 7 + 1,
item_id * 7 + 2,
item_id * 7 + 3,
item_id * 7 + 4,
item_id * 7 + 5,
item_id * 7 + 6
]
# The if-then statements below checks the highlighted item and use
# the right .rxdata.
if $currenthighlighteditem.is_a?(RPG::Item)
f = File.open("Data/Item_Detail.rxdata")
end
if $currenthighlighteditem.is_a?(RPG::Weapon)
f = File.open("Data/Weapon_Detail.rxdata")
end
if $currenthighlighteditem.is_a?(RPG::Armor)
f = File.open("Data/Armor_Detail.rxdata")
end
# Stores _every_ line of the file into @itemdetail as an array.
@itemdetail = f.readlines
# Clears first seven lines for Lines 1-7 (0..6), as it will never be used.
for i in 0..6
@itemdetail[i] = ""
end
# Crops the first 6 characters in each line.
for i in 0..6
cropheadcharacters(descarray[i])
end
# Stores the cropped lines into description array.
@description = []
for i in 0..6
@description[i] = @itemdetail[descarray[i]]
end
return
end
def cropheadcharacters(descarray)
# Checks to see if any lines are nil. If so, then sets them
# as blank lines after cropping.
if @itemdetail[descarray] == nil
@itemdetail[descarray] = "123456 "
end
# Crops the first (@leadingcharacters) characters in each line.
# Default: 5.
@itemdetail[descarray].slice!(0..@leadingcharacters)
return
end
def write_item_detail(x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y - 20, 640, 32, "Description:")
self.contents.font.color = normal_color
self.contents.font.size = $fontsize - 2
# Draws the first six lines in normal color.
for i in 0..5
self.contents.draw_text(x, y, 640, 32, @description[i])
y += 18
end
# Draws the seventh line in another color.
self.contents.font.color = Color.new(255, 255, 0, 255)
self.contents.draw_text(x, y, 640, 32, @description[6])
end
end
I want to display the HP and SP values there from that other script there.
I only need to know how to do it, everything else is doable by myself.
Something like this: self.contents.draw_text(x + 74, y + 98, 64, 24, p5 + item_hp, 2)
So I would need to save the HP values of Weapon/Armor ID "x" in item_hp
But I'm not sure how to do it.