ForeverZer0's Diary Script Edit

Started by Vexus, May 18, 2012, 12:54:29 pm

Previous topic - Next topic

Vexus

I can't find any decent script which has a diary like book to write notes on so I started editing foreverzer0's diary script.

I managed to put a picture as background, managed to move some of the font (Can't find which line moves the chapter's line) and managed to lower the font size BUT for some odd reason the font type doesn't want to change nor the font color eventhough the script command is written correct.

Also when I close the window the picture goes as it should but the window with the words, etc stays for a bit longer then goes off.

This is the edited script:

Spoiler: ShowHide
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# Diary Scene
# Author: ForeverZer0
# Version: 1.0
# Date: 12.18.2010
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Introduction:
#
#   This is a basic script that will allow you to keep a "diary" or notepad in
#   your game. It is very simple to use, and uses a simple interface for
#   displaying the notes.
#
# Features:
#
#   - Group your notes into "chapters". 
#   - Automatically formats text to fit on each line in a legible format.
#   - Simple script call to add text.
#   - Option to define each note in the script editor, then simply use a script
#     call to add it.
#   - Option to use the map as the background.
#
# Instructions:
#
#   - Place script above main, and below default scripts.
#   - Make configurations below.
#   - To call the scene, use this syntax:  $scene = Scene_Diary.new
#   - To add an entry, use this syntax:
#
#     Diary.add_entry(CHAPTER, TEXT)
#     
#     CHAPTER: An arbitrary integer to define what group to add the note to.
#     TEXT: Either a string which will be the text added to the diary, or an
#           integer which will return the string defined in the configuration
#           below. The second method will make it easier to make long notes
#           without filling up the little script call box.
#
# Author's Notes:
#
#  - Please be sure to report any bugs/issues with the script. Enjoy!
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

module Diary
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#                         BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   
  MAP_BACKGROUND = false
  # Set to true if you would like the map to show behind the window.
  RETURN_SCENE = Scene_Map
  # The scene that the game returns to when you exit the diary.
  SCENE_ARGUMENTS = []
  # Define any arguments that may need called with scene if need be. Place them
  # in the array in the order in which they are normally called.
 
  def self.chapter_name(chapter)
    # Define the names of the "chapters".
    # when CHAPTER then "CHAPTER_NAME"
    return case chapter
    when 1 then 'Millenium Fair'
    when 2 then 'What Happened to Marle?'
    end
  end
 
  def self.entry(index)
    # Define the strings that correspond with each index. The index can be called
    # instead of actual text to add an entry.
    # when INDEX then "TEXT"
    return case index
    when 0 then 'I Forgot Today was the day of the big fair! I was supposed to go and see Lucca\'s new invention.'
    when 1 then 'I need to escort Marle around the fair, and maybe play a few games.'
    when 2 then 'Marle was sucked into the vortex. I think it had something to do with that pendant that she was wearing...'
    when 3 then 'This place is very strange, and everyone talks funny. It\'s all vaguely the same, yet different. Where am I?'
    end
  end

#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#                           END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  def self.add_entry(chapter, text)
    # Add the chapter number if it does not exist.
    if $game_party.diary[chapter] == nil
      $game_party.diary[chapter] = []
    end
    if text.is_a?(String)
      # Add the new entry to the end of the chapter.
      $game_party.diary[chapter].push(text)
    elsif text.is_a?(Integer)
      # Get the defined note if the text is a number.
      $game_party.diary[chapter].push(self.entry(text))
    end
  end
end

#===============================================================================
# ** Window_Diary
#===============================================================================

class Window_Diary < Window_Base
 
  attr_reader :lines
 
  def initialize
    super(35, 50, 265, 416) #0, 64, 640, 416
    self.opacity = Diary::MAP_BACKGROUND ? 0 : 0
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Zephyr"
    self.contents.font.size = 20
    self.contents.font.color = Color.new(0, 0, 0, 255)
    @lines = []
  end
 
  def chapter=(chapter)
    # Reset the current entries.
    entries = $game_party.diary[chapter]
    entries = [''] if entries == nil
    # Divide the current entries into lines based off the text size and length.
    @lines = entries.collect {|text| self.contents.slice_text(text, 80) } #608
    @lines.flatten!
    refresh
  end
 
  def refresh
    # Dispose bitmap, returning if no lines are defined.
    self.contents.clear
    return if @lines.size == 0
    self.contents.dispose
    # Create bitmap to contain the lines.
    self.contents = Bitmap.new(self.width - 32, @lines.size * 32)
    # Draw each line.
    @lines.each_index {|i| self.contents.draw_text(0, i*32, 608, 32, @lines[i])}# 0, i*32, 608, 32
  end
