RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Conversion Request] Notebook Menu VX to Ace (Willing to pay $15 paypal)

0 Members and 3 Guests are viewing this topic.

**
Rep:
Level 74
RMRK Junior - - Cute Pegasus Pony

Script : Notebook Menu By Jet10985 (Jet) (Damn useful, don't know what I'd do without it) I really need this done as soon as possible. I am willing to pay $15 out of my paypal account to have someone do this soon.

Spoiler for:
Code: [Select]
#===============================================================================
# Notebook Menu
# By Jet10985 (Jet)
#===============================================================================
# This script will add a Notebook menu to the game, which can be used to add
# entries to the notebook that the player can read.
# This script has: 6 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Scene_Title: initialize
#===============================================================================
=begin
To use this script, you need to have a folder in your game directory called
Notebook
This is where your .txt files should be located.
This script runs solely on the .txt files in the folder, and it's where it
grabs the files for the .rvdata conversion if used.
--------------------------------------------------------------------------------
To add new entries to the journal, use this in an event "Script..." command
add_entry("filename")
"filename" should be the name of a .txt file in the Notebook folder, excluding
the .txt. So say i have a file called Test.txt: add_entry("Test")
Even if you use the .rvdata file, the filenames stay the same so make sure
you remember your filenames.
--------------------------------------------------------------------------------
You can call the journal scene with this code in an event "Script..." command:
$scene = Scene_Notebook.new
The journal scene will be inaccessable unless the player has at least 1 entry
--------------------------------------------------------------------------------
If the text entry is too long height-wise to be shown completely, then the
player needs to use (left) to scroll up, or (right) to scroll down.
--------------------------------------------------------------------------------
To force a next line in the text, put \line inside the .txt file where you
want to force text to the next line
=end
module Notebook

  # Would you like to convert all .txt files in the "Notebook" folder to a
  # .rvdata data file which can be encrpyted with the game, and used with
  # the USE_RVDATA_FILE option?
  DO_CONVERSION_TO_RVDATA = false

  # Would you like to use the Notebook.rvdata file generated with the
  # DO_CONVERSION_TO_RVDATA instead of the .txt files in the "Notebook" folder?
  USE_RVDATA_FILE = false

  # What is the notebook called?
  NOTEBOOK_NAME = "Notebook"

  # What font does the notebook use? The first item is the primary font you
  # want, and it will go through each item if the font doesn't exist
  # until it finds a font that does exist.
  NOTEBOOK_FONT = ["Verdana", "Arial", "Courier New"]

  # What is the font size in the notebook? 20 is default
  NOTEBOOK_FONT_SIZE = 20

  # How much space will be given for each line? 24 is default
  NOTEBOOK_WLH = 24

end
#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Game_System

  attr_accessor :notebook_entries

  alias jet1835_initialize initialize unless $@
  def initialize(*args, &block)
    @notebook_entries = []
    jet1835_initialize(*args, &block)
  end
end
class Game_Interpreter

  def add_entry(filename)
    unless $game_system.notebook_entries.include?(filename)
      $game_system.notebook_entries.push(filename)
    end
  end
end
class Scene_Title

  alias jet1934_initialize initialize unless $@
  def initialize(*args, &block)
    convert_txt if Notebook::DO_CONVERSION_TO_RVDATA && $TEST
    jet1934_initialize(*args, &block)
  end

  def convert_txt
    file = Dir.entries("Notebook")
    file.reverse!
    2.times {|i| file.pop }
    file.reverse!
    if file.empty?
      p "No files found in Notebook, aborting conversion process."
    end
    text_hash = {}
    for txt in file
      text_hash[txt] = File.open("Notebook/#{txt}", "r") {|a| a.read}
    end
    b = File.new("Data/Notebook.rvdata", "wb")
    Marshal.dump(text_hash, b)
    b.close
    p "Notebook file successfully converted."
  end
end
class String

  def each_word
    array = self.split(" ")
    if block_given?
      array.each {|a| yield a }
    else
      return array
    end
  end
