Description Codes
Version: 1.0
Author: modern algebra
Date: July 22, 2008
Version History
- <Version 1.0> Original Releaase July 22, 2008
Description
This script is essentially for the lazy person inside all of us. It basically allows you to use replacement codes inside a description for an item, weapon, armor, or skill. So, \n[1] would print the name of the Actor with ID 1, and \vocab[hp] would print the Vocab you set for HP in the Terms tab, etc...
Features
- Allows you to use special codes in item, weapon, armor, or skill descriptions
- A large number of codes, including ways to print out most of the stats of the item, weapon, armor, or skill
- Easy to use
Instructions
To use, insert the codes you'd like to use into the description of the item, weapon, armor, or skill. The message codes you can use are:
- \n[actor_id] - prints name of actor with specified ID
- \c[class_id] - prints name of class with specified ID
- \s[state_id] - prints name of state with specified ID
- \v[variable_id] - prints value of variable with specified ID
- \e[element_id] - prints name of element with specified ID
- \vocab[value] - prints vocab for that value. Suitable values for this are: level, level_a, hp, hp_a, mp, mp_a, atk, def, spi, agi, weapon, armor1, armor2, armor3, armor4, weapon1, weapon2, attack, skill, guard, item, equip, status, save, game_end, fight, escape, new_game, shutdown, to_title, continue, cancel, gold
- \p - prints price (Items, Weapons, or Armors ONLY)
- \spd - prints speed stat value (Skills or Items ONLY)
- \dmg - prints damage stat value (Skills or Items ONLY)
- \var - prints variance stat value (Skills or Items ONLY)
- \atkf - prints Attack F stat value (Skills or Items ONLY)
- \spif - prints Spirit F stat value (Skills or Items ONLY)
- \hr - prints hit ratio (Skills or Weapons ONLY)
- \mpc - prints mp cost value (Skills ONLY)
- \mpr - prints mp rate percentile (Items ONLY)
- \mpv - prints mp value (Items ONLY)
- \hpr - prints hp rate percentile (Items ONLY)
- \hpv - prints hp value (Items ONLY)
- \pn - prints paramter name (MaxHP etc...) (Items ONLY)
- \pv - prints parameter points (50, etc...) (Items ONLY)
- \eva - prints evasion (Armors ONLY)
- \atk - prints Attack (Weapons or Armors ONLY)
- \def - prints Defense (Weapons or Armors ONLY)
- \spi - prints Spirit (Weapons or Armors ONLY)
- \agi - prints Agility (Weapons or Armors ONLY)
Script
[/list]
#==============================================================================
# Description Replacement Codes
# Version 1.0
# Author: modern algebra (rmrk.net)
# Date: July 20, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Description:
#
# This script basically just allows the use of some basic message codes in
# item descriptions.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
#
# To use, insert the codes you'd like to use into the description of the
# item, weapon, armor, or skill. The message codes you can use are:
#
# General Codes
# \n[actor_id] - prints name of actor with specified ID
# \c[class_id] - prints name of class with specified ID
# \s[state_id] - prints name of state with specified ID
# \v[variable_id] - prints value of variable with specified ID
# \e[element_id] - prints name of element with specified ID
# \vocab[value] - prints vocab for that item type. Suitable values for this
# are: level, level_a, hp, hp_a, mp, mp_a, atk, def, spi,
# agi, weapon, armor1, armor2, armor3, armor4, weapon1,
# weapon2, attack, skill, guard, item, equip, status, save,
# game_end, fight, escape, new_game, shutdown, to_title,
# continue, cancel, gold
# \p - prints price (Items, Weapons, or Armors ONLY)
# \spd - prints speed stat value (Skills or Items ONLY)
# \dmg - prints damage stat value (Skills or Items ONLY)
# \var - prints variance stat value (Skills or Items ONLY)
# \atkf - prints Attack F stat value (Skills or Items ONLY)
# \spif - prints Spirit F stat value (Skills or Items ONLY)
# \hr - prints hit ratio (Skills or Weapons ONLY)
# \mpc - prints mp cost value (Skills ONLY)
# \mpr - prints mp rate percentile (Items ONLY)
# \mpv - prints mp value (Items ONLY)
# \hpr - prints hp rate percentile (Items ONLY)
# \hpv - prints hp value (Items ONLY)
# \pn - prints paramter name (MaxHP etc...) (Items ONLY)
# \pv - prints parameter points (50, etc...) (Items ONLY)
# \eva - prints evasion (Armors ONLY)
# \atk - prints Attack (Weapons or Armors ONLY)
# \def - prints Defense (Weapons or Armors ONLY)
# \spi - prints Spirit (Weapons or Armors ONLY)
# \agi - prints Agility (Weapons or Armors ONLY)
#==============================================================================
# ** RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased method - description
#==============================================================================
class RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Description
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_desc_codes_description_extract_8fn3 description
def description
# Get duplicate of actual description
text = modalg_desc_codes_description_extract_8fn3.dup
# Substitute codes for their actual values
text.gsub! (/\\n\[(\d+)\]/i) { $game_actors[$1.to_i].name } # Actor Name
text.gsub! (/\\c\[(\d+)\]/i) { $data_classes[$1.to_i].name } # Class Name
text.gsub! (/\\s\[(\d+)\]/i) { $data_states[$1.to_i].name } # State Name
text.gsub! (/\\v\[(\d+)\]/i) { $game_variables[$1.to_i].to_s } # Variable
text.gsub! (/\\e\[(\d+)\]/i) { $data_elements[$1.to_i].name } # Element
begin
text.gsub! (/\\vocab\[(\w+)\]/i) {eval ("Vocab.#{$1.to_s}")}# Vocabulary
rescue
end
# Skill or Item ONLY
if self.is_a? (RPG::UsableItem)
text.gsub! (/\\spd/i) { self.speed } # Speed
text.gsub! (/\\dmg/i) { self.base_damage } # Damage
text.gsub! (/\\var/i) { self.variance } # Variance
text.gsub! (/\\atkf/i) { self.atk_f } # Attack F
text.gsub! (/\\spif/i) { self.spi_f } # Spirit F
end
# Skill or Weapon ONLY
text.gsub! (/\\hr/i) {self.hit} if self.is_a? (RPG::Weapon) || self.is_a? (RPG::Skill)
# Item ONLY
if self.is_a? (RPG::Item)
text.gsub! (/\\hpr/i) { self.hp_recovery_rate } # HP Percent
text.gsub! (/\\hpv/i) { self.hp_recovery } # HP Value
text.gsub! (/\\mpr/i) { self.mp_recovery_rate } # MP Percent
text.gsub! (/\\mpv/i) { self.mp_recovery } # MP Value
text.gsub! (/\\pv/i) { self.parameter_points } # Param. Value
if text[/\\pn/i]
vocab = ["Max + #{Vocab.hp}", "Max + #{Vocab.mp}", Vocab.atk,
Vocab.def, Vocab.spi, Vocab.agi]
text.gsub! (/\\pn/i) { vocab[self.parameter_type] } # Param. Name
end
end
# Items, Weapons, or Armor ONLY
unless self.is_a? (RPG::Skill)
text.gsub! (/\\p/i) { self.price }
# Armor ONLY
text.gsub! (/\\eva/i) {self.hit} if self.is_a? (RPG::Armor)
# Armor or Weapon ONLY
if self.is_a? (RPG::Armor) || self.is_a? (RPG::Weapon)
text.gsub! (/\\atk/i) { self.atk }
text.gsub! (/\\def/i) { self.def }
text.gsub! (/\\spi/i) { self.spi }
text.gsub! (/\\agi/i) { self.agi }
end
end
# Return the text with substituted codes
return text
end
end
Credit
Thanks
- Zeriab, for his excellent tutorial on Regexp (http://rmrk.net/index.php/topic,25353.0.html), without which this script would not exist
Support
Post here for the swiftest response
Thank! YOU! lol. This was exactly the salve i was looking for.
Makes for a good reference.
Sorry, this might be out of the topic...
can you make it that if i do \f or something my text dialog box will display whoever my main character currently? and work with NMS3 by Wortana? or at least work with it?
This is only for the description that is shown when you hover over an item, skill, weapon, or armor. It isn't for text boxes.