end

#===============================================================================
# ** Bitmap
#===============================================================================
   
class Bitmap
 
  # Blizzard's slice_text method. This method can be removed if you have another
  # script that already uses it.
  def slice_text(text, width)
    words = text.split(' ')
    return words if words.size == 1
    result, current_text = [], words.shift
    words.each_index {|i|
    if self.text_size("#{current_text} #{words[i]}").width > width
      result.push(current_text)
      current_text = words[i]
    else
      current_text = "#{current_text} #{words[i]}"
    end
    result.push(current_text) if i >= words.size - 1}
    return result
  end
end

#===============================================================================
# ** Scene_Diary
#===============================================================================

class Scene_Diary
 
  def main
    @diary = Sprite.new
    @diary.bitmap = RPG::Cache.picture("Diary.png") #rescue nil
    # Create the windows.
    @sprites = [Window_Help.new, Window_Diary.new]
    if Diary::MAP_BACKGROUND
      @sprites.push(Spriteset_Map.new)
      @sprites[0].opacity = 0 #160
    end
    @sprites[0].opacity = 0 #160
    @keys = $game_party.diary.keys.sort
    @names = @keys.collect {|chapter| Diary.chapter_name(chapter) }
    # Find current index, setting to first chapter if undefined.
    @index = @keys.index(Diary.chapter_name(@chapter))
    @index = 0 if @index == nil
    # Set the information for each window.
    @sprites[0].set_text(@names[@index] == nil ? '' : @names[@index])
    @sprites[1].chapter = @keys[@index]
    # Transition Graphics.
    Graphics.transition
    # Main loop.
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose windows.
    @diary.dispose
    Graphics.freeze
    @sprites.each {|sprite| sprite.dispose }
  end
 
  def update
    # Branch by what input is recieved.
    if Input.repeat?(Input::UP) || Input.trigger?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      @sprites[1].oy -= 32 if @sprites[1].oy if @sprites[1].oy > 0
    elsif Input.repeat?(Input::DOWN) || Input.trigger?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      @sprites[1].oy += 32 if @sprites[1].oy < (@sprites[1].contents.height-384)
    elsif Input.trigger?(Input::L) || Input.trigger?(Input::R)
      $game_system.se_play($data_system.decision_se)
      # Change the current index.
      @index += Input.trigger?(Input::L) ? -1 : 1
      @index %= @keys.size
      # Display the name of the current chapter in the header.
      @sprites[0].set_text(@names[@index], 1)
      # Change the current chapter.
      @sprites[1].chapter = @keys[@index]
    elsif Input.trigger?(Input::B)
      # Play cancel SE and return to the defined scene.
      $game_system.se_play($data_system.cancel_se)
      args, scene = Diary::SCENE_ARGUMENTS, Diary::RETURN_SCENE
      $scene = (args == []) ? scene.new : scene.new(*args)
    end
  end
 
end

#===============================================================================
# ** Game_Party
#===============================================================================

class Game_Party
 
  attr_accessor :diary
 
  alias zer0_diary_init initialize
  def initialize
    zer0_diary_init
    @diary = {}
  end
end


Could anyone help?

Thanks

Also here's a picture of what I'm trying to do:

Spoiler: ShowHide


The Chapter should be written on the top while the rest of the words under it.

The only flaw I have is that I can only write on the left page of the diary because I resized the window to be able to move it on the left page.
Current Project/s:

ForeverZer0

The font doesn't change because the refresh method disposes the bitmap and recreates it. Just move your font change line to after the "self.contents.dispose" line and after it is recreated.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Vexus

May 18, 2012, 01:09:28 pm #2 Last Edit: May 19, 2012, 08:23:48 am by Vexus
It worked! Tough the chapter line font color is still default.

Been looking at the script for hours it's driving me crazy.