end
class Window_Notebook < Window_Base

  include Notebook

  def initialize(filename)
    super(160, 56, Graphics.width - 160, Graphics.height - 56)
    @filename = filename
    refresh(@filename)
  end

  def refresh(filename)
    self.oy = 0
    form_bitmap_rect(filename)
    self.contents.font.name = NOTEBOOK_FONT
    self.contents.font.size = NOTEBOOK_FONT_SIZE
    wlh = NOTEBOOK_WLH
    i = 0
    @file_text.each_line {|line|
      text = line.gsub(/\r|\n/i, "")
      self.contents.draw_text(0, 0 + i * wlh, self.width - 32, wlh, text)
      i += 1
    }
  end

  def form_bitmap_rect(filename)
    if USE_RVDATA_FILE
      file = load_data("Data/Notebook.rvdata")[filename + ".txt"]
    else
      file = File.open("Notebook/#{filename}.txt", "r") {|a| a.read }
    end
    new_text = ""
    width_taken = 0
    height_taken = 0
    file.gsub!(/\r\n/i, " ")
    file.gsub!(/\\line/i, " \\xjet ")
    file.each_word {|word|
      width_taken += self.contents.text_size("#{word} ").width
      if word == "\\xjet"
        width_taken = 0
        new_text.concat("\n")
        height_taken += NOTEBOOK_WLH
      elsif width_taken > self.width - 32
        width_taken = 0
        new_text.concat("\n#{word} ")
        width_taken += self.contents.text_size("#{word} ").width
        height_taken += NOTEBOOK_WLH
      else
        new_text.concat("#{word} ")
      end
    }
    @file_text = new_text
    @height_taken = height_taken
    self.contents = Bitmap.new(self.width - 32, @height_taken + 32)
  end
end
class Window_Entries < Window_Base
  def initialize(x, y)
    super(x, y, 160, WLH + 32)
    refresh
  end
  def refresh
    contents.clear
    contents.font.color = system_color
    contents.draw_text(0, 0, 100, 24, "Entries:")
    contents.font.color = normal_color
    contents.draw_text(104, 0, 40, 24, $game_system.notebook_entries.size, 1)
  end
end

class Scene_Notebook < Scene_Base

  def initialize
    @return_scene = $scene.class.to_s
    @return = false
  end

  def start
    if $game_system.notebook_entries.empty?
      $scene = eval(@return_scene + ".new")
      @return = true
      return
    end
    super
    create_menu_background
    @help_window = Window_Help.new
    @help_window.set_text(Notebook::NOTEBOOK_NAME, 1)
    @notebook_window = Window_Notebook.new($game_system.notebook_entries[0])
    @entries_window = Window_Entries.new(0, Graphics.height - 54)
    @command_window = Window_Command.new(160, $game_system.notebook_entries)
    @command_window.height = Graphics.height - 110
    @command_window.y += 56
  end

  def update
    return if @return
    super
    update_menu_background
    old_index = @command_window.index
    @command_window.update
    if old_index != @command_window.index
      @notebook_window.refresh(@command_window.commands[@command_window.index])
    end
    @notebook_window.update
    if Input.trigger?(Input::B)
      return_scene
    end
    if @notebook_window.contents.height > @notebook_window.height - 32
      wlh = Notebook::NOTEBOOK_WLH
      if Input.trigger?(Input::RIGHT)
        @notebook_window.oy = [@notebook_window.oy + wlh,
          @notebook_window.contents.height - @notebook_window.height + 32].min
      elsif Input.trigger?(Input::LEFT)
        @notebook_window.oy = [@notebook_window.oy - wlh,
          0].max
      end
    end
  end

  def return_scene
    $scene = Scene_Menu.new(9)
  end

  def perform_transition
    super unless @return
  end

  def terminate
    return if @return
    super
    dispose_menu_background
    @help_window.dispose
    @notebook_window.dispose
    @entries_window.dispose
    @command_window.dispose
  end
end

Thank you for your time and energy. *smile*

---

Signature

If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!!

- Nightgazer Starlight, Loyal Servant of The Royal Pony Sisters Princess Celestia and Princess Luna... Forever Equestria!

***
hail satan buddy 666
Rep:
Level 55
Blagil VlUE
Has you read the instruction
Instruction
Code: [Select]
=begin
To use this script, you need to have a folder in your game directory called
Notebook
This is where your .txt files should be located.
This script runs solely on the .txt files in the folder, and it's where it
grabs the files for the .rvdata conversion if used.
--------------------------------------------------------------------------------
To add new entries to the journal, use this in an event "Script..." command
add_entry("filename")
"filename" should be the name of a .txt file in the Notebook folder, excluding
the .txt. So say i have a file called Test.txt: add_entry("Test")
Even if you use the .rvdata file, the filenames stay the same so make sure
you remember your filenames.
--------------------------------------------------------------------------------
You can call the journal scene with this code in an event "Script..." command:
$scene = Scene_Notebook.new
The journal scene will be inaccessable unless the player has at least 1 entry
--------------------------------------------------------------------------------
If the text entry is too long height-wise to be shown completely, then the
player needs to use (left) to scroll up, or (right) to scroll down.
--------------------------------------------------------------------------------
To force a next line in the text, put \line inside the .txt file where you
want to force text to the next line
=end

