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.

Scrolling Text

Vent

Member

Does anyone know how to make text scroll if it's too big for a window? I think a lot of other people would like this for help windows.
Thanks in advance.
 
Dubealex Text Scroll
Version: Release #3


Introduction

This script provides scrolling text in your game through creating designated books and using call script events. It gives the appearance of some of those long storylines you would see in a professional game (also can be used for end credits).

Features
  • Takes text from a text file in the Text directory of your projects.
  • Can show the scrolling anywhere, on the map or in another scene.
  • Live Scroll options > Allow to use player/event while scrolling. (New in release 3)
  • Can control the scrolling UP/DOWN like Windows window.
  • Can create Books using RIGHT/LEFT arrow to swap pages, 100% script (New in release 3)
  • Can change line colors from within the text file.
  • Can change the main text color from within the text file (new in release 2)
  • Info on how to fix foreign characters (as french and german) added to manual.
  • Easy to use, fast, and small.
Screenshots

N/A

Demo

Clicky

Script

Code:
#===================================================
# â–  Text Scroll Script  R3-Fixed - Created by dubealex
#===================================================
# For more infos and update, visit:
# rmxp.dubealex.com
#
#-> Stack level too deep caused by ALIAS now fixed.
#
# November 29, 2004
#===================================================

#===================================================
# â–¼ CLASS Text_Scroller Begins
#===================================================
class Text_Scroller
 
 def initialize (file, opacity_scroll, opacity_bg, speed, live_scroll)
   
   text=IO.readlines("Text/#{file}")
   $tss_speed = speed
   $tss_iteration = 480.0/speed
   $tss_sy= (text.size*32) + 64
   
   $tss_scroll_window = Window_Scroll.new(file, 640, $tss_sy)
   $tss_scroll_window.opacity = opacity_scroll
   $tss_scroll_window.z=500
   $tss_scroll_window.x = 0
   $tss_scroll_window.y = 480
   
   $tss_bg_window = Window_bg.new
   $tss_bg_window.opacity = opacity_bg
   $tss_bg_window.z=400
   
   case live_scroll
   when 0  
     update
     when 1  
       $live_scroll=true
   end
 end  

 def update
       for i in 0...(($tss_sy/480.0) * $tss_iteration) + $tss_iteration
          $tss_scroll_window.y -= $tss_speed
          Graphics.update
        end
        $tss_scroll_window.dispose
        $tss_bg_window.dispose
  end
end
#===================================================
# â–² CLASS Text_Scroller Ends
#===================================================


#===================================================
# â–¼ CLASS Window_Scroll Begins
#===================================================
class Window_Scroll < Window_Base

 def initialize (file, sx, sy)
   @sx=sx
   @sy=sy
   
   super(0, 0, sx, sy)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = "Tahoma"
   self.contents.font.size = 24
   @text=IO.readlines("Text/#{file}")
   @text_color=0
   refresh
 end
 
 def refresh    
   y=0
     for i in 0...@text.size
       y+=32
       if @text[i].index('/') == 0
           @text_color=@text[i].slice! (0..2)
           @text_color.slice!(0)
       end  
       if @text[i].index('*') == 0
           line_color=@text[i].slice! (0..2)
           line_color.slice!(0)
          self.contents.font.color = text_color(line_color.to_i)
        else
       self.contents.font.color = text_color(@text_color.to_i)
       end
       self.contents.draw_text(0, y, @sx, 32, @text[i])
     end
 end
end
#===================================================
# â–² CLASS Window_Scroll Ends
#===================================================