Thanks for the help.

[Edit]

Uploading a picture of my current version and to show you the problem on chapter font not wanting to change color:

Spoiler: ShowHide


I tried several things like:

@sprites[0].contents.font.color = Color.new(0,0,0)


Or even adding a new color in window base and try changing it to it but nothing happens on the chapter's color :S.

To be able to change the font and move the chapter I had to put the pieces of coding in scene diary instead of window diary.

Any help?

Also I was thinking on the possibility of having text also on the right side of the diary but I have no idea on how could I do it. I was thinking on maybe having 2 chapters showing, chapter 1 on left page, chapter 2 on right page then you switch to chapter 3,4 etc etc.

Would it be hard to implement?

Thanks
Current Project/s:

ForeverZer0

May 20, 2012, 01:26:06 am #3 Last Edit: May 20, 2012, 01:29:50 am by ForeverZer0
It doesn't change because the scene uses Window_Help, and the "set_text" method in that script sets the color to "normal_color" right before it draws. Here's an extension to Window_Help that will allow you to fix it. Modify the "set_text" method to use a "color" argument that sets the color.

class Window_Help
 
 def set_text(text, align = 0, color = normal_color)
   # If at least one part of text and alignment differ from last time
   if text != @text or align != @align
     # Redraw text
     self.contents.clear
     self.contents.font.color = color
     self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
     @text = text
     @align = align
     @actor = nil
   end
   self.visible = true
 end
end

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Vexus

May 20, 2012, 06:33:43 am #4 Last Edit: May 20, 2012, 08:58:28 am by Vexus
Thanks that worked perfectly!

I added some extra lines to edit the window size too to fit only 1 page.

Would you mind helping me on 1 last tiny thing?

When I test the diary the chapter words show on the far left near the border then when I switch chapter they get aligned to the middle, what do I have to do so that the chapter words doesn't get aligned so I won't have problems with long chapter names in the future if I ever needed it.

Thanks

[Edit]

Meh even on the normal text when I switch page they are getting screwed with the align eventough the window is the size of a page the words keep on going. :/

Here's a pic to show the problem:

Spoiler: ShowHide


Spoiler: ShowHide
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# Diary Scene
# Author: ForeverZer0
# Version: 1.0
# Date: 12.18.2010
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
#
# Introduction:
#
#   This is a basic script that will allow you to keep a "diary" or notepad in
#   your game. It is very simple to use, and uses a simple interface for
#   displaying the notes.
#
# Features:
#
#   - Group your notes into "chapters". 
#   - Automatically formats text to fit on each line in a legible format.
#   - Simple script call to add text.
#   - Option to define each note in the script editor, then simply use a script
#     call to add it.
#   - Option to use the map as the background.
#
# Instructions:
#
#   - Place script above main, and below default scripts.
#   - Make configurations below.
#   - To call the scene, use this syntax:  $scene = Scene_Diary.new
#   - To add an entry, use this syntax:
#
#     Diary.add_entry(CHAPTER, TEXT)
#     
#     CHAPTER: An arbitrary integer to define what group to add the note to.
#     TEXT: Either a string which will be the text added to the diary, or an
#           integer which will return the string defined in the configuration
#           below. The second method will make it easier to make long notes
#           without filling up the little script call box.
#
# Author's Notes:
#
#  - Please be sure to report any bugs/issues with the script. Enjoy!
#
#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

module Diary
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#                         BEGIN CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
   
  MAP_BACKGROUND = false
  # Set to true if you would like the map to show behind the window.
  RETURN_SCENE = Scene_Menu.new(2)#Scene_Map
  # The scene that the game returns to when you exit the diary.
  SCENE_ARGUMENTS = []
  # Define any arguments that may need called with scene if need be. Place them
  # in the array in the order in which they are normally called.
 
  def self.chapter_name(chapter)
    # Define the names of the "chapters".
    # when CHAPTER then "CHAPTER_NAME"
    return case chapter
    when 1 then 'Millenium Fair'
    when 2 then 'What Happened to Marle?'
    end
  end
 
  def self.entry(index)
    # Define the strings that correspond with each index. The index can be called
    # instead of actual text to add an entry.
    # when INDEX then "TEXT"
    return case index
    when 0 then 'I Forgot Today was the day of the big fair! I was supposed to go and see Lucca\'s new invention.'
    when 1 then 'I need to escort Marle around the fair, and maybe play a few games.'
    when 2 then 'Marle was sucked into the vortex. I think it had something to do with that pendant that she was wearing...'
    when 3 then 'This place is very strange, and everyone talks funny. It\'s all vaguely the same, yet different. Where am I?'
    end
  end

