The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on October 04, 2009, 07:53:58 PM

Title: Diary 1.0
Post by: modern algebra on October 04, 2009, 07:53:58 PM
Diary
Version: 1.0
Author: modern algebra
Date: October 4, 2009

Version History



Description


This script allows you to add entries into a diary, much like the system in Baldur's Gate. It allows you to make any number of entries and add them into the journal at any time, and they will be ordered by the playtime you encountered them in. Unlike Baldur's Gate, you can also set pictures in the entries, to appear to the left, right, or center at the top of the entry. Further, you can use a number of special codes in the script to make the entries more interesting.

This script also has built-in capabilities to add itself to the menu, though it may not be compatible with some custom menu systems.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg4.imageshack.us%2Fimg4%2F8586%2Fjuliacompanydiaryscreen.png&hash=97c189e3c21d0392dc9a5b89eda7405509dbc0b2)
A basic book-style journal with multiple entries displayed. The book image is from http://juliacompany.com/images/open-book.jpg

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg39.imageshack.us%2Fimg39%2F7053%2Fshutterstockparchmentdi.png&hash=9144a511f2b71356ab7c41fe9450bbb2cb7a05cf)
But you don't have to use the base image provided, you can also customize how and where text shows up, how many pages are shown at a time, where they are shown, on what background they are shown, and where the label is shown (and if it is rotated) and much more. The layout is entirely customizable!

The parchment image is from Shutterstock (http://www.shutterstock.com/pic-19499140-vintage-grunge-rolled-parchment-illustration-with-ragged-borders-natural-paper-texture.html) (not included because it has to be paid for), but a useful example

Instructions

Place this script in your project's Script Editor (F11) above Main and below all other custom scripts.

See the header and editable regions of the script for detailed instructions on configuration and use.

Script


Note that this script requires the Paragraph Formatter v. 2.0 (http://rmrk.net/index.php/topic,25129.0.html), as well as the Special Codes Formatter that is attached at the bottom of that post. The Formatter has to be Version 2.0 ~ it will not work with earlier versions of the Paragraph Formatter, but the new paragraph formatter will still work with any other scripts you might have that uses an earlier version of the Paragraph Formatter.

Please see the demo (http://rmrk.net/index.php?action=dlattach;topic=35059.0;attach=18059) or attached text document (http://rmrk.net/index.php?action=dlattach;topic=35059.0;attach=18060)

Also, attached is the "Diary Back" image used in the demo. It was taken and edited from http://juliacompany.com/images/open-book.jpg. While that particular graphic is not necessary, you will probably want to find some image to use as a backdrop for the text.

Addons

Spoiler for Multiple Diaries Addon:
While always possible to have multiple diaries in the script, this addon gives an easy way to create and access them for the non-scripter. They are not accessible through the menu, only through events. So you can use items to call them, for instance, or a common event on key press. Detailed instructions are included in the header and the editable region:

Code: [Select]
#==============================================================================
#    Multiple Diaries
#      Addon to Diary 1.0
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: January 17, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This allows for an built-in way to create and access multiple diaries.
#   Unlike the main diary, this is a little simpler as it does not allow for
#   access through the menu or anything fancy, so it has to be called through
#   an event. Entries for these diaries are also set up in the default way
#   through the main script
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script below the main Diary script, but keep it above Main
#
#    To create the new diaries, go down to line 66 and read the instructions
#   located there. Keep in mind what order you creat them, as that is how you
#   will access them. The main diary will always have the ID 0, so each of the
#   new diaries you create will have IDs starting from 1. So, the first one you
#   make has ID 1, the second one ID 2, and so on.
#
#    You can then write entries or call the diaries by using their IDs in these
#   codes, which you put in the call script event command:

#      write_diary_entry (entry_id, diary_id)
#        entry_id : this is an ID of an entry set up in the database, or it
#          could be an entry object itself if you have set one up in an
#          event (which is NOT recommended, btw).
#        diary_id : this is the ID of the diary you want to call. It could also
#          be the diary object itself, if you wanted, but I don't see any
#          reason why that would be easier than the ID. If left blank, it
#          defaults to the main diary that you set up through the main script.
#
#      call_diary (diary_id)
#        diary_id : this is the ID of the diary you want to call. It could also
#          be the diary object itself. If left blank, it defaults to the main
#          diary that you set up through the main script.
#==============================================================================

#==============================================================================
# ** Game System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - diaries
#    aliased method - initialize
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :diaries
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_joy_cokbok_diry_4kw1 initialize
  def initialize (*args)
    # Run Original Method
    ma_joy_cokbok_diry_4kw1 (*args)
    @diaries = [@diary]
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  EDITABLE REGION
    #``````````````````````````````````````````````````````````````````````````
    # Make new diaries Like this:
    #    name = "name of diary"
    #    font_name = "name of font" OR ["font_1", "font_2", ..., "font_n"]
    #    back_pic = "name of Background Image
    #    page_rects = [Rect.new (x, y, w, h), Rect.new (x, y, w, )]
    #      w, h : width, height
    #    num_rects = [[Rect.new (x, y, w, h), align], [Rect.new (x, y, w, h), align]]
    #      align : 0 => Left, 1 => Middle, 2 => Right
    #
    #  You must define all of the following, and then you can make it:
    #    @diaries.push (Diary.new (name, font_name, back_pic, page_rects, num_rects))
    #
    #  I should note, if you do not define arguments, then they resorts to
    #  the default setting you've set up. However, you can't "skip" arguments.
    #  If you want back_pic to be default but want to change page_rects, then
    #  you will need to define back_pic anyway. However, if you wanted back_pic,
    #  page_rects, and num_rects all to be default, then you would only need to
    #  define name and font_name and create it like this:
    #    @diaries.push (Game_Diary.new (name, font_name))
    name = "Cookbook"
    @diaries.push (Game_Diary.new (name))
    #``````````````````````````````````````````````````````````````````````````
    #  END EDITABLE REGION
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - call_diary, write_diary_entry
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Write Diary Entry
  #    entry : either an Game_DiaryEntry object or an entry ID
  #    diary : the Game_Diary object to write it to
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_mult_diry_writeentry_6hf2 write_diary_entry
  def write_diary_entry (entry, diary = $game_system.diary, *args)
    diary = $game_system.diaries[diary] if diary.is_a? (Integer)
    ma_mult_diry_writeentry_6hf2 (entry, diary, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Diary
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mjoy_clldiry_multiples_8kd2 call_diary
  def call_diary (diary = $game_system.diary, *args)
    diary = $game_system.diaries[diary] if diary.is_a? (Integer)
    mjoy_clldiry_multiples_8kd2 (diary, *args)
  end
end

Credit



Support


Please post in this topic at RMRK for swiftest response. I will fix any bugs that may arise.

Known Compatibility Issues

Likely will not work with some Custom Menu Systems.

Spoiler for YEM Menu:
First, put all of the Diary scripts above YEM Menu in the Script Editor.

Next, paste this code somewhere below the YEM Menu script in the editor, but still above Main:
Code: [Select]
if Data_DiaryEntries::MENU_ACCESS
 
YEM::MENU::MENU_COMMANDS.insert (Data_DiaryEntries::MENU_INDEX, :diary)
YEM::MENU::MENU_ICONS[:diary] = 178
YEM::MENU::IMPORTED_COMMANDS[:diary] = [nil, nil, false, 178, Data_DiaryEntries::VOCAB_DIARY_LABEL, "Scene_Diary"]

class Scene_Diary
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (diary = $game_system.diary, from_menu = true)
    @diary = diary
    @from_menu = from_menu
  end
end

end

You can change the 178 in this:

Code: [Select]
YEM::MENU::MENU_ICONS[:diary] = 178

to whatever icon you want to use for YEM

Now, the only problem with this patch is that if you use MAP_ACCESS in the diary script, then when you leave the diary you go to the Menu instead of back to the map. To fix that, you can go to around line 648 of the diary script and change:
Code: [Select]
          $scene = Scene_Diary.new ($game_system.diary)

to:

Code: [Select]
          $scene = Scene_Diary.new ($game_system.diary, false)

Demo


Note that this script requires the Paragraph Formatter v. 2.0 (http://rmrk.net/index.php/topic,25129.0.html), as well as the Special Codes Formatter that is attached at the bottom of that post. Note that the Formatter has to be Version 2.0 ~ it will not work with earlier versions of the Paragraph Formatter, but the new paragraph formatter will still work with any other scripts you might have that uses an earlier version of the Paragraph Formatter.

Both are included in the attached demo (http://rmrk.net/index.php?action=dlattach;topic=35059.0;attach=18059)


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Diary 1.0
Post by: Cascading Dragon on October 04, 2009, 08:05:17 PM
Very nice script. Good job
Title: Re: Diary 1.0
Post by: modern algebra on October 05, 2009, 07:15:09 PM
Thanks, I'm glad you like it redyugi
Title: Re: Diary 1.0
Post by: Cascading Dragon on October 05, 2009, 08:42:22 PM
Well its a more "personal" version of a quest script. Now it sorta takes the player inside the mind of one of your characters.
Title: Re: Diary 1.0
Post by: joy on October 13, 2009, 02:28:02 AM
Hey mod, I have a question.

I see you mention multiple diaries in the instructions, how would one go about doing that? Like say, having a Diary in the traditional sense, but also having a separate notebook with things like recipes and whatnot.
Title: Re: Diary 1.0
Post by: modern algebra on October 13, 2009, 11:25:55 AM
Essentially, all that would need to be done is to create a new Game_Diary object and then save it somewhere. All of the codes can take a diary argument - when none is specified it assumes a default diary. So, you would need to put the diary in as an argument when you use the "call_diary (diary)" code. Otherwise it would call the system diary. When you were adding entries, it would need to be "write_diary_entry (entry_id, diary)".

In any case, you would first need to make a diary to call. You could make this in a game variable if you wanted, but it would be better to make it in one of the Game classes. Either way, to make it, you would need to use the code:

Code: [Select]
xx = Game_Diary.new (name, font_name, back_pic, page_rects, num_rects)

Each of those default to the values specified in constants if you do not specify a value. Ex:

Code: [Select]
$game_variables[1] = Game_Diary.new ("Cookbook")

So, in that case, Variable 1 would hold the diary and obivously could not be used in any normal variable operations. It would be the same as a regular diary except it's name would be Cookbook.

To call it, you would need to use the code:
Code: [Select]
call_diary ($game_variables[1])
. To write an entry you would need the code:
Code: [Select]
write_diary_entry (entry_id, $game_variables[1])

You would create the entries as you normally would in the editor, but just only use cookbook entries in the cookbook and not in the regular Diary.

Now, if you wanted to add it to the menu, it would be more trouble.

As you can see, it's fairly complicated. If you specify exactly how you want the recipe book to be available and what graphics you want to use then I can make an addon to the script that does all that if you want me to.
Title: Re: Diary 1.0
Post by: joy on October 13, 2009, 11:50:51 AM
:O

That would be amazing, man. I was just planning on using the same graphic system really, just organize the post differently. As for calling it, since I don't anticipate the player needing it all the time I was just gonna tie it to an item with a common event.

You need a cameo in this game...
Title: Re: Diary 1.0
Post by: Emanzi on December 23, 2009, 01:11:32 AM
write_diary_entry (entry_id[, diary])

I used that in the call script function under advanced, script... but when I run it it says syntax error. What do I do, I also tried specifying the enty id like write_diary_entry (entry_1[, diary]) but the same error came up! Please Help. Im I using the command wrongly? I dont know whats wrong.  ???
Title: Re: Diary 1.0
Post by: modern algebra on December 23, 2009, 02:03:51 AM
Don't use the square brackets, and only put the ID. The square brackets just mean that that argument can be excluded unless you have more than one diary. So, to do it properly, do:

write_diary_entry (1)
Title: Re: Diary 1.0
Post by: modern algebra on January 17, 2010, 02:15:06 PM
Wow, joy - I'm really bad at doing thing I say I'll do :P

Anyway, I just realized I hadn't done what you asked of me when I visited this topic for another reason, so I figured I'd do it up quickly - these diaries won't show up in the menu, so you have to use events to call them, but I figured that'd be OK. The instructions are inside, but if there's anything you don't know how to do just tell me and I'll clarify or fix it.


Spoiler for Multiple Diaries Addon:
Code: [Select]
#==============================================================================
#    Multiple Diaries
#      Addon to Diary 1.0
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: January 17, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This allows for an built-in way to create and access multiple diaries.
#   Unlike the main diary, this is a little simpler as it does not allow for
#   access through the menu or anything fancy, so it has to be called through
#   an event. Entries for these diaries are also set up in the default way
#   through the main script
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script below the main Diary script, but keep it above Main
#
#    To create the new diaries, go down to line 66 and read the instructions
#   located there. Keep in mind what order you creat them, as that is how you
#   will access them. The main diary will always have the ID 0, so each of the
#   new diaries you create will have IDs starting from 1. So, the first one you
#   make has ID 1, the second one ID 2, and so on.
#
#    You can then write entries or call the diaries by using their IDs in these
#   codes, which you put in the call script event command:

#      write_diary_entry (entry_id, diary_id)
#        entry_id : this is an ID of an entry set up in the database, or it
#          could be an entry object itself if you have set one up in an
#          event (which is NOT recommended, btw).
#        diary_id : this is the ID of the diary you want to call. It could also
#          be the diary object itself, if you wanted, but I don't see any
#          reason why that would be easier than the ID. If left blank, it
#          defaults to the main diary that you set up through the main script.
#
#      call_diary (diary_id)
#        diary_id : this is the ID of the diary you want to call. It could also
#          be the diary object itself. If left blank, it defaults to the main
#          diary that you set up through the main script.
#==============================================================================

#==============================================================================
# ** Game System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - diaries
#    aliased method - initialize
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :diaries
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_joy_cokbok_diry_4kw1 initialize
  def initialize (*args)
    # Run Original Method
    ma_joy_cokbok_diry_4kw1 (*args)
    @diaries = [@diary]
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  EDITABLE REGION
    #``````````````````````````````````````````````````````````````````````````
    # Make new diaries Like this:
    #    name = "name of diary"
    #    font_name = "name of font" OR ["font_1", "font_2", ..., "font_n"]
    #    back_pic = "name of Background Image
    #    page_rects = [Rect.new (x, y, w, h), Rect.new (x, y, w, )]
    #      w, h : width, height
    #    num_rects = [[Rect.new (x, y, w, h), align], [Rect.new (x, y, w, h), align]]
    #      align : 0 => Left, 1 => Middle, 2 => Right
    #
    #  You must define all of the following, and then you can make it:
    #    @diaries.push (Diary.new (name, font_name, back_pic, page_rects, num_rects))
    #
    #  I should note, if you do not define arguments, then they resorts to
    #  the default setting you've set up. However, you can't "skip" arguments.
    #  If you want back_pic to be default but want to change page_rects, then
    #  you will need to define back_pic anyway. However, if you wanted back_pic,
    #  page_rects, and num_rects all to be default, then you would only need to
    #  define name and font_name and create it like this:
    #    @diaries.push (Diary.new (name, font_name))
    name = "Cookbook"
    @diaries.push (Diary.new (name))
    #``````````````````````````````````````````````````````````````````````````
    #  END EDITABLE REGION
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - call_diary, write_diary_entry
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Write Diary Entry
  #    entry : either an Game_DiaryEntry object or an entry ID
  #    diary : the Game_Diary object to write it to
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_mult_diry_writeentry_6hf2 write_diary_entry
  def write_diary_entry (entry, diary = $game_system.diary, *args)
    diary = $game_system.diaries[diary] if diary.is_a? (Integer)
    ma_mult_diry_writeentry_6hf2 (entry, diary, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Diary
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mjoy_clldiry_multiples_8kd2 call_diary
  def call_diary (diary = $game_system.diary, *args)
    diary = $game_system.diaries[diary] if diary.is_a? (Integer)
    mjoy_clldiry_multiples_8kd2 (diary, *args)
  end
end
Title: Re: Diary 1.0
Post by: skaraflame on February 07, 2010, 10:10:37 PM
The script doesnt even work
It came up with some error, why do no ellaborate scripts work for me?
Title: Re: Diary 1.0
Post by: modern algebra on February 07, 2010, 11:04:31 PM
I don't know - it works for me. Did you make sure to follow the instructions and copy the paragraph formatter into your project? What other scripts are you using? Does the demo work for you? What does the error message say?
Title: Re: Diary 1.0
Post by: skaraflame on February 08, 2010, 05:22:26 PM
I don't know - it works for me. Did you make sure to follow the instructions and copy the paragraph formatter into your project? What other scripts are you using? Does the demo work for you? What does the error message say?
Where can I find it?
None
yeah....
cause I deleted the script so I dont know
Title: Re: Diary 1.0
Post by: modern algebra on February 08, 2010, 07:51:40 PM
The best place is just to take it straight from the demo as that has all the parts you need, or you could take it from: Paragraph Formatter v. 2.0 (http://rmrk.net/index.php/topic,25129.0.html) - you need the Special Codes formatter too.
Title: Re: Diary 1.0
Post by: skaraflame on February 08, 2010, 10:35:24 PM
The best place is just to take it straight from the demo as that has all the parts you need, or you could take it from: Paragraph Formatter v. 2.0 (http://rmrk.net/index.php/topic,25129.0.html) - you need the Special Codes formatter too.
aaargh too much stuff XD
Title: Re: Diary 1.0
Post by: lplegacy on May 17, 2010, 03:05:13 AM
Gahh, I'm too simple-minded for this scripting stuff. Could you tell me in more detail how to make more than one diary, because I have a feeling I'm doing something wrong because when ever I try to make one, I mess up  :(
Title: Re: Diary 1.0
Post by: modern algebra on May 17, 2010, 02:17:40 PM
I don't really know how to explain it any better than I do at line 66 of the Addon, so maybe some examples would help:

Code: [Select]
name = "Recipe Book"
font_name = ["Times New Roman", "Arial"]
back_pic = "Cookbook_Back"
page_rects = [Rect.new (20, 20, 200, 360), Rect.new (260, 20, 200, 360)]
num_rects = [[Rect.new (110, 384, 20, 24), 1], [Rect.new (350, 384, 20, 24), 1]]
@diaries.push (Game_Diary.new (name, font_name, back_pic, page_rects, num_rects))
name = "Ulrika's Diary"
@diaries.push (Game_Diary.new (name))

That code would create two diaries.

The first would be named Recipe Book, it would use Times New Roman as its font, or Arial if Times New Roman isn't installed on the player's computer. It uses an image called Cookbook_Back located in the Pictures folder as the background. It draws two pages, both 200x360 that are located at 20x20 and 260x20 respectively. The page numbers are shown at the bottom of the center of each page. It would be accessed by the ID 1.

The second diary would be named Ulrika's Diary, and it would have the default font, picture, and pages since those aren't set. It would be accessed by the ID 2.

You could write entries to those diaries using call script, like so:

Code: [Select]
write_diary_entry (entry, diary_id)

where entry is either a Game_DiaryEntry object or an ID of one of the entries you set up in the database. diary_id is the Id of the diary you want to write to. 0 is the default diary and it will default to that if you don't put in diary_id at all. 1 would refer to "Recipe Book", and 2 would refer to "Ulrika's Diary"

You can open these diaries with the call script:

Code: [Select]
call_diary (diary_id)

where diary_id is the same as above.
Title: Re: Diary 1.0
Post by: user3k on May 25, 2010, 11:49:36 PM
Thanks Modern Algebra, this script is awesome. The script always open showing the last page when you close the diary, there's a way to make they show always the last (reverse order) page? If not, the way they work it's ok.
Title: Re: Diary 1.0
Post by: modern algebra on May 26, 2010, 12:14:02 AM
I don't know what you're asking for. It already opens to the start of the last entry immediately after it is added. After that, if you open the diary, it opens to the last page you were on. So, you want it to open at the first entry? Or do you mean you want it so that the player can't turn the pages? Or do you mean that you want it to open to the latest entry even if it wasn't just added, and not to the page it was last closed on?
Title: Re: Diary 1.0
Post by: user3k on May 26, 2010, 01:08:36 AM
"Or do you mean that you want it to open to the latest entry even if it wasn't just added"
This way.
Title: Re: Diary 1.0
Post by: user3k on May 27, 2010, 01:08:33 AM
Somebody had luck making this script work with yanfly custom menu? I'm testing with YEM Main Menu Melody, and they don't work - Script Diary  line 855: Argument error ocurred. wrong number of arguments (2 for 1)
Title: Re: Diary 1.0
Post by: modern algebra on May 27, 2010, 08:38:58 PM
Yeah, well they aren't hard to make compatible. Yanfly changes how many arguments are expected in the command window, which is why that error occurs. But they aren't hard to make compatible. First, put all of the Diary scripts above YEM Menu in the Script Editor.

Next, paste this code somewhere below the YEM Menu script in the editor, but still above Main:
Code: [Select]
if Data_DiaryEntries::MENU_ACCESS
 
YEM::MENU::MENU_COMMANDS.insert (Data_DiaryEntries::MENU_INDEX, :diary)
YEM::MENU::MENU_ICONS[:diary] = 178
YEM::MENU::IMPORTED_COMMANDS[:diary] = [nil, nil, false, 178, Data_DiaryEntries::VOCAB_DIARY_LABEL, "Scene_Diary"]

class Scene_Diary
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (diary = $game_system.diary, from_menu = true)
    @diary = diary
    @from_menu = from_menu
  end
end

end

You can change the 178 in this:

Code: [Select]
YEM::MENU::MENU_ICONS[:diary] = 178

to whatever icon you want to use for YEM

Now, the only problem with this patch is that if you use MAP_ACCESS in the diary script, then when you leave the diary you go to the Menu instead of back to the map. To fix that, you can go to around line 648 of the diary script and change:
Code: [Select]
          $scene = Scene_Diary.new ($game_system.diary)

to:

Code: [Select]
          $scene = Scene_Diary.new ($game_system.diary, false)
Title: Re: Diary 1.0
Post by: user3k on May 27, 2010, 11:54:22 PM
Thanks, it works!
Title: Re: Diary 1.0
Post by: Eruvis on June 10, 2010, 04:21:13 AM
this looks fun. its been a while since ive been on here but MA scripts are pretty intuitive even for a complete programming newbie like me. so heres my question, when i read diary i almost felt like it would let the player type up an entry, is that possible? i looked into the script editor and see the text is already pre-typed in there and while it is awesomely useful, there may be a way to let the player enter something of their own maybe?
Title: Re: Diary 1.0
Post by: modern algebra on June 10, 2010, 12:18:09 PM
Well, I'd basically have to write a word processor to do that. Maybe I will in the future, but definitely not right now.
Title: Re: Diary 1.0
Post by: naizehcnas on September 10, 2010, 07:47:50 AM
i have a problem in your script. it is found here:
http://rmrk.net/index.php/topic,40130.msg462087.html#new (http://rmrk.net/index.php/topic,40130.msg462087.html#new)
Title: Re: Diary 1.0
Post by: modern algebra on September 10, 2010, 11:25:46 AM
Try switching the order of the scripts in the Script Editor.

Otherwise, try making it so that the Journal option is above the Continue option. If both of those don't work, I'll take a look at the scripts and make them compatible.
Title: Re: Diary 1.0
Post by: The Frontera on September 10, 2010, 02:23:58 PM
Woah, that's really cool !
I will absolutely use it in my new game !
modern algebra you rock ! Your scripts are some of the best I ever seen !
Title: Re: Diary 1.0
Post by: Linkx7 on September 18, 2010, 06:35:54 AM
Help i got error on diary on line 763 "Paragraher" :'(
Title: Re: Diary 1.0
Post by: modern algebra on September 18, 2010, 01:10:32 PM
Did you add the Paragraph Formatter and Special Codes Formatter as is required? You can get both from the demo.
Title: Re: Diary 1.0
Post by: furryfisk on March 04, 2011, 01:04:42 AM
Hello, I got an error with
line 667: NoMethodError occured
undefined method 'back_picture' for nil"NilClass

i have the pictures from the demo, the formatters, im not using a special menu script and i copied correctly.
Title: Re: Diary 1.0
Post by: modern algebra on March 04, 2011, 01:38:08 AM
My best guess is that you are loading from a save file that existed from before you added the diary script. You can't do that - you need to delete the old save files and start again.
Title: Re: Diary 1.0
Post by: Mapper2100 on April 17, 2011, 07:40:13 PM
Hey,

Im using a mouse script, and I was wondering if it was possible to have like an arrow or something here taht you could click to turn the page as well as using the arrow keys.

thanks

Matt (Mapper2100)
Title: Re: Diary 1.0
Post by: fenicearcana on September 21, 2011, 09:27:37 AM
Modern, this Script is very very very usefoul to people like me that tend to do big stories with a lot of talk XD but i have a question. I dont see anywhere in the script, the chance to change the font size...is it possible? Becouse the font is very big, i need a smaller one. can it be done somehow?
Thanks for your time ^^
Title: Re: Diary 1.0
Post by: fenicearcana on September 22, 2011, 01:17:42 AM
Modern, i use Yem and many other script and your Diary 1.0 work fine.
But i'm Italian so it taked to me around 2 hours to figure out how to set the 2nd diary [a cookbook] and call it. So if you dont mind, i will post here the complete code for those who, like me, had same problem to set the diary cause they didnt get well with english or script. Hope to be of help to other newbie like me. Your work is awesome as alwais Modern! The code, is set like this:

Quote
#==============================================================================
#    Multiple Diaries
#      Addon to Diary 1.0
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: January 17, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This allows for an built-in way to create and access multiple diaries.
#   Unlike the main diary, this is a little simpler as it does not allow for
#   access through the menu or anything fancy, so it has to be called through
#   an event. Entries for these diaries are also set up in the default way
#   through the main script
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script below the main Diary script, but keep it above Main
#
#    To create the new diaries, go down to line 66 and read the instructions
#   located there. Keep in mind what order you creat them, as that is how you
#   will access them. The main diary will always have the ID 0, so each of the
#   new diaries you create will have IDs starting from 1. So, the first one you
#   make has ID 1, the second one ID 2, and so on.
#
#    You can then write entries or call the diaries by using their IDs in these
#   codes, which you put in the call script event command:

#      write_diary_entry (entry_id, diary_id)
#        entry_id : this is an ID of an entry set up in the database, or it
#          could be an entry object itself if you have set one up in an
#          event (which is NOT recommended, btw).
#        diary_id : this is the ID of the diary you want to call. It could also
#          be the diary object itself, if you wanted, but I don't see any
#          reason why that would be easier than the ID. If left blank, it
#          defaults to the main diary that you set up through the main script.
#
#      call_diary (diary_id)
#        diary_id : this is the ID of the diary you want to call. It could also
#          be the diary object itself. If left blank, it defaults to the main
#          diary that you set up through the main script.
#==============================================================================

#==============================================================================
# ** Game System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - diaries
#    aliased method - initialize
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :diaries
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_joy_cokbok_diry_4kw1 initialize
  def initialize (*args)
    # Run Original Method
    ma_joy_cokbok_diry_4kw1 (*args)
    @diaries = [@diary]
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #  EDITABLE REGION
    #``````````````````````````````````````````````````````````````````````````
    # Make new diaries Like this:
    #    name = "name of diary"
    #    font_name = "name of font" OR ["font_1", "font_2", ..., "font_n"]
    #    back_pic = "name of Background Image
    #    page_rects = [Rect.new (x, y, w, h), Rect.new (x, y, w, )]
    #      w, h : width, height
    #    num_rects = [[Rect.new (x, y, w, h), align], [Rect.new (x, y, w, h), align]]
    #      align : 0 => Left, 1 => Middle, 2 => Right
    #
    #  You must define all of the following, and then you can make it:
    #    @diaries.push (Diary.new (name, font_name, back_pic, page_rects, num_rects))
    #
    #  I should note, if you do not define arguments, then they resorts to
    #  the default setting you've set up. However, you can't "skip" arguments.
    #  If you want back_pic to be default but want to change page_rects, then
    #  you will need to define back_pic anyway. However, if you wanted back_pic,
    #  page_rects, and num_rects all to be default, then you would only need to
    #  define name and font_name and create it like this:
    #    @diaries.push (Diary.new (name, font_name))
name = "Ricettario"
font_name = ["Garamond", "Verdana", "Arial"]
back_pic = "Diary Back"
page_rects = [Rect.new (20, 20, 200, 360), Rect.new (260, 20, 200, 360)]
num_rects = [[Rect.new (110, 384, 20, 24), 1], [Rect.new (350, 384, 20, 24), 1]]
@diaries.push (Game_Diary.new (name, font_name, back_pic, page_rects, num_rects))

    #``````````````````````````````````````````````````````````````````````````
    #  END EDITABLE REGION
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - call_diary, write_diary_entry
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Write Diary Entry
  #    entry : either an Game_DiaryEntry object or an entry ID
  #    diary : the Game_Diary object to write it to
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_mult_diry_writeentry_6hf2 write_diary_entry
  def write_diary_entry (entry, diary = $game_system.diary, *args)
    diary = $game_system.diaries[diary] if diary.is_a? (Integer)
    ma_mult_diry_writeentry_6hf2 (entry, diary, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Diary
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mjoy_clldiry_multiples_8kd2 call_diary
  def call_diary (diary = $game_system.diary, *args)
    diary = $game_system.diaries[diary] if diary.is_a? (Integer)
    mjoy_clldiry_multiples_8kd2 (diary, *args)
  end
end

and to call the 2nd Diary, you just need to create one Item, give it to the player and ser his use "only from the menĂ¹", no consume.
it must call a "common event" and in the common event you need just the
"Script" command, the last in the 3rd page, below "advanced"
and put there, this:

Quote
call_diary (1)

for the entryies you simpli use the first script, the Diary 1.0 and if you will like to have an ordered list, use the entryes from 1 to 100 [just to say] for the diary, and the entryes from 101 to 200 for the coockbook.

To add other diarys, just add another time the first quote and change name and picture and to make the call of other diaries you will make another item same as the first but the call will be...

Quote
call_diary (2)

then call 3..4...5 as many as you want. easy to configure.
Our problem was just to figure out where we need to edit eheh
my first time i messed up all because i misunderstand this line
@diaries.push (Game_Diary.new (name, font_name, back_pic, page_rects, num_rects))
i used it like this:
@diaries.push (Game_Diary.new (cookbook, font_name, back_pic, page_rects, num_rects))
Fon non-scripter like me is easy make those kind of mistake...but i read your comments many time, doing some change and at least figured out how to configure properly.
Now it work perfect! And i'm starting making my event-cooking part of the game heheh "sweeet"
Thanks a lot Algebra. More the tima passes, more i think you are truly blessed with genius.

I just remind you about my question, if you dont mind.
I will like to change font to a smaller size if can be done.
For now, i'm simply avoiding the problem using "Garamond" Font that is smaller than Verdana or the others, but if there is a way to change the font-size, i will like to know ^^

Thanks for your time, sorry for my talkative habits...i hope this post will be of some help ^^
Title: Re: Diary 1.0
Post by: nemrog on December 31, 2011, 04:26:22 PM
I'm using your Addon, but I get the following:

Quote
Script 'Diary_Addon' line 88: Name Error Occured.
Uninitialized Constant Game_System::Diary.

I get that when I try Loading the Game up.
Title: Re: Diary 1.0
Post by: modern algebra on January 01, 2012, 10:58:45 PM
Well, the Addon requires the original script to work.
Title: Re: Diary 1.0
Post by: nemrog on January 03, 2012, 01:52:33 AM
i have the Demo, and I added onto the Demo under the original Program. Which is why I'm confused on to that error message.
Title: Re: Diary 1.0
Post by: modern algebra on January 03, 2012, 02:08:38 AM
Oh, I took a look and there was an error in the addon. Grab it again and see if it's any better.
Title: Re: Diary 1.0
Post by: nemrog on January 05, 2012, 04:11:58 AM
Nope. It's now saying that Game_Interpreter::Cookbook is an Uninitialized Constant.

Can you plug it into a Demo so I can see it in a Working Model please? Thank you very much for your time.
Title: Re: Diary 1.0
Post by: Darkxyn on January 06, 2012, 10:13:10 AM
I can't download the demo, the link doesn't seem to work
Nevermind, It does work but downloads the demo as "index.php", i have to rename it as .exe to make it work... Dunno if it's just a downloading problem of mine or it's like that for everybody else.