Need a little change in this scroll text

Hi, I'm using this scroll text script to scroll my longer descriptions. However, this scrolls the text even if I put there like 2 or 3 words, and it gets annoying. What I ask for, is if someone could modify this, so I can assign a notetag (like lets say <scroll>) in items, spells, etc. If something has that notetag, then it will scroll the description text, otherwise no. OR if you know an other script which will do this, then please let me know.

Spoiler: Scroll text
# Original VX script by BigEd781
# Converted for VX Ace by Xypher
# Script is provided as is
class Window_Help < Window_Base
@@SCROLL_DELAY = 2 # seconds
@@SCROLL_SPEED = 1 # pixels / frame (60 frames / sec)
alias :scroll_init :initialize
def initialize(*args)
scroll_init(*args)
@internal_frame_count = 0
@text_is_long = false
self.windowskin = $game_system.window_skin_bitmap(self.class)
end
def get_altered_skin
default = Cache.system('Window')
window = Bitmap.new(default.width, default.height)
window.blt(0, 0, default, default.rect)
window.fill_rect(80, 16, 32, 32, Color.new(0,0,0,0))
return window
end
def set_text(text, align = 0)
unless (text == @text) && (align == @align)
@internal_frame_count = 0
txt_width = self.contents.text_size(text).width
@text_is_long = txt_width > (self.width - 32)
self.contents.dispose
w = @text_is_long ? (txt_width + self.width - 32) : self.width - 32
self.contents = Bitmap.new(w, self.height)
self.contents.clear
self.ox = 0
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.contents.width, fitting_height(1), text, align)
@text = text
@align = align
refresh
end
end
def update
super
@internal_frame_count += 1
if ((@internal_frame_count > @@SCROLL_DELAY * 60) && @text_is_long)
if self.ox >= (self.contents.width / 2 - self.width / 2)
self.ox = 0
@internal_frame_count = 0
else
self.ox += @@SCROLL_SPEED
end
end
end
end
You should paste a link to the script, not include the script in your post.

Why aren't you just using the Show Text or Show Scrolling Text commands as appropriate? VX didn't have a Show Scrolling Text command, but Ace does - I don't know why this needed to be ported to Ace at all.
@Shaz
It is for scrolling description texts in the description window, not for scrolling message window texts from events.

That said, this script still looks... bad, at least in my opinion.
It scrolls the text horizontally, but not fully, only until around the middle, and than it jumps back to the start and repeats the scrolling again.
This should be done with a plane instead, or at least scroll the text fully, not just halfway through the window. Even scrolling it back and forth would look better.
Also, it won't account for message codes, since it gets the text directly from the unaltered text you enter into the database. This will mess up the width calculation and in turn renders the script quite pointless if you use message codes in your descriptions.

I made a heavy edit for it which fixes the width issue and scrolls the text back and forth instead of just one way.
Spoiler
Code:
# Original VX script by BigEd781
# Converted for VX Ace by Xypher
# Script is provided as is
# ------------------------------
# Heavy edit by Sixth
# ------------------------------
class Window_Help < Window_Base
 
  @@SCROLL_DELAY = 2 # seconds
  @@SCROLL_SPEED = 1 # pixels / frame (60 frames / sec)
 
  alias :scroll_init :initialize
  def initialize(*args)
    @tdt = {:x => 0, :y => 0, :w => 1, :h => 1}
    scroll_init(*args)
    @count = 0
    @dir = 1
    @long = false
    #self.windowskin = $game_system.window_skin_bitmap(self.class)
  end
 
  def get_altered_skin # No idea what's this for...
    default = Cache.system('Window')
    window = Bitmap.new(default.width, default.height)
    window.blt(0, 0, default, default.rect)
    window.fill_rect(80, 16, 32, 32, Color.new(0,0,0,0))
    return window
  end
 
  def winw
    return self.width - standard_padding * 2
  end
 
  def winh
    return self.height - standard_padding * 2
  end
 
  def set_text(text, align = 0)
    unless (text == @text) && (align == @align)
      @text = text
      @align = align
      @count = 0
      @fake = true
      refresh
      @fake = false
      tw = @tdt[:x] + @tdt[:w]
      th = @tdt[:y] + @tdt[:h]
      @long = tw > winw
      self.contents.dispose
      cw = @long ? tw : winw
      self.contents = Bitmap.new(cw, winh)
      self.ox = 0
      refresh
    end
  end
 
  def update
    super
    return unless @long
    if @count >= @@SCROLL_DELAY * 60
      if self.ox <= 0 && @dir < 0
        @dir = 1; @count = 0
      elsif self.ox >= contents.width - winw && @dir > 0
        @dir = -1; @count = 0
      else
        self.ox += @dir * @@SCROLL_SPEED
      end
    else
      @count += 1
    end
  end
    
  def draw_text_ex(x, y, text)
    @tdt = {:x => x, :y => y, :w => 0, :h => 0}
    super
  end
    
  def process_normal_character(c, pos)
    if @fake
      #return unless c >= ' ' Only enable this line if you use LoneWolf's character fix!
      text_width = text_size(c).width
      pos[:x] += text_width
      @tdt[:w] = pos[:x] if @tdt[:w] < pos[:x]
      @tdt[:h] = pos[:y] + pos[:height]
    else
      super
    end
  end

end
Looks much better, at least to me. 😛
Thanks Sixth, youre awesome 🙂 There is a small issue with it however, its not compatible with Killozapit Word wrapper script :-( If I have a long description, it just shows what fits into the window, then leaves out the rest, and doesnt scroll.

Picture

Killozapit word wrapper
Disable the word wrapper feature in your descriptions and it will work.
If I remember right, that word wrapper script got a message code for disabling the word wrapping for the text.

Actually, screw that, the message codes from that script are barely functional.
And the word wrap script itself got a bug, which will insert line breaks whether you enable word wrapping or not.

In the word wrap script, you should see a line like this:
Code:
if pos[:x] + get_next_word_size('', text) > contents.width
Just above this line, insert this line:
Code:
return unless @wordwrap
This will fix the line break issue when the word wrap is turned off.

In addition, in the scroll text script, at the very end of the initialize method, add these lines:
Code:
    @wordwrap = @convert_newlines = @collapse_whitespace = false
    @right_margin = 0
And this should make the scroll text work with that annoying word wrap script.
Again Thank You Sixth, you're awesome 🙂 It works as intended 🙂
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/need-a-little-change-in-this-scroll-text.84291/