#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#                           END CONFIGURATION
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  def self.add_entry(chapter, text)
    # Add the chapter number if it does not exist.
    if $game_party.diary[chapter] == nil
      $game_party.diary[chapter] = []
    end
    if text.is_a?(String)
      # Add the new entry to the end of the chapter.
      $game_party.diary[chapter].push(text)
    elsif text.is_a?(Integer)
      # Get the defined note if the text is a number.
      $game_party.diary[chapter].push(self.entry(text))
    end
  end
end

#===============================================================================
# ** Window_Diary
#===============================================================================

class Window_Diary < Window_Base
 
  attr_reader :lines
 
  def initialize
    super(48, 50, 265, 480) #0, 64, 640, 416
    self.opacity = Diary::MAP_BACKGROUND ? 0 : 0
    self.contents = Bitmap.new(width - 32, height - 32)
    @lines = []
  end
 
  def chapter=(chapter)
    # Reset the current entries.
    entries = $game_party.diary[chapter]
    entries = [''] if entries == nil
    # Divide the current entries into lines based off the text size and length.
    @lines = entries.collect {|text| self.contents.slice_text(text, 260) } #260
    @lines.flatten!
    refresh
  end
 
  def refresh
    # Dispose bitmap, returning if no lines are defined.
    self.contents.clear
    return if @lines.size == 0
    self.contents.dispose
    # Create bitmap to contain the lines.
    self.contents = Bitmap.new(self.width - 32, @lines.size * 32)
    self.contents.font.name = "where stars shine the brightest"
    self.contents.font.size = 33
    self.contents.font.color = diary_color
    # Draw each line.
    @lines.each_index {|i| self.contents.draw_text(0, i*32, 608, 32, @lines[i])}
  end
end

#===============================================================================
# ** Window_Help
#===============================================================================
class Window_Help
 
   def initialize
    super(48, 0, 200, 60) #0, 64, 640, 416
    self.contents = Bitmap.new(width - 32, height - 32)
  end
 
  def set_text(text, align = 0, color = diary_color)
    # If at least one part of text and alignment differ from last time
    if text != @text or align != @align
      # Redraw text
      self.contents.clear
      self.contents.font.color = diary_color
      self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
end

#===============================================================================
# ** Bitmap
#===============================================================================
   
class Bitmap
 
  # Blizzard's slice_text method. This method can be removed if you have another
  # script that already uses it.
  def slice_text(text, width)
    words = text.split(' ')
    return words if words.size == 1
    result, current_text = [], words.shift
    words.each_index {|i|
    if self.text_size("#{current_text} #{words[i]}").width > width
      result.push(current_text)
      current_text = words[i]
    else
      current_text = "#{current_text} #{words[i]}"
    end
    result.push(current_text) if i >= words.size - 1}
    return result
  end
end

#===============================================================================
# ** Scene_Diary
#===============================================================================