Note book name change
Code: [Select]
NOTEBOOK_NAME = "Notebook"
For example, Notebook name
Code: [Select]
NOTEBOOK_NAME = "Hello Man"

Note book font change
Code: [Select]
NOTEBOOK_FONT = ["Verdana", "Arial", "Courier New"]
For example,
["Verdana", "Arial", "Courier New"]
Change "Verdana" to "Any font"
Change "Arial" to "Any font"
Change "Courier New" to "Any font"
Don't remove ""

Notebook font size
Code: [Select]
NOTEBOOK_FONT_SIZE = 20
Change 20 to any size like numbers.

Space Notebook
Code: [Select]
NOTEBOOK_WLH = 24
Change 24 to any space number.
I don't need money from you.
[

*
A-pow 2015
Rep:
Level 81
2014 Best RPG Maker User - GraphicsFor frequently finding and reporting spam and spam bots2013 Most Unsung MemberSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.How can I help you? :Da^2 + b^2 = c^2Secret Santa 2012 ParticipantSilver - GIAW 10Silver - GIAW 9Bronze - GIAW HalloweenGold - Game In A Week VII
She wasn't asking how to use it, she asked for a conversion.

***
hail satan buddy 666
Rep:
Level 55
Blagil VlUE
[

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Dunnit.

Code: [Select]
#===============================================================================
# Notebook Menu (VXA)
# By Jet10985 (Jet) - converted to VXA by Pacman (21/10/12)
#===============================================================================
# This script will add a Notebook menu to the game, which can be used to add
# entries to the notebook that the player can read.
# This script has: 6 customization options.
#===============================================================================
=begin
To use this script, you need to have a folder in your game directory called
Notebook
This is where your .txt files should be located.
This script runs solely on the .txt files in the folder, and it's where it
grabs the files for the .rvdata2 conversion if used.
--------------------------------------------------------------------------------
To add new entries to the journal, use this in an event "Script..." command
add_entry("filename")
"filename" should be the name of a .txt file in the Notebook folder, excluding
the .txt. So say i have a file called Test.txt: add_entry("Test")
Even if you use the .rvdata file, the filenames stay the same so make sure
you remember your filenames.
--------------------------------------------------------------------------------
You can call the journal scene with this code in an event "Script..." command:
goto_notebook
The journal scene will be inaccessable unless the player has at least 1 entry
--------------------------------------------------------------------------------
If the text entry is too long height-wise to be shown completely, then the
player needs to use (left) to scroll up, or (right) to scroll down.
--------------------------------------------------------------------------------
To force a next line in the text, put \line inside the .txt file where you
want to force text to the next line
=end

module Notebook

  # Would you like to convert all .txt files in the "Notebook" folder to a
  # .rvdata data file which can be encrpyted with the game, and used with
  # the USE_RVDATA_FILE option?
  DO_CONVERSION_TO_RVDATA = false

  # Would you like to use the Notebook.rvdata file generated with the
  # DO_CONVERSION_TO_RVDATA instead of the .txt files in the "Notebook" folder?
  USE_RVDATA_FILE = false

  # What is the notebook called?
  NOTEBOOK_NAME = "Notebook"

  # What font does the notebook use? The first item is the primary font you
  # want, and it will go through each item if the font doesn't exist
  # until it finds a font that does exist.
  NOTEBOOK_FONT = ["Verdana", "Arial", "Courier New"]

  # What is the font size in the notebook? 20 is default
  NOTEBOOK_FONT_SIZE = 20

  # How much space will be given for each line? 24 is default
  NOTEBOOK_WLH = 24

end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :notebook_entries
  #--------------------------------------------------------------------------
  # Alias listing
  #--------------------------------------------------------------------------
  alias jet1835_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args, &block)
    @notebook_entries = []
    jet1835_initialize(*args, &block)
  end
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Add Notebook Entry to Database
  #--------------------------------------------------------------------------
  def add_entry(filename)
    unless $game_system.notebook_entries.include?(filename)
      $game_system.notebook_entries.push(filename)
    end
  end
  #--------------------------------------------------------------------------
  # * Activate Notebook Scene
  #--------------------------------------------------------------------------
  def goto_notebook
    SceneManager.goto(Scene_Notebook)
  end
end

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs the title screen processing.
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # Alias listing
  #--------------------------------------------------------------------------
  alias jet1934_initialize initialize unless $@
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args, &block)
    convert_txt if Notebook::DO_CONVERSION_TO_RVDATA && $TEST
    jet1934_initialize(*args, &block)
  end
  #--------------------------------------------------------------------------
  # * Convert text from .txt to .rvdata2
  #--------------------------------------------------------------------------
  def convert_txt
    file = Dir.entries("Notebook")
    file.reverse!
    2.times {|i| file.pop }
    file.reverse!
    if file.empty?
      p "No files found in Notebook, aborting conversion process."
    end
    text_hash = {}
    for txt in file
      text_hash[txt] = File.open("Notebook/#{txt}", "r") {|a| a.read}
    end
    b = File.new("Data/Notebook.rvdata2", "wb")
    Marshal.dump(text_hash, b)
    b.close
    p "Notebook file successfully converted."
  end
