Jump to content
New account registrations are disabed. This website is now an archive. Read more here.

Recommended Posts

Diary

Authors: ForeverZer0

Version: 1.1

Type: Misc Add-on


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.


Screenshots

 

 

Diary1.png

 


Demo

 

None.


Script

 

Here's the script.

 

#+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
# 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 = true
 # 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(0, 64, 640, 416)
   self.back_opacity = Diary::MAP_BACKGROUND ? 160 : 255
   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, 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])}
 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
   # Create the windows.
   @sprites = [Window_Help.new, Window_Diary.new]
   if Diary::MAP_BACKGROUND
     @sprites.push(Spriteset_Map.new)
     @sprites[0].back_opacity = 160
   end
   @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.
   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

 


Instructions

 

Place script below default scripts, and above "Main".

Instructions are in the script.


Compatibility

 

No known issues.


Credits and Thanks

 

  • ForeverZer0, for the script.
  • Blizzard, for the "slice_text" method I always steal.
  • Lauros, for requesting it.


Author's Notes

 

Please report any bugs/issues/suggestions. I will be happy to fix them.

Enjoy!

Share this post


Link to post
Share on other sites

Hello!

This is a great script! :D
However, I need a "Chapter Selection". Are distributed the way the Notes and inserted into the "Diary", I like really super! So i can arrange everything perfectly, yet it comes in the order the book, in which the player experiences the story.
But! Let's say you have 10 or 20 chapters.
Then the player is forced each time to switch to "Q" through all the chapters. I find that ugly. Could you give me a "chapter-preselection" interpose? So you open the Diary and does not come to chapter 1 and then must continue to turn until it is only on one side, on which the chapter is lined up and you can choose in which you want to read.

In addition, I think it would be nice if the Minni bug would be fixed that the first headline is far left and then at the next turn in the middle.
If the headlines appeared only in the middle, I think it would be pretty :3

 

 

Thank you very much for this script! :D

 

 

(Oh god, this broken englisch D: Sorry... This is, what the google translator shows.)

Edited by Josey Hikari

Share this post


Link to post
Share on other sites

Playm from rpg-studio.org has fixed the bug:

He says:

There is missing only the align parameter in set_text - add in line 186 even a " , 1":
 

# Set the information for each window.
@sprites[0].set_text(@names[@index] == nil ? '' : @names[@index] , 1)

 

It works :)

Edited by Josey Hikari

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...