The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on July 22, 2008, 02:55:05 AM

Title: Description Codes
Post by: modern algebra on July 22, 2008, 02:55:05 AM
Description Codes
Version: 1.0
Author: modern algebra
Date: July 22, 2008

Version History




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


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:


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


Support



Post here for the swiftest response



Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Description Codes
Post by: Arclight on August 01, 2008, 11:41:30 AM
Thank! YOU! lol. This was exactly the salve i was looking for.

Makes for a good reference.
Title: Re: Description Codes
Post by: Wrong on August 08, 2008, 11:46:29 PM
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?
Title: Re: Description Codes
Post by: modern algebra on August 09, 2008, 12:02:46 AM
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.