class Scene_Diary
 
  FONT_NAME = "where stars shine the brightest"
  FONT_SIZE = 34
 
  def main
    @diary = Sprite.new
    @diary.bitmap = RPG::Cache.picture("Diary.png") #rescue nil
    # Create the windows.
    @sprites = [Window_Help.new, Window_Diary.new]
    if Diary::MAP_BACKGROUND
      @sprites.push(Spriteset_Map.new)
      @sprites[0].opacity = 0 #160
    end
    @sprites[0].opacity = 0 #160
    #@sprites[0].x = 45
    @sprites[0].contents.font.name = FONT_NAME
    @sprites[0].contents.font.size = FONT_SIZE

    @keys = $game_party.diary.keys.sort
    @names = @keys.collect {|chapter| Diary.chapter_name(chapter) }
    # Find current index, setting to first chapter if undefined.
    @index = @keys.index(Diary.chapter_name(@chapter))
    @index = 0 if @index == nil
    # Set the information for each window.
    @sprites[0].set_text(@names[@index] == nil ? '' : @names[@index])
    @sprites[1].chapter = @keys[@index]
    # Transition Graphics.
    Graphics.transition
    # Main loop.
    loop { Graphics.update; Input.update; update; break if $scene != self }
    # Dispose windows.
    @diary.dispose
    Graphics.freeze
    @sprites.each {|sprite| sprite.dispose }
  end
 
  def update
    # Branch by what input is recieved.
    if Input.repeat?(Input::UP) || Input.trigger?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      @sprites[1].oy -= 32 if @sprites[1].oy if @sprites[1].oy > 0
    elsif Input.repeat?(Input::DOWN) || Input.trigger?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      @sprites[1].oy += 32 if @sprites[1].oy < (@sprites[1].contents.height-384)
    elsif Input.trigger?(Input::L) || Input.trigger?(Input::R)
      #$game_system.se_play($data_system.decision_se)
      Audio.se_play('Audio/SE/046-Book01', volume = 80, pitch = 100)
      # Change the current index.
      @index += Input.trigger?(Input::L) ? -1 : 1
      @index %= @keys.size
      # Display the name of the current chapter in the header.
      @sprites[0].set_text(@names[@index], 1)
      # Change the current chapter.
      @sprites[1].chapter = @keys[@index]
    elsif Input.trigger?(Input::B)
      # Play cancel SE and return to the defined scene.
      #$game_system.se_play($data_system.cancel_se)
      #args, scene = Diary::SCENE_ARGUMENTS, Diary::RETURN_SCENE
      #$scene = (args == []) ? scene.new : scene.new(*args)
    #end
      # Play cancel SE
      #$game_system.se_play($data_system.cancel_se)
       Audio.se_play('Audio/SE/047-Book02', volume = 90, pitch = 100)
      # Switch to menu screen
      $scene = Scene_Menu.new(2)
      return
    end
  end
 
end

#===============================================================================
# ** Game_Party
#===============================================================================

class Game_Party
 
  attr_accessor :diary
 
  alias zer0_diary_init initialize
  def initialize
    zer0_diary_init
    @diary = {}
  end
end
Current Project/s:

ForeverZer0

For what you are doing, it would probably be better to simply avoid using Window_Help, and create a an instance of Window_Base, and simply use #draw_text() so you have better control over the coordinates.
Either way, you are not forced to use the "set_text" method for Window_Help. I suggest leaving its size alone so it doesn't screw up other scenes, and use @sprites[0].draw_text(x, y, width, height, text, alignment) to draw the chapter names.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Vexus

May 20, 2012, 12:39:21 pm #6 Last Edit: May 20, 2012, 01:50:14 pm by Vexus
I managed to stop alignment on chapters now I need to figure out how to stop it on the actual paragraph :P

Ps. For the chapter line to stop being aligned all I had to do is remove the align part from the piece of code you posted.
Current Project/s:

Vexus

Now I finally got what you meant with avoiding window_help as it makes the font colour of every window that calls it the same colour of the diary scene but I don't know how to do what you said by scripting.

I tried adding < Window_Base in front of window_help but that did nothing it seems.

Also I can't find a solution for the alignment problem on the actual text page. I managed to solve the align on the chapter from the piece of code you posted of window help by removing the @align part from draw text but have no idea what I have to do on the other part where it shows the text as it keeps on getting aligned when I switch page :/.
Current Project/s:

Vexus

Any help on the problem?

No need for exactly foreverzer0 to help me I just can't figure out why the text gets aligned after I switch page but when I enter firstly It doesn't align.

I don't really need the align.

Thanks
Current Project/s:

Vexus

Bump

I still can't figure out what to edit to stop the alignment after switching pages please some help.
Current Project/s:

Vexus

Current Project/s:

KK20

What do you mean by the paragraph is not aligning? Do you mean, in that image you posted, the paragraph/diary entry is being cut off on the edges? If so click below:
Spoiler: ShowHide
Well, from a scripter's point of view, the problem I saw was this:
@sprites = [Window_Help.new, Window_Diary.new]

#further down the script, upon pressing 'L' or 'R'
@sprites[1].chapter = @keys[@index]
These are calling entirely new Window instances every time. Looking back at Window_Diary, 'def chapter=' is also where the "format the line of text into a paragraph" (slice_text) process occurs. Windows default to a font_size of 22. The slice_text method takes this font_size into account. However, you have it where the font_size is 33 when being drawn, thus making the slice_text method useless.

I did something like this:
def chapter=(chapter)
    # Reset the current entries.
    self.contents.font.name = "Arial"
    self.contents.font.size = 33
    entries = $game_party.diary[chapter]
    entries = [''] if entries == nil
    # Divide the current entries into lines based off the text size and length.
    @lines = entries.collect {|text| self.contents.slice_text(text, 260) } #260
    @lines.flatten!
    refresh
  end
and I wasn't getting any cut-off text. (Side note, I put the font style as Arial because I don't have that long-named font you have)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

First of all thank you for the help, now to answer your questions:

What I mean is when I launch the diary scene everything looks fine but when I switch page the text gets aligned differently and some is cut off the page as shown on the picture.

I placed the font name and size near bitmap because if you put them where you placed them the font doesn't change.

Also the font = 32 is for the chapter's name not for the actual paragraph.

------

I just tried your edit and it does indeed stop the font from being realigned when I switch page but it also stop the text from being organised in a way (When a certain word is too long to fit in the line instead of the whole word going on the next line the words that can fit on the first line stay there, the rest go on the 2nd line)

I keep on trying to edit the text slice number from 260 to higher but the problem persists in some way.

Anything can be done?

Thanks
Current Project/s:

ForeverZer0

Make me up a quick demo demonstrating the problem and I'll fix it up.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Vexus

Made a small demo with a box to add pages and the book on the floor to launch the scene then switch chapter with W/D and when you go back to the first page you'll see that the text has changed.

http://www.mediafire.com/?gb74vun20hok1n5

Would it be hard for me to try and have chapter 1 show on the left and chapter 2 on the right and when you switch chapters then 3 on the left and 4 on the right and so on?

I already tried something but have almost 0 clue on what to do as I know nothing about scripting apart of small edits/changes/additions.

Thanks for the help.
Current Project/s:

KK20

June 14, 2012, 06:51:05 pm #15 Last Edit: June 14, 2012, 07:00:54 pm by KK20
def slice_text(text, width)
    words = text.split('')

Ummm...why is there no space between the quotes?

Also, if the words are getting cut off, reduce that 260 to a smaller number; making it bigger will only make it worse.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

Yeah... um, I wanted to try and make paragraphs into the text but having a space between that line makes it impossible since having a lot of spaces get ignored.

There could be another way on doing it but I couldn't find one when I was fooling around.
Current Project/s:

KK20

I've made an edit for that before. Found it in one of my old scripts:
class Bitmap
  def slice_text(text, width)
    words = text.split(' ')
    return words if words.size == 1
    result, current_text = [], words.shift
    #loop
    words.each_index {|i|
      if self.text_size("#{current_text} #{words[i]}").width > width or words[i] == "/n"
        #Checks if '/n' is the current word.
        if words[i] == "/n"
          result.push(current_text)
          current_text = ""
        else
          result.push(current_text)
          current_text = words[i]
        end
      else
        # True if the previous word was '/n'
        if current_text == ""
          current_text = words[i]
        else
          current_text = "#{current_text} #{words[i]}"
        end
      end
      #Push the last word in
      result.push(current_text) if i >= words.size - 1}
    #end loop
    return result
  end

end
Test string on how to use it:
'I Forgot Today was the day of the big fair! /n /n I was supposed to go and see Lucca\'s new invention.'

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Vexus

Worked, thanks!

It's neater this way.

Now if the alignment problem gets fixed I'd be very happy :)

+1 to you people for the help.
Current Project/s:

ForeverZer0

June 14, 2012, 07:53:13 pm #19 Last Edit: June 14, 2012, 07:57:06 pm by ForeverZer0
Simply change the value of 260 for the slice width to self.contents.width, and add the space back to the slice method. Having no space kinda defeats the purpose of having such a method.

Also, reduce the text size a bit. A text size of 32 or whatever you had, plus using only half the screen looks bad in my opinion.

EDIT:
Forgot to mention that your demo doesn't even include the multipage type of implementation you had. I thought that's what you wanted fixed?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.