Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Using the "\v[n]" command in skill descriptions?

Well, I noticed that for some reason you can't use the "\v[n]" command in the skill description box (it just shows as is during test play).
So, I am assuming that for it to be possible to display variables in skill (or any database) descriptions, a script would be required. Does anyone know if one exists, or would be willing to make one? You would be credited of course.
I don't know a whole lot about scripting, but I'm assuming that doing something like this would be relatively simple...? I dunno.
 
This shouldn't be too extremely difficult. We need to use the regular expression substitution from Window_Message in Window_Help (shows skill & item descriptions).
Give me a few minutes.... 
 

poccil

Sponsor

 
The following function will replace variable descriptions wherever they occur:
Code:
  def replaceVariables(str)
   text=str.clone
   begin
    last_text = text.clone
    text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
   end until text == last_text
   text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
    $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
   end
   return text
 end

Here is an example of its use for the class Window_Skill:

Code:
 class Window_Skill
  def update_help
    skilltext=self.skill == nil ? "" : self.skill.description
    @help_window.set_text(replaceVariables(skilltext))
  end
 end
 
!!
Cool! Thank you so much!! Both of you, actually. I didn't quite understand where to put the first script poccil put up, but you explained it, Brewmeister. :D
Seriously, thank you SO much. I'll credit you, poccil. :D
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top