[XP] Enhanced Item Description

Started by ForeverZer0, May 14, 2011, 01:20:30 pm

Previous topic - Next topic

ForeverZer0

Enhanced Item Description
Authors: ForeverZer0
Version: 1.0
Type: Menu Add-on
Key Term: Menu Add-on



Introduction

This is a small script I wrote when I got started scripting, but never released. I found it going through some old projects, but I'm sure someone else can make use of it. What it does is allows you to use the same shortcuts commands you can in a "Show Text..." command, but within the descriptions for Items, Weapons, and Armors. For example, if you wanted the description to include the value of a variable, in the database where you right the descriptions, just use "\v[VAR_ID]", and the command will be replaced with the actual value of the variable during the game.


Features


  • Easy to use.

  • Makes descriptions a little more dynamic.

  • Commands included: Actor Names, Variables, Gold, Switches, and Steps.

  • Can easily add custom ones




Screenshots

Name character whatever you want: ShowHide

Use command in the description: ShowHide

Description remains correct: ShowHide



Demo

None.


Script

Here lies the script.
Spoiler: ShowHide

#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Enhanced Item Description
# Author: ForeverZer0
# Version: 1.0
# Date: 5.14.2011
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
#
# Introduction:
#   This is a small, very basic script I wrote a while back, but never released.
#   It allows for you to use the same type of commands you can use in event
#   "Show Message" commands, but within the descriptions of Weapons, Armors, and
#   Items. Review the commands below, they will be substituted in the actual
#   text to display the respective value.
#
# Commands:
#   \v[ID]  = Replaces with value of game variable with ID
#   \n[ID]  = Replaces with name of actor that has ID
#   \sw[ID] = Replaces with value of switch withg ID  (ON/OFF)
#   \g      = Replaces with amount of gold party has
#   \st     = Replaces with step count
#
# Author's Notes:
#   I can add more at request. Only values that are global to the RTP scripts
#   and cannot be easily accessed will be added to the script, though I can
#   still give someone a one line of code they can add themselves for custom
#   commands.
#
#=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

module RPG
 
  def self.substitute_text(message)
    text = message.clone
    text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
    text.gsub!(/\\[Nn]\[([0-9]+)\]/) {
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : '' }
    text.gsub!(/\\[Gg]/) { $game_party.gold }
    text.gsub!(/\\[Ss][Tt]/) { $game_party.steps }
    text.gsub!(/\\[Ss][Ww]\[([0-9]+)\]/) {
      $game_switches[$1.to_i] ? 'ON' : 'OFF' }
    return text
  end
 
  class Weapon
    def description
      return RPG.substitute_text(@description)
    end
  end
 
  class Armor
    def description
      return RPG.substitute_text(@description)
    end
  end
 
  class Item
    def description
      return RPG.substitute_text(@description)
    end
  end
end



Instructions

Place script anywhere above "Main".
Use the following commands in the database when making descriptions:

  • \v[ID] :  Replaces with value of game variable with ID

  • \n[ID] :  Replaces with name of actor that has ID

  • \sw[ID] :  Replaces with value of switch with ID  (ON/OFF)

  • \g :  Replaces with amount of gold party has

  • \st : Replaces with step count




Compatibility

Compatible with practically everything.


Credits and Thanks


  • ForeverZer0




Author's Notes

If you would like a custom command, feel free to ask. 
Please report any bugs/issues you encounter so that they may be resolved.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

Lol, why didn't you post it in the database right away? xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

May 14, 2011, 01:57:46 pm #2 Last Edit: May 14, 2011, 02:15:31 pm by Sub-Zero
He's not a moderator of this board.

*moves*

Quick note, you could give any text "\" commands by simply aliasing the Bitmap.draw_text method. Scripters could even use it then when writing code.

Blizzard

*fixes behind G_G's back* But he is!
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

May 14, 2011, 03:01:44 pm #4 Last Edit: May 14, 2011, 03:03:36 pm by Baraka
lol, thanks.

"I FEEL THE POWER!"

@GG: i didn't think of that. You are a ninja.  :ninja:
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Jragyn

Quote..., in the database where you write the descriptions,...


:D I like.
A bright light can either illuminate or blind, but how will you know which until you open your eyes?

brewmeister

Quote from: Sub-Zero on May 14, 2011, 01:57:46 pm
Quick note, you could give any text "\" commands by simply aliasing the Bitmap.draw_text method. Scripters could even use it then when writing code.


Kinda like this....   http://www.hbgames.org/forums/viewtopic.php?f=11&t=74073    ;)  ;)

I started out the same way, then realized... "Everything uses Bitmap.draw_text, why not modify that!!"


Either way, great enhancement! Lot's of people have requested it.

Be Well

XaineC

Really great. Could you possibly make this work with skills as well?

G_G

Add this right below his script.
module RPG
  class Skill
    def description
      return RPG.substitute_text(@description)
    end
  end
end

XaineC