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.

[VX] Advanced Help

Advanced Help
by Dargor
Version 1.3


Introduction

I was tired of squeezed text in the help window when an description is too long. So I made this script!
This script will not squeeze the text. Instead, it will scroll it if it's larger than the help window.
This script also supports some message codes like changing colors, displaying variables and actor names.
You also have the possibility to switch to letter by letter mode!

Features
  • Scrolling text
  • 3 Scrolling modes: 1 Vertical, 2 Horizontal
  • Can add new lines using the \L code
  • Customizable scrolling delay
  • Letter by letter
  • Color message code
  • Variable message code
  • Actor name message code

Script

Code:
#==============================================================================

# ** Advanced Help

#------------------------------------------------------------------------------

#  © Dargor, 2008-2009

#  17/02/09

#  Version 1.3

#------------------------------------------------------------------------------

#  VERSION HISTORY:

#   - 1.0 (02/11/08), Initial release

#   - 1.1 (03/11/08), Now compatible with the Takentai CBS

#   - 1.2 (17/02/09), Text can now scroll vertically using Scroll Mode 2

#   - 1.3 (17/02/09), Now works with text alignment

#------------------------------------------------------------------------------

#  INSTRUCTIONS:

#   - Place this script above Main

#   - Edit the constants in the Advanced Help module and enjoy!

#------------------------------------------------------------------------------

#  Notes

#   This script handles the following message codes.

#   - Color      : \C[n]

#   - Variable   : \V[n]

#   - Actor Name : \N[n]

#   - New Line   : \L

#==============================================================================

 

#==============================================================================

# ** Advanced Help Configuration Module

#==============================================================================

 

module Advanced_Help

  # The delay (in frames) before the text starts to scroll

  Scroll_Wait = 120

  # Scroll Mode 

  # 0 : Scrolls to left and loops

  # 1 : Scrolls to left and goes back to its origin.

  # 2 : Scrolls down and goes back to its origin when using 2+ lines.

  Scroll_Mode = 0

  # Letter by letter

  Letter_By_Letter = true

end

 

#==============================================================================

# ** Window_Help

#------------------------------------------------------------------------------

#  This window shows skill and item explanations along with actor status.

#==============================================================================

 