end

#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  The string class. Can handle character sequences of arbitrary lengths.
# See String Literals for more information.
#==============================================================================

class String
  #--------------------------------------------------------------------------
  # * Split to each word
  #--------------------------------------------------------------------------
  def each_word
    array = self.split(" ")
    if block_given?
      array.each {|a| yield a }
    else
      return array
    end
  end
end

#==============================================================================
# ** Window_Notebook
#------------------------------------------------------------------------------
#  This window displays the note currently open.
#==============================================================================

class Window_Notebook < Window_Base
  #--------------------------------------------------------------------------
  # Include Notebook module
  #--------------------------------------------------------------------------
  include Notebook
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(filename)
    super(160, 56, Graphics.width - 160, Graphics.height - 56)
    @filename = filename
    refresh(@filename)
  end
  #--------------------------------------------------------------------------
  # * Refresh window
  #--------------------------------------------------------------------------
  def refresh(filename)
    self.oy = 0
    form_bitmap_rect(filename)
    self.contents.font.name = NOTEBOOK_FONT
    self.contents.font.size = NOTEBOOK_FONT_SIZE
    wlh = NOTEBOOK_WLH
    i = 0
    @file_text.each_line {|line|
      text = line.gsub(/\r|\n/i, "")
      self.contents.draw_text(0, 0 + i * wlh, self.width - 32, wlh, text)
      i += 1
    }
  end
  #--------------------------------------------------------------------------
  # * Form Contents (or whatever)
  #--------------------------------------------------------------------------
  def form_bitmap_rect(filename)
    if USE_RVDATA_FILE
      file = load_data("Data/Notebook.rvdata2")[filename + ".txt"]
    else
      file = File.open("Notebook/#{filename}.txt", "r") {|a| a.read }
    end
    new_text = ""
    width_taken = 0
    height_taken = 0
    file.gsub!(/\r\n/i, " ")
    file.gsub!(/\\line/i, " \\xjet ")
    file.each_word {|word|
      width_taken += self.contents.text_size("#{word} ").width
      if word == "\\xjet"
        width_taken = 0
        new_text.concat("\n")
        height_taken += NOTEBOOK_WLH
      elsif width_taken > self.width - 32
        width_taken = 0
        new_text.concat("\n#{word} ")
        width_taken += self.contents.text_size("#{word} ").width
        height_taken += NOTEBOOK_WLH
      else
        new_text.concat("#{word} ")
      end
    }
    @file_text = new_text
    @height_taken = height_taken
    self.contents = Bitmap.new(self.width - 32, @height_taken + 32)
  end
end

#==============================================================================
# ** Window_NoteCommand
#------------------------------------------------------------------------------
#  This window is the selection window for the notebook entries.
#==============================================================================

class Window_NoteCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Form list of commands
  #--------------------------------------------------------------------------
  def make_command_list
    for entry in $game_system.notebook_entries
      add_command(entry, :entry)
    end
  end
end

#==============================================================================
# ** Window_Entries
#------------------------------------------------------------------------------
#  This window displays the number of entries in the notebook database.
#==============================================================================

class Window_Entries < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, Graphics.height - 54, 160, 54)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh window
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    contents.font.color = system_color
    contents.draw_text(0, 0, 100, 24, "Entries:")
    contents.font.color = normal_color
    contents.draw_text(104, 0, 40, 24, $game_system.notebook_entries.size, 1)
  end
end

#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  This class performs notebook screen processing.
#==============================================================================