#===================================================
# â–¼ CLASS Book_Scroll Begins
#===================================================
class Book_Scroll
 
 def initialize (book_name, number_of_pages, start_page, opacity_scroll, opacity_bg)
   
   file = book_name.to_s+"/"+start_page.to_s+".rxdata"
   text=IO.readlines("Text/#{file}")
   $tss_sy= (text.size*32) + 64
   
   $tss_scroll_window = Window_Scroll.new(file, 640, $tss_sy)
   $tss_scroll_window.opacity = opacity_scroll
   $tss_scroll_window.z=500
   $tss_scroll_window.x = 0
   $tss_scroll_window.y = 0
   
   $tss_bg_window = Window_bg.new
   $tss_bg_window.opacity = opacity_bg
   $tss_bg_window.z=400
   
   book_update(book_name, start_page, number_of_pages, opacity_scroll, opacity_bg)
   $game_system.menu_disabled = true
 end  
 
 def book_update(book_name,start_page, number_of_pages, opacity_scroll, opacity_bg)
   loop do
   Graphics.update
   Input.update
   if Input.repeat?(Input::RIGHT) and number_of_pages > 1
     unless start_page == number_of_pages
       start_page+=1
     else
       start_page=1
     end  
     $tss_scroll_window.dispose
     $tss_bg_window.dispose
     Book_Scroll.new(book_name, number_of_pages,start_page, opacity_scroll, opacity_bg)
     break
   end
   if Input.repeat?(Input::LEFT) and  number_of_pages > 1
     unless start_page == 1
       start_page-=1
     else
       start_page=number_of_pages
     end  
     $tss_scroll_window.dispose
     $tss_bg_window.dispose
     Book_Scroll.new(book_name, number_of_pages,start_page, opacity_scroll, opacity_bg)
     break
   end
   if Input.repeat?(Input::UP)
     $tss_scroll_window.y+=15
   end  
   if Input.repeat?(Input::DOWN)
     $tss_scroll_window.y-=15
   end  
   if Input.trigger?(Input::B)
     $tss_scroll_window.dispose
     $tss_bg_window.dispose
     $game_system.menu_disabled = false
     break
   end
 end
end  
   
end
#===================================================
# â–² CLASS Book_Scroll Ends
#===================================================


#===================================================
# â–¼ CLASS Scene_Map Additional Code Begins
#===================================================
class Scene_Map

 alias alex_tss_original_update update
 @@i=0
 
 def update
 alex_tss_original_update
   
   if $live_scroll==true
      $tss_scroll_window.y -= $tss_speed
       @@i+=1
       if @@i ==(($tss_sy/480.0) * $tss_iteration) + $tss_iteration
         $tss_scroll_window.dispose
         $tss_bg_window.dispose
         @@i=0
         $live_scroll=false
       end  
   end
 end
end
#===================================================
# â–² CLASS Scene_Map Additional Code Ends
#===================================================


#===================================================
# â–¼ CLASS Window_bg Begins
#===================================================
class Window_bg < Window_Base

 def initialize
   super(0, 0, 640, 480)
 end
end
#===================================================
# â–² CLASS Window_bg Ends
#===================================================
Instructions

Your text files:
They must be a raw text file, with no formatting saved in it. So you cannot use WordPad, Word, Wordperfect or any other program beside Notepad.

Save it as ANSI or UTF-8 if you need extra-foreign character like é or à -- Don't use the other format.

The text that will be used in the scrolling window is taken in your text files. You just have to create a directory named "Text" in your project root folder, and put your text in it. You can have the extention you want, you will have to specify it when calling the window in your scripts/events. I named them rxdata to make them fit with the rest... But they are just TXT files. Take note that for book, your are obligated to use .rxdata as your file extention. (Use RIGHT-CLICK and choose OPEN WITH>NOTEPAD in Win XP for fast access.)

When you write in your text file (using notepad), make sure to make short lines, remember that the screen of RMXP is a bit less than 640 pixel width. Make some test, and adjust yourself accordingly. Your text file can be as long as you want, but the longer they are, the longer it is to build the window.

About foreign language/character:
You can use foreign characters, as french or german one, in the script, as the following characters: ß ä ¼ ê «

All you need to do to allow the characters like those to show up is to save your text file as UTF-8 with Notepad. (Open Notepad, choose SAVE AS, and select the last option, should be UTF-8).

There is one important thing to remember using this, and it's that you cannot use the color code to change the color of the text on the first line, but you can on any other line. So if you need to set the first line as another color, for a title or something, simply leave an empty line on the beggining of the file, and start your true text on line 2.

Using colors code:
I coded something in the script that will allow you to specify a color for the line and also a color for the main text being displayed, so your stories or credits can be a little bit more interesting.

-> The Line Color code:
The line color code will change only one line to a specific color, and that's all. To do so, you must begin the line with a * sign, followed by the 2 digits representing the color ID you want to use. Those color ID are defined in the class Window Base, and you can add as much as you desire. You must use 2 digits, so put a 0 in front of it if the number is below 10... like 07. And do not use space between the words and the syntax. Here's a example:

*06Hi, what's up ? I don't know !!!

You will be able to use the * sign elsewhere in the lign, because I just check the first character for it.

-> The Main Color code:
The main color code allow you to specify a color for the entire text, without the need of inserting the line code (*) before each line. To use it, you have to start your line with a / symbol followed by the 2 digit representing your color ID. You can use the / sign anywhere but not as the first character, unless you want to specify a color. So if you want the text to be yellow, you use /06 as the line start. This code will make the entire text become of the color you specified, without you having to add a * code in each line. You can still use the * code to change a line color, and the color will return to the one you specified with / after it's been drawn. You can change the color with another / anytime, and the color of
all line will now be of that new one. Have fun ! Here's an example:

/06Hi, what's up ? I don't know !!!

The syntax to call the scrolling window:
You can use that syntax in a Call Script with an event, or within your own script/scene. The syntax is the following:

Text_Scroller.new("FileName", scroll_opacity, bg_opacity, speed, Live Scroll?)

FileName Is where you write the exact same filename (with the extention) of your text file within the Text folder. Take note that you can do sub folders to classify your things, just incluse the path in the filename. Here's 2 example:

Code:
Text_Scroller.new("Credits Demo.rxdata", 0,0, 2, 0)
#Will use the file in Text\Credits Demo.rxdata 
Text_Scroller.new("MyStuff/Credits Demo.rxdata", 0,0, 2, 0)
#Will use the file in Text\MySTuff\Credits Demo.rxdata
Something important to remember is that in RGSS, the \ (backslash) character used in windows in drive path is a / (slash) character; as on the web.

scroll_opacity Set the opacity of the window in which the text will scroll. 255 is opaque, and 0 is transparent. I suggest you set it to 0 and tint the screen, or use a background pictures, it's give better results.

bg_opacity Set the opacity of the "dummy" background window. You can now have a window displayed behind the scrolling text, sized to 640X480 (full screen), if you dont want to use it, simply set its opacity to 0. 255 is opaque, and 0 is transparent.

speed Set the speed at which the text will scrolls. The minimum (slower) speed is 1. If you do story, it's a good idea to make a lot of paragraph and add extra empty lines between them so the player can read the text. Check the demo.

Live Scroll? The last option is the Live Scroll option. When set to 0, the player and every other event processing will stop. If you set it to 1,event
processing and the player controls will be available, meaning that the player will be able to move around while the text is scrolling and it also means that event processing... (Parallel, Auto, and all other type) will still work perfectly. Use this to create better cut scene and intro story.

Remember the Trick to stop/enable the control of the hero with a Move Event.You do a move event "Move Toward Hero" on the player itself, it then freezes.To regain control use a "Face Hero" (Face Player) command on the hero again. Neat !

You can also allow/disallow menu with a simple event commands. Look at the demo !

The syntax to call The Book Scroller:

New from Release 3, you now can use Books without any common events, without any game variables and without any game switches; it's 100$ script ! Here's the syntax to call a book:

Book_Scroll.new("book_title",number_of_pages,start_page,book_window,bg_window)

"book_title" The book title is where you specified the title of your book. It must be the name of the directory where you put your pages in. This book directory must be in the Text directory.
Example: Text\My Book

number_of_pages You must specify a total number of pages so the script can carry out everything by itself. If your page have 10 pages, you put a 10 in there.

REMEMBER: All your pages must be only a number starting from 1. And the extention must be .rxdata

EXAMPLE: For a 5 pages book, the files in your book directory would look like that:

1.rxdata
2.rxdata
3.rxdata
4.rxdata
5.rxdata


start_page Here you specify on which page the book should be opened. Insert 1 to open page 1 as default.

book_window Set the opacity of the window in which the text will scroll. 255 is opaque, and 0 is transparent. I suggest you set it to 0 and tint the screen, or use a background pictures, it's give better results.

bg_window Set the opacity of the "dummy" background window. You can now have a window displayed behind the scrolling text, sized to 640X480 (full screen), if you dont want to use it, simply set its opacity to 0. 255 is opaque, and 0 is transparent.

When using the "Book Syntax" to call a book, be sure to add a event command "Allow/Disallow Main Menu" and choose "Allow" right after the call script of the book. Add a wait of 5 frames between the two. It should look like that:

-> Message
-> Call Script - Calling your book
-> Wait 5 frames
-> Allow/Disallow Main Menu-Allow


This will be fixed in future release.
FAQ

Please refer to the original thread at Dubealex's website. http://www.dubealex.com/asylum/index.php?showtopic=52&hl=Text+Scroll

Compatibility

I don't have any idea if this script is compatible with SDK. But it should work just fine with any other scripts.

Credits and Thanks

Sole credit should go to Dubealex, not me. I just reposted what he posted.

Author's Notes

Visit www.dubealex.com for more of Dubealex's scripts.
 

Vent

Member

Thats a nice script, and thank you for helping me, but it's not what I was really looking for.
I apologize for not explaining it well enough.
I need a script that makes text scroll horizontally, because I want to use it to make a help window like the one in Wild ARMs 4.
Thanks again.
 

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