class Window_Help < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  alias dargor_vx_help_scroll_update update

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 544, WLH + 32)

    @scroll_wait = 0

    @scroll_mode = Advanced_Help::Scroll_Mode

    @temp_wait = 0

    @text = ''

    @new_text = ''

    @last_text = ''

    @contents_x = 0

    @line_y = 0

  end

  #--------------------------------------------------------------------------

  # * Set Text

  #  text  : character string displayed in window

  #  align : alignment (0..flush left, 1..center, 2..flush right)

  #--------------------------------------------------------------------------

  def set_text(text, align=0)

    @last_text = @text

    if text != @text or align != @align

      self.ox = 0

      self.oy = 0

      self.contents.clear

      @scroll_wait = Advanced_Help::Scroll_Wait

      @text = text

      @new_text = text.dup

      @temp_text = @new_text.dup

      @align = align

      @max_line_y = 0

      @contents_x = 0

      if align == 1

        @contents_x = ((self.width - get_contents_width) / 2) - 16

      elsif align == 2

        @contents_x = (self.width - get_contents_width) - 32

      end

      if @scroll_mode == 2

        ch = (get_contents_height + 1) * WLH

        self.contents = Bitmap.new(self.width - 32, ch)

      else

        cw = [contents.text_size(text).width + 16, 32].max

        self.contents = Bitmap.new(cw, WLH)

      end

      convert_special_characters

    end

  end

  #--------------------------------------------------------------------------

  # * Get the number of lines in the text

  #--------------------------------------------------------------------------

  def get_contents_height

    @temp_text.gsub!(/\\L/)              { @max_line_y += 1 }

    return @max_line_y

  end

  #--------------------------------------------------------------------------

  # * Get the width of the text

  #--------------------------------------------------------------------------

  def get_contents_width

    @temp_text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }

    @temp_text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }

    @temp_text.gsub!(/\\C\[([0-9]+)\]/i) { "" }

    @temp_text.gsub!(/\\L/)              { "" }

    return self.contents.text_size(@temp_text).width

  end

  #--------------------------------------------------------------------------

  # * Convert Special Characters

  #--------------------------------------------------------------------------

  def convert_special_characters

    @new_text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }

    @new_text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] }

    @new_text.gsub!(/\\N\[([0-9]+)\]/i) { $game_actors[$1.to_i].name }

    @new_text.gsub!(/\\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }

    @new_text.gsub!(/\\G/)              { "\x02" }

    @new_text.gsub!(/\\\./)             { "\x03" }

    @new_text.gsub!(/\\\|/)             { "\x04" }

    @new_text.gsub!(/\\!/)              { "\x05" }

    @new_text.gsub!(/\\>/)              { "\x06" }

    @new_text.gsub!(/\\</)              { "\x07" }

    @new_text.gsub!(/\\\^/)             { "\x08" }

    @new_text.gsub!(/\\L/)              { "\x09" }

    @new_text.gsub!(/\\\\/)             { "\\" }

  end

  #--------------------------------------------------------------------------

  # * Update Message

  #--------------------------------------------------------------------------

  def update_message

    # Draw text letter by letter

    if Advanced_Help::Letter_By_Letter

      loop do

        c = @new_text.slice!(/./m)            # Get next text character

        case c

        when nil                          # There is no text that must be drawn

          break

        when "\x01"                       # \C[n]  (text character color change)

          @new_text.sub!(/\[([0-9]+)\]/, "")

          contents.font.color = text_color($1.to_i)

          next

        when "\x09"

          @contents_x = 0

          @line_y += 1

        else                              # Normal text character

          contents.draw_text(@contents_x, @line_y * WLH, 40, WLH, c)

          c_width = contents.text_size(c).width

          @contents_x += c_width

        end

        break

      end

    # Draw the whole text

    else  

      while (c = @new_text.slice!(/./m)) != nil

        case c

        when nil                          # There is no text that must be drawn

          break

        when "\x01"                       # \C[n]  (text character color change)

          @new_text.sub!(/\[([0-9]+)\]/, "")

          contents.font.color = text_color($1.to_i)

          next

        when "\x09"

          @contents_x = 0

          @line_y += 1

        else                              # Normal text character

          contents.draw_text(@contents_x, @line_y * WLH, 40, WLH, c)

          c_width = contents.text_size(c).width

          @contents_x += c_width

        end

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Draw text

    update_message

    # The usual

    dargor_vx_help_scroll_update

    # Scroll text

    @scroll_wait -= 1

    if @temp_wait > 0

      @temp_wait -= 1

      @temp_wait = -1 if @temp_wait == 0

      return

    else

      if self.oy != 0 && @temp_wait == -1

        self.oy -= 1 if Graphics.frame_count % 2 == 0

        if self.oy % WLH == 0

          @temp_wait = Advanced_Help::Scroll_Wait

          return

        end

        @temp_wait = 0 if self.oy == 0

        return

      end

    end

    if @scroll_mode != 2

      if self.contents.width > self.width && @scroll_wait < 0

        self.ox += 1 

        @scroll_wait = Advanced_Help::Scroll_Wait if self.ox == 0

      end

    else

      if self.contents.height + 32 > self.height && @scroll_wait < 0

        self.oy += 1 if Graphics.frame_count % 2 == 0

        if self.oy % WLH == 0

          if self.oy > self.contents.height - WLH

            @temp_wait = Advanced_Help::Scroll_Wait

          else

            @scroll_wait = Advanced_Help::Scroll_Wait

          end

          return

        end

        #@scroll_wait = Advanced_Help::Scroll_Wait if self.oy == 0

      end

    end

    case @scroll_mode

    when 0

      if self.ox > self.contents.width

        self.ox = (-self.contents.width + 64) 

      end

    when 1

      if self.ox > self.contents.width + 64

        self.ox = 0

        @scroll_wait = Advanced_Help::Scroll_Wait

      end

    when 2

      if self.oy > self.contents.height - WLH

        @temp_wait = Advanced_Help::Scroll_Wait

        @scroll_wait = Advanced_Help::Scroll_Wait

      end

    end

  end

end

 

#==============================================================================

# ** Scene_Battle

#------------------------------------------------------------------------------

#  This class performs battle screen processing.

#==============================================================================

 

class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_advanced_help_battle_update_basic update_basic

  #--------------------------------------------------------------------------

  # * Basic Update Processing

  #     main : Call from main update method

  #--------------------------------------------------------------------------

  def update_basic(main = false)

    dargor_vx_advanced_help_battle_update_basic(main)

    @help_window.update unless @help_window.nil?

  end

end

Screenshots



Hope you like it!
-Dargor
 

Devlin

Member

It doesn't work on mine. I'm using the fresh project (no scripts in it), and I put your script between the materials and main process.

When I play-test the game, it works fine. Until I selected the items in the menu and pressed the enter. I get the error window.

Script 'Advanced Help' line 66: NoMethodError occurred.
undefined method 'echo' for #<Window_Help:0x1a8d3c8>


The script error is this:

65  def set_text(text, align = 0)
66   echo "#{text} - #{@text} - #{@last_text}"
67   @last_text = @text
68   if text != @text or align != @align
69     @contents_x = 0
70     self.ox = 0
71     self.contents.clear
72     @scroll_wait = Advanced_Help::Scroll_Wait
73     cw = [contents.text_size(text).width + 16, 32].max
74     self.contents = Bitmap.new(cw, WLH)
75     @text = text
76     @new_text = text.dup
77     @align = align
78     convert_special_characters
79    end
80  end


Is it a human error on my part or is the script bugged?

EDIT: Well, I changed it to

66  echo = "#{text} - #{@text} - #{@last_text}"

And it works fine. You just forgot to add =
 
oops sorry, it was for debugging purpose, FIXED!
This line is supposed to send the string after 'echo' to a debugging console, but you don't have it so this line is useless.
 

Devlin

Member

All right. I removed echo line from the script. I thought it was odd about the echo but I didn't know much about the script so I just left it be. Anyways, thanks for a quick reply.
 
As usual Mr. Dargor, your a professional programmer who works around the clock to help people in need of little problems such as these. Surely many have asked for your advice and help when it comes to programming. Thanks a lot for making our game-making life easier. ^^V

EDIT: Hmmm, this may not be a bug or glitch to many, however Dargor, I think I found a little problem when it comes to using a skill. The skill name will not appear in the help window (Takentai SBS yeah, really does annoy the heck out of ya with this battle system eh?) at all. The help window does show but not the name itself. So if you may, help and try to overcome this problem if possible? It's for all Takentai SBS users...
 
@Azuaya
Thanks for the bug report. I'll fix that as soon as possible ;)

EDIT:
I have updated the script. I looked at the Takentai CBS and it seems that the help window is not updating in this script.
I just added a few lines at the end of my script. It should do the trick!
I can't test it right now because I'm at work, so tell me if it's working or not.
 
It does work now. This may bug you yet again, the words does not seem like how it should originally be. The text should normally centered alignment and fonts should have stayed as default system. But nevertheless, it's fixed. Just informing you on how the default look like and this one is like.

Good work Dargor and thanks for fixing it.

EDIT: I'll see if I can fix this somehow o.O
EDIT 2: It seems that I cannot fix it ... I'm too noob >.> making it centre just for Takentai Help Window surely is hard...
 
I have updated the script to version 1.2
You can now have vertical scrolling and you can also add new lines to items description using the \L code!

Take care
-Dargor
 
Great script Dargor.

However, I can't change the alignment of text.

No matter what I change under the "set_text(text, align = 0)" method, it will always be left aligned. Lines used in other scripts such as "@help_window.set_text(text, 1)" will have the alignment parameter ignored.

BTW, this was tested in a clean project.
 
It's normal, it's because I have removed that by mistake. I'll bring it back! ;)

EDIT: Try the new version, I have restored the alignment feature.
 
Thanks, it's all good now. :) Although you might want to change to default alignment to = 0 so the newbies won't get confused on why their text is right aligned.
 
There will be a stack error if you F12 reset and attempt to load a scene with a help window after the reset.

This seems to be averted if you change line 188 to:

dargor_vx_help_scroll_update unless $@
 
I appear to be having a problem with vertical scrolling.
The text appears in the help window, scrolls down to the last line line normal.
When it reaches the last line, it waits a little longer, the text jumps up and down once, quickly, and it slowly scrolls back up to the top: Then it never scrolls back down. It behaves the same with both 2 lines, and 3, and I don't think it's due to some level of interference since it behaves this way with items & skills, inside and outside of battle.

I apologize if my posting in your threads happens to be an annoyance >.>
 

Devlin

Member

I'm having same problem that CrimsonPride had too. The issue is vertical scrolling. I'll try my best to be specific. (Note: It happened in a fresh project, so it's not foreign scripts' doing.)

I access to the item inventory, and I move to the item that has a vertical scrolling effect.

It works prefectly at first scroll-down. It reaches to final line.

It then tries to get next line (except there is no next line) so it shook slightly, and waited as if it thinks it reached next line but it really didn't.

It'll scroll back up to the first line.

It gets struck. It tries to scroll a line that is above the first line (except it's not there) so it gets struck and shaky.

If I try to move to next item, the help description disappears. I can still see arrows (in help description) but I can't see the text. It happens with all text even one with no vertical scrolling effects.
 
sorry my bad english >.<
Can this script compatible with Tankentai SBS?.
I mean ... when the actor's battle commands appeared, just wait for 3 or 4 second, they will be disappeared.
Hope u can understand me =.^
 

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