class Scene_Notebook < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    if $game_system.notebook_entries.empty?
      return_scene
    end
    super
    @help_window = Window_Help.new
    @help_window.set_text(Notebook::NOTEBOOK_NAME)
    @command_window = Window_NoteCommand.new(0, 0)
    @command_window.height = Graphics.height - 110
    @command_window.y = @help_window.height
    @entries_window = Window_Entries.new
    @notebook_window = Window_Notebook.new($game_system.notebook_entries[0])
    @command_window.height = Graphics.height - (@entries_window.height +
     @help_window.height)
    @notebook_window.y = @command_window.y
    @notebook_window.height = Graphics.height - @help_window.height
  end
  #--------------------------------------------------------------------------
  # * Frame update
  #--------------------------------------------------------------------------
  def update
    old_index = @command_window.index
    super
    if old_index != @command_window.index
      @notebook_window.refresh(@command_window.current_data)
    end
    @notebook_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      SceneManager.goto(Scene_Map)
    end
    if @notebook_window.contents.height > @notebook_window.height - 32
      wlh = Notebook::NOTEBOOK_WLH
      if Input.trigger?(Input::RIGHT)
        @notebook_window.oy = [@notebook_window.oy + wlh,
          @notebook_window.contents.height - @notebook_window.height + 32].min
      elsif Input.trigger?(Input::LEFT)
        @notebook_window.oy = [@notebook_window.oy - wlh, 0].max
      end
    end
  end
end

#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================

Let me know if anything's wrong. :)
it's like a metaphor or something i don't know

