Yet Another External Message Script
Version: 1.0 : 21/08/2009
By: Trebor777
Introduction
Loads a txt file, and call the messages stored in it for your dialogs! Make your life easier for translations, and management.
Features
Aims to be super simple !
Screenshots
Well... it's for dialogs... so...
Demo
It's so simple you shouldn't need one.
Script
Instructions
Read the header or read this:
How to use ?
1st, you need to load the messages in memory. The messages are stored in files, inside the Data/Text/ folder ( you need to create it )
The text file can be name as you like :)
So you load the file like this :
Then to display a message from this file, using the call_script command:
You don't have to specify: position, background, face_name & index, by default:
FILE SPECIFICATION: very simple
Be Aware for the length of each line !!! text editors are not limited unlike the event message !
FAQ
Does this work under XP ? Maybe I'm not sure, because of the way message are handled in XP. A XP version might come in the future, if heavily requested.
When I call twice display_message in the same "script" command, the 2nd message follows the 1st on the same page, is it a bug?? No it's not, it's voluntary for flexibility.
If you want two different messages to not be following each other directly on the same message box, simply call the second one , in a new "call script" command.
Compatibility
Should be compatible with everything :) I added a method in the Game Interpreter class.
Terms and Conditions
As usual, Commercial or Not, you can edit it, just don't delete my name :), You don't have to put me in the credits.
Version: 1.0 : 21/08/2009
By: Trebor777
Introduction
Loads a txt file, and call the messages stored in it for your dialogs! Make your life easier for translations, and management.
Features
Aims to be super simple !
Screenshots
Well... it's for dialogs... so...
Demo
It's so simple you shouldn't need one.
Script
- # ================================================================
- # Yet Another External Message Script
- # Trebor777
- # v 1.0
- # 21/08/2009
- # ================================================================
- =begin
- How to use ?
- 1st, you need to load the messages in memory. The messages are stored
- in files, inside the Data/Text/ folder ( you need to create it )
- The text file can be name as you like :)
- So you load the file like this :
- Text_Reader.load_file(filename) !!! filename doesn't contain the extension !!!
- Then to display a message from this file, using the call_script command:
- display_message(id , position, background, face_name, face_index)
- You don't have to specify: position, background, face_name & index, by default:
- .position = 2, means bottom of the screen ( 0 = top, 1 = middle, 2 = bottom)
- .background = 1, means "dark", ( 0 = normal, 1 = dark(uses the messageback), 2 = transparent)
- .face_name = "", means no faceset is used. it's the name of the Faceset file.
- .face_index = 0, the position of the face in the faceset.
- FILE SPECIFICATION: very simple
- . file extension must be .txt.'
- . the messages are identified by numbers :),
- . messages can take as many lines as you wish, because RM is not that dumb, it'll
- display new "messages" when there are more than 4 lines.
- example:
- [0000]:Hey! How's it going?
- Not too bad! You?
- I'm cool.
- Great so what's up?
- [0001]: Not much actually, I'm working on a game called "SUPER GAME"
- REeeaally ??? That's cool dude!
- Yeah :) we're quite happy with it, though there is still loads to do!
- [0002]: Well tell me when there will be a demo!
- Sure I'll !
- line 3
- line 4
- line 5
- # ================================================================
- =end
- module Text_Reader
- @@messages = {}
- def self.load_file(file_id)
- if File.exist? "Data/Text/#{file_id}.txt"
- File.open("Data/Text/#{file_id}.txt",'rb'){ |file| Text_Reader.parse(file)}
- else
- p "I'm not crashing, but just to tell you: Text File \"#{file_id}.txt\" doesn't exist in the Data/Text/ folder."
- end
- end
- def self.parse(file)
- lines = file.readlines
- id = 0
- lines.each do |line|
- # Check if message ID is found
- id_ = line.scan(/\[(\d+)\]:/).flatten # Extract "[0000]:", if no ID, returns []
- txt = line.split("[#{id_}]:").last.chomp # ID or not, the message will always be the last item in the split, ( last is the 1st, if size == 1 ). Removes the end of line character.
- id = id_[0].to_i unless id_.empty? # Update current message ID if there is a new one
- if @@messages[id].nil? # New id ?
- @@messages[id] = [txt] # Add a new message array containing the 1st line
- else
- @@messages[id] << txt # Add the line to the current message array
- end
- end
- end
- def self.[](id)
- @@messages[id] || [] # If the message doesn't exist, return an empty array :) instead of nil
- end
- end
- class Game_Interpreter
- def display_message(id, position = 2, back = 1, face_name = "", face_index = 0)
- Text_Reader[id].each {|str| $game_message.texts << str }
- @message_waiting = true
- $game_message.background = back
- $game_message.position = position
- $game_message.face_name = face_name
- $game_message.face_index = face_index
- $game_message.main_proc = Proc.new { @message_waiting = false }
- return false
- end
- end
Expand to see the code.
Instructions
Read the header or read this:
How to use ?
1st, you need to load the messages in memory. The messages are stored in files, inside the Data/Text/ folder ( you need to create it )
The text file can be name as you like :)
So you load the file like this :
- Text_Reader.load_file(filename) # !!! filename doesn't contain the extension !!!
Expand to see the code.
Then to display a message from this file, using the call_script command:
- display_message(id , position, background, face_name, face_index)
Expand to see the code.
You don't have to specify: position, background, face_name & index, by default:
- position = 2, means bottom of the screen ( 0 = top, 1 = middle, 2 = top)
- background = 1, means "dark", ( 0 = normal, 1 = dark(uses the messageback), 2 = transparent)
- face_name = "", means no faceset is used. it's the name of the Faceset file.
- face_index = 0, the position of the face in the faceset.
FILE SPECIFICATION: very simple
- file extension must be .txt.'
- the messages are identified by numbers :)
- messages can take as many lines as you wish, because RM is not that dumb, it'll display new "messages" when there are more than 4 lines.
Quote:
[0000]:Hey! How's it going?
Not too bad! You?
I'm cool.
Great so what's up?
[0001]: Not much actually, I'm working on a game called "SUPER GAME"
REeeaally ??? That's cool dude!
Yeah :) we're quite happy with it, though there is still loads to do!
[0002]: Well tell me when there will be a demo!
Sure I'll !
line 3
line 4
line 5
Not too bad! You?
I'm cool.
Great so what's up?
[0001]: Not much actually, I'm working on a game called "SUPER GAME"
REeeaally ??? That's cool dude!
Yeah :) we're quite happy with it, though there is still loads to do!
[0002]: Well tell me when there will be a demo!
Sure I'll !
line 3
line 4
line 5
Be Aware for the length of each line !!! text editors are not limited unlike the event message !
FAQ
Does this work under XP ? Maybe I'm not sure, because of the way message are handled in XP. A XP version might come in the future, if heavily requested.
When I call twice display_message in the same "script" command, the 2nd message follows the 1st on the same page, is it a bug?? No it's not, it's voluntary for flexibility.
If you want two different messages to not be following each other directly on the same message box, simply call the second one , in a new "call script" command.
Compatibility
Should be compatible with everything :) I added a method in the Game Interpreter class.
Terms and Conditions
As usual, Commercial or Not, you can edit it, just don't delete my name :), You don't have to put me in the credits.