Advertisement
ForeverZer0

[RMXP] Enhanced Item Description

May 21st, 2011
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.03 KB | None | 0 0
  1. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  2. # Enhanced Item Description
  3. # Author: ForeverZer0
  4. # Version: 1.0
  5. # Date: 5.14.2011
  6. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  7. #
  8. # Introduction:
  9. #   This is a small, very basic script I wrote a while back, but never released.
  10. #   It allows for you to use the same type of commands you can use in event
  11. #   "Show Message" commands, but within the descriptions of Weapons, Armors, and
  12. #   Items. Review the commands below, they will be substituted in the actual
  13. #   text to display the respective value.
  14. #
  15. # Commands:
  16. #   \v[ID]  = Replaces with value of game variable with ID
  17. #   \n[ID]  = Replaces with name of actor that has ID
  18. #   \sw[ID] = Replaces with value of switch withg ID  (ON/OFF)
  19. #   \g      = Replaces with amount of gold party has
  20. #   \st     = Replaces with step count
  21. #
  22. # Author's Notes:
  23. #   I can add more at request. Only values that are global to the RTP scripts
  24. #   and cannot be easily accessed will be added to the script, though I can
  25. #   still give someone a one line of code they can add themselves for custom
  26. #   commands.
  27. #
  28. #=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  29.  
  30. module RPG
  31.  
  32.   def self.substitute_text(message)
  33.     text = message.clone
  34.     text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  35.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) {
  36.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : '' }
  37.     text.gsub!(/\\[Gg]/) { $game_party.gold }
  38.     text.gsub!(/\\[Ss][Tt]/) { $game_party.steps }
  39.     text.gsub!(/\\[Ss][Ww]\[([0-9]+)\]/) {
  40.       $game_switches[$1.to_i] ? 'ON' : 'OFF' }
  41.     return text
  42.   end
  43.  
  44.   class Weapon
  45.     def description
  46.       return RPG.substitute_text(@description)
  47.     end
  48.   end
  49.  
  50.   class Armor
  51.     def description
  52.       return RPG.substitute_text(@description)
  53.     end
  54.   end
  55.  
  56.   class Item
  57.     def description
  58.       return RPG.substitute_text(@description)
  59.     end
  60.   end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement