Introduction
If you want a very simple journal, this is the script for you. This script creates a new journal screen for you that contains a list of quests that your character needs to complete. The player can scroll through the list, and that's it. You define your journal entries in the script, and then use switches to turn the entries on and off in your game. Easy!
Create Window_Journal
In this section, we will create the journal and its window.
1. Open your game and script editor.
2. Add a new script called Window_Journal below Window_Menu in your script list.
3. In Window_Journal, add the following code:
CODE
#==============================================================================
# ** Journal
#------------------------------------------------------------------------------
# This window displays a journal.
#==============================================================================
class Window_Journal < Window_Selectable
# ------------------------
def initialize
super(0, 32, 460, 330)
@column_max = 1
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Draw the contents of the item window
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# variables
@journal_height = (2)*32 # y coord of entire journal (# of entries - 1) * 32
@n = 0 # y coord for each entry
@item_max = 0 # max items to dispaly
# draw the bitmap. the text will appear on this bitmap
self.contents = Bitmap.new(width - 32, height+@journal_height)
# populate your journal with entries. Each entry must match its switch number!
@data = []
@data[1] = "Task 1"
@data[2] = "Task 2"
@data[3] = "Task 3"
for i in 1..3
if $game_switches[i] == true
draw_item(i)
@item_max += 1
end
end
end
#--------------------------------------------------------------------------
# * Draw an individual item in the window
# index : Index of the item to be drawn
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = Rect.new(10, @n, 640, 32)
self.contents.fill_rect(rect, Color.new(0,0,0,0))
self.contents.draw_text(10, @n, 640, 32, "●", 0)
self.contents.draw_text(25, @n, 640, 32, item, 0)
@n += 32
end
end
# ** Journal
#------------------------------------------------------------------------------
# This window displays a journal.
#==============================================================================
class Window_Journal < Window_Selectable
# ------------------------
def initialize
super(0, 32, 460, 330)
@column_max = 1
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Draw the contents of the item window
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# variables
@journal_height = (2)*32 # y coord of entire journal (# of entries - 1) * 32
@n = 0 # y coord for each entry
@item_max = 0 # max items to dispaly
# draw the bitmap. the text will appear on this bitmap
self.contents = Bitmap.new(width - 32, height+@journal_height)
# populate your journal with entries. Each entry must match its switch number!
@data = []
@data[1] = "Task 1"
@data[2] = "Task 2"
@data[3] = "Task 3"
for i in 1..3
if $game_switches[i] == true
draw_item(i)
@item_max += 1
end
end
end
#--------------------------------------------------------------------------
# * Draw an individual item in the window
# index : Index of the item to be drawn
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = Rect.new(10, @n, 640, 32)
self.contents.fill_rect(rect, Color.new(0,0,0,0))
self.contents.draw_text(10, @n, 640, 32, "●", 0)
self.contents.draw_text(25, @n, 640, 32, item, 0)
@n += 32
end
end
Create Scene_Journal
In this section, we will create the scene that will contain our journal window. The scene determines where the journal window will appear to users and what happens when keys are pressed.
1. Open your game and script editor.
2. Add a new script called Scene_Journal below Scene_Menu in your script list.
3. In Scene_Journal, add the following code:
CODE
#==============================================================================
# ■ Scene_Status
#------------------------------------------------------------------------------
# This class contains the windows for the character status menu that can be
# accessed from the main menu.
#==============================================================================
class Scene_Journal
#--------------------------------------------------------------------------
# ● Initialize the Status menu
#--------------------------------------------------------------------------
def main
@journal_window = Window_Journal.new
@journal_window.x = 90
@journal_window.y = 70
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@journal_window.dispose
end
#--------------------------------------------------------------------------
# ● Draw the Status menu
#--------------------------------------------------------------------------
def update
@journal_window.update
if @journal_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# ● Update menu after player makes a selection
#--------------------------------------------------------------------------
def update_item
# Cancel key pressed (go to menu)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
return
end
end
end
# ■ Scene_Status
#------------------------------------------------------------------------------
# This class contains the windows for the character status menu that can be
# accessed from the main menu.
#==============================================================================
class Scene_Journal
#--------------------------------------------------------------------------
# ● Initialize the Status menu
#--------------------------------------------------------------------------
def main
@journal_window = Window_Journal.new
@journal_window.x = 90
@journal_window.y = 70
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@journal_window.dispose
end
#--------------------------------------------------------------------------
# ● Draw the Status menu
#--------------------------------------------------------------------------
def update
@journal_window.update
if @journal_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# ● Update menu after player makes a selection
#--------------------------------------------------------------------------
def update_item
# Cancel key pressed (go to menu)
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(5)
return
end
end
end
Update Window_Menu
In this section, we will add Journal to the main menu. It will appear at the bottom of the menu after Quit.
Note: This section assumes that you now have 7 items in your main menu, and the journal is the 7th item.
1. Open the Window_Menu script.
2. Find @item_max and add 1 to it. (@item_max = 7)
3. Find the data[] array, and add an additional item. (@data[7] = "Journal")
4. Below the data[] array, add 1 to the for loop. (for i in 1..7)
Update Scene_Menu
In this section we will add a link to the journal. This scene controls main menu navigation.
Note: This section assumes that you now have 7 items in your main menu, and the journal is the 7th item.
1. Open the Scene_Menu script.
2. Under def update_command, under case @menu_window.index, add the following line (this assumes that you have 7 items in your menu, and this is the 7th item):
CODE
when 6 # Journal selected
$game_system.se_play($data_system.decision_se)
$scene = Scene_Journal.new
$game_system.se_play($data_system.decision_se)
$scene = Scene_Journal.new
Create Journal Entries
Now that you have your Journal set up, you need to add journal entries to it.
1. Go to your Window_Journal script.
2. Find this section:
@data[1] = "Task 1"
@data[2] = "Task 2"
@data[3] = "Task 3"
3. Replace the tasks with your own. For example:
@data[1] = "Find treasure for Jake"
@data[2] = "Get milk for Ma"
@data[3] = "Destroy the world"
Create Journal Switches
Now that your journal entries are added to your journal, turn them on and off with switches.
Note: The number assigned to each data entry needs to match the number assigned to each switch. For example, @data[2] = "Get milk for Ma" | 0002: Help Ma.
1. Add a new event to one of your maps.
2. Open the Event Commands window.
3. Click Control Switches and add the following:
0001: Help Jake
0002: Help Ma
0003: Destroy World
Turn Entries On and Off
To turn entries on and off, simply turn the journal switches on or off in the Event Command window for an event on the map.
How do I add more journal entries?
To add new journal entries, you need to update your list of switches and your list of journal entires in Window_Journal.
1. Open the Window_Journal script and add another entry to the data[] array. (for example, data[4] = "Save the world")
2. In the Window_Journal script, update the journal_height variable. (+1 for each additional journal entry. For example: @journal_height = (3)*32)
3. In the Window_Journal script, update the for loop. (+1 for each additional journal entry. For example: for i in 1..4)
4. Exit the script editor, and open an event on your map. Add a new switch for the journal entry. (for example, 0004: Save World)
I don't want to start with switch 1
If you don't want to start your journal entry with switch 1, simply adjust your for loop in Window_Journal as follows:
Note: The following code assumes that you are starting at switch 100 instead of 1.
for i in 1..3
if $game_switches[i+99] == true
draw_item(i)
@item_max += 1
end
end