***
hail satan buddy 666
Rep:
Level 55
Blagil VlUE
Pacman, I am going to use it in my demo game. I will tell you, OK Pacman
[

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I think you should see if Neko Hibiki is okay with that first. Also make sure that you're only using scripts you really feel the need to. Don't use scripts just because they're there.

Also I'm not entirely sure it's completely functional. So be wary of that.
it's like a metaphor or something i don't know

**
Rep:
Level 74
RMRK Junior - - Cute Pegasus Pony
Dunnit.

Let me know if anything's wrong. :)

Thanks!^_^

But, I seem to be having a problem.

If I have more than one entry, when I try to use the down key to go to the other entries I get this ' Script 'Notebook' line 217: Errno::EINVAL occured.
Invalid argument - Notebook/{:name=>"Ice Dragons", :symbol=>:entry, :enabled=>true, :ext=>nil}.txt '.

The entries I was using are :

add_entry("Bought")
add_entry("Ice Dragons")
add_entry("Letter")
add_entry("Library")
add_entry("Note")
add_entry("Tentacles")

.

I hope I provided enough information there.

---

Signature

If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!!

- Nightgazer Starlight, Loyal Servant of The Royal Pony Sisters Princess Celestia and Princess Luna... Forever Equestria!

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I believe I know what's causing that. Go to line 322. Around here you should see the line:
Code: [Select]
      @notebook_window.refresh(@command_window.current_data)
Replace that with:
Code: [Select]
      @notebook_window.refresh(@command_window.current_data[:name])
That should work. Lemme know how it goes.
it's like a metaphor or something i don't know

**
Rep:
Level 74
RMRK Junior - - Cute Pegasus Pony
I believe I know what's causing that. Go to line 322. Around here you should see the line:
Code: [Select]
      @notebook_window.refresh(@command_window.current_data)
Replace that with:
Code: [Select]
      @notebook_window.refresh(@command_window.current_data[:name])
That should work. Lemme know how it goes.

Thanks!^_^

That got it, it's working fine now!^_^

Sorry for the late reply.

Been out sick lately y'know.

Thanks again now!^_^

---

Signature

If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!!

- Nightgazer Starlight, Loyal Servant of The Royal Pony Sisters Princess Celestia and Princess Luna... Forever Equestria!

**
Rep:
Level 74
RMRK Junior - - Cute Pegasus Pony

One more thing.

I was wondering, is it possible to make the entries display alphabetically now as well?

You don't have to bother with this if you don't want to, it's purely optional.

---

Signature

If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!!

- Nightgazer Starlight, Loyal Servant of The Royal Pony Sisters Princess Celestia and Princess Luna... Forever Equestria!

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I don't think I have the time or skills required to implement that. I'm not sure how to check the first letter of a string. Sorry.
it's like a metaphor or something i don't know

**
Rep:
Level 74
RMRK Junior - - Cute Pegasus Pony
I don't think I have the time or skills required to implement that. I'm not sure how to check the first letter of a string. Sorry.

Ok.

No problem there.

Like I said, purely optional.

---

Signature

If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!!

- Nightgazer Starlight, Loyal Servant of The Royal Pony Sisters Princess Celestia and Princess Luna... Forever Equestria!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
I don't think I have the time or skills required to implement that. I'm not sure how to check the first letter of a string. Sorry.

Well, if x is your string, then you can check the first letter by x[0,1], but for sorting things alphabetically, it is useful to know when you check <=> as between two strings, the result is determined alphabetically, which is to say a < b < c < ... x < y < z < A < B < C < ... And it works for strings of any length, so it will sort the way you expect alphabetical sorting to work. Anyway, if you have an unsorted array of strings, ary, all you would need to do is:

Code: [Select]
ary.sort! { |a, b| a.downcase <=> b.downcase }

Alternately, you could maintain an alphabetrical list by inserting them into the appropriate place when they are first added. I think I do something similar in my Quest Journal.
« Last Edit: October 28, 2012, 01:13:52 PM by modern algebra »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
I was asked by a member where to insert the code to make it alphabetical. This was my response:

If you only ever add to the notebook through the add_entry method, then you could go to that method in the script:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Add Notebook Entry to Database
  #--------------------------------------------------------------------------
  def add_entry(filename)
    unless $game_system.notebook_entries.include?(filename)
      $game_system.notebook_entries.push(filename)
    end
  end

And just add the following line right after $game_system.notebook ...:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Add Notebook Entry to Database
  #--------------------------------------------------------------------------
  def add_entry(filename)
    unless $game_system.notebook_entries.include?(filename)
      $game_system.notebook_entries.push(filename)
      $game_system.notebook_entries.sort! { |a, b| a.downcase <=> b.downcase }
    end
  end

That said, that is a very inefficient way to do it and it could get laggy if you have tons of entries. It would be better to insert them in a sorted array to begin with.

You could do that by adding the following module into its own slot in the Script Editor:

Code: [Select]
#==============================================================================
# ** MAQJ_SortedArray
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This module mixes in to an array to maintain the sorted order when inserting
#==============================================================================

module MAQJ_SortedArray
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Insert to Array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maqj_insert_sort(el, &block)
    index = bsearch_index(el, 0, size, &block)
    index ? insert(index, el) : push(el)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Retrieve Index from Binary Search
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def bsearch_index(el, b = 0, e = size, &block)
    return bsearch_index(el, b, e) { |a,b| a <=> b } if block.nil?
    return b if b == e # Return the discovered insertion index
    return if b > e
    m = (b + e) / 2    # Get Middle
    block.call(el, self[m]) > 0 ? b = m + 1 : e = m
    bsearch_index(el, b, e, &block)
  end
end

Then, you would need to go to the above method already mentioned and change it to:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Add Notebook Entry to Database
  #--------------------------------------------------------------------------
  def add_entry(filename)
    unless $game_system.notebook_entries.include?(filename)
      $game_system.notebook_entries.maqj_insert_sort(filename) { |a, b| a.downcase <=> b.downcase}
    end
  end

And then you would need to go to the Initialize method in Game System, which should look like this:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args, &block)
    @notebook_entries = []
    jet1835_initialize(*args, &block)
  end

You would need to change it to:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args, &block)
    @notebook_entries = [].send(:extend, MAQJ_SortedArray)
    jet1835_initialize(*args, &block)
  end


Those are alternatives. Do one or the other. Don't do both.

Again, either method only works if all entries to the array are added through the add_entry method in Game_Interpreter. If you add them through $game_system directly then they won't get sorted, and it is particularly troublesome to do that if you add it throught the second way.


Also, if you're already using my Quest Journal, then there is no reason to add that module in its own slot.
« Last Edit: January 12, 2013, 03:30:23 PM by modern algebra »

**
Rep:
Level 74
RMRK Junior - - Cute Pegasus Pony

Yes, I am using your Quest Journal. *Smiles*

I used the second method, the one with the 'MAQJ' array.

It works fine. *Smiles*

It even sorts numerically too.

And it scrolls when there's many entries.

Thank you, thank you, thank you, thank you, thank you very much now! *Smiles*

This is just what I needed too! *Smiles*

Now my game will work very great! *Smiles*

My game is going to absolutely rock!

---

Signature

If you are a believer of Jesus Christ, and are 100% proud of it, put this in your sig!!

- Nightgazer Starlight, Loyal Servant of The Royal Pony Sisters Princess Celestia and Princess Luna... Forever Equestria!