Seamsquall

dhbchest's Datalog script refreshing each time you restart the game.

12 posts in this topic

Hello. I have been using dbchest's datalog script and it has been working great. However, after making around 120 pages of datalog with it, I realised that upon restarting the game, it isn't saving the datalogs and sort of "resetting to default" forgetting all the datalogs unlocked during the game. 

I checked and this problem is in the script, it is not influenced by other scripts. 

 

Here is the script : 

 

#==============================================================================
# ** dbchest's Datalog (v2.0)
#==============================================================================
# ** Credits (Freeware)
#------------------------------------------------------------------------------
# a list of credits for those involved in the production of said script.
# you are responsible for crediting those mentioned (using discretion).
# you do not have to credit special mentions. they are being thanked now.
#------------------------------------------------------------------------------
# programmer: dbchest (none required, always appreciated)
# special thanks: Riff (rpgmakervxace.net) # for general help RGSS3.
#==============================================================================
# ** Details
#------------------------------------------------------------------------------
# any notable programmer would have one to include in their resume! it's my
# pleasure to present you with what i consider to be a satisfactory grade
# datalog script. included in your project, you will give your players the
# opportunity to review important events, people, places, and more. should you
# come across any programming errors, be sure to contact me at
# rpgmakervxace.net (dbchest) with information of your findings. thanks for
# trying me out.
#==============================================================================
# ** Features
#------------------------------------------------------------------------------
# access your datalog from your menu.
# record and review important events, people, places, etc...
# control the order in which commands and information is added to your log.
#==============================================================================
# ** Installation Instructions (Plug and Play)
#------------------------------------------------------------------------------
# paste script in "Materials" section of the script editor.
# no known compatibility issues.
# no foreign script requirements.
#==============================================================================

#==============================================================================
# ** Datalog
#------------------------------------------------------------------------------
# This module defines subjects and their content within the datalog. The
# display window can accomodate fifty-one text characters per line. Begin new
# lines by using the \n expression.
#==============================================================================

module Datalog
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
DATALOG = "Datalog"
HELP = "Review detailed information about " # 34 / 51 => *17 remaining*
#--------------------------------------------------------------------------
# * Constants (Subject Help)
#--------------------------------------------------------------------------
COM1HELP = "storyline events\nthat have taken shape thus far."
COM2HELP = "the diverse\nenvironments you've explored."
#--------------------------------------------------------------------------
# * Constants (Content Help)
#--------------------------------------------------------------------------
SINGHELP = "."
PLURHELP = "s."
#--------------------------------------------------------------------------
# * Constants (Content Text Display)
#--------------------------------------------------------------------------
INFO1 = "INFO1"
INFO2 = "INFO2"
INFO3 = "INFO3"
INFO4 = "INFO4\nINFO5"
#--------------------------------------------------------------------------
# * Key Mapping (Subjects)
#--------------------------------------------------------------------------
SUBJECT = {}
SUBJECT[:story] =
{:help => COM1HELP,
:string => "Storyline",
:content => ["A New Day"] }
SUBJECT[:locations] =
{:help => COM2HELP,
:string => "Locations",
:content => ["Amarillo"] }
#--------------------------------------------------------------------------
# * Key Mapping (Contents)
#--------------------------------------------------------------------------
CONTENT = {}
CONTENT[:story] =
{:help => SINGHELP,
:anewday => INFO1,
:anewnight => INFO2 }
CONTENT[:locations] =
{:help => SINGHELP,
:amarillo => [iNFO3, INFO4] }
end
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================

class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * For Adding Original Commands
#--------------------------------------------------------------------------
def add_original_commands
add_command(Datalog::DATALOG, :datalog, datalog_enabled?)
end
#--------------------------------------------------------------------------
# * Get Activation State of Datalog Commands
#--------------------------------------------------------------------------
def datalog_enabled?
return true
#return true if Datalog::SUBJECT[:story][:content].size > 0
#return true if Datalog::SUBJECT[:locations][:content].size > 0
end
end
#==============================================================================
# ** Window_DatalogHeader
#------------------------------------------------------------------------------
# This window appears on the datalog screen.
#==============================================================================

class Window_DatalogHeader < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :text
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 72, window_width, window_height)
@text = Datalog::DATALOG
draw_header
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_height
return line_height + standard_padding * 2
end
#--------------------------------------------------------------------------
# * Draw Header Text
#--------------------------------------------------------------------------
def draw_header
contents.draw_text(4, 0, window_width, line_height, @text)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_header
end
end
#==============================================================================
# ** Window_DatalogCommand
#------------------------------------------------------------------------------
# This command window appears on the datalog screen.
#==============================================================================

class Window_DatalogCommand < Window_Command
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :subject # current subject
attr_accessor :content # current content
attr_accessor :command_list # current command list
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@subject = nil
@content = nil
@command_list = :subjects
super(0, 120)
end
#--------------------------------------------------------------------------
# * Window Width
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Window Height
#--------------------------------------------------------------------------
def window_height
return Graphics.height - 120
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
if @command_list == :subjects
Datalog::SUBJECT.each do |key, value|
add_command(value[:string], key, true)
end
elsif @command_list == :contents
Datalog::SUBJECT[@subject][:content].each do |content|
add_command(content, create_symbol(content), true,)
end
end
end
#--------------------------------------------------------------------------
# * Create Symbol for Content
#--------------------------------------------------------------------------
def create_symbol(content)
string = content.clone
string.slice!(/\s/) until !string.include?(" ")
return string.downcase.to_sym
end
end
#==============================================================================
# ** Window_DatalogPages
#------------------------------------------------------------------------------
# This window appears on the datalog screen.
#==============================================================================

class Window_DatalogPages < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :current_page # current page
attr_accessor :max_page # maximum page
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(160, 72, window_width, window_height)
@current_page = 1
@max_page = nil
end
#--------------------------------------------------------------------------
# * Window Width
#--------------------------------------------------------------------------
def window_width
return Graphics.width - 160
end
#--------------------------------------------------------------------------
# * Window Height
#--------------------------------------------------------------------------
def window_height
return Graphics.height - 72
end
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
return 1
end
#--------------------------------------------------------------------------
# * Get Item Width
#--------------------------------------------------------------------------
def item_width
current = @current_page.to_s
max = @max_page.to_s
text = "Page" + " " + current + "/" + max
return text.size * 10.9
end
#--------------------------------------------------------------------------
# * Draw Page Number
#--------------------------------------------------------------------------
def draw_page_number
rect = Rect.new(4, 0, window_width, line_height)
current = @current_page.to_s
max = @max_page.to_s
text = "Page" + " " + current + "/" + max
draw_text(rect, text)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_page_number
end
end
#==============================================================================
# ** Window_DatalogText
#------------------------------------------------------------------------------
# This window shows detailed descriptions of selected content.
#==============================================================================

class Window_DatalogText < Window_Help
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(line_number = 13)
super
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_MenuCommand.new
@command_window.set_handler(:item, method(:command_item))
@command_window.set_handler(:skill, method(:command_personal))
@command_window.set_handler(:equip, method(:command_personal))
@command_window.set_handler(:status, method(:command_personal))
@command_window.set_handler(:formation, method(:command_formation))
@command_window.set_handler(:datalog, method(:command_datalog))
@command_window.set_handler(:save, method(:command_save))
@command_window.set_handler(:game_end, method(:command_game_end))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# * [Datalog] Command
#--------------------------------------------------------------------------
def command_datalog
SceneManager.call(Scene_Datalog)
end
end
#==============================================================================
# ** Scene_Datalog
#------------------------------------------------------------------------------
# This class performs the datalog screen processing.
#==============================================================================

class Scene_Datalog < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
@subject = nil
@content = nil
create_help_window
create_header_window
create_command_window
create_pages_window
create_text_window
end
#--------------------------------------------------------------------------
# * Frame Update (Basic)
#--------------------------------------------------------------------------
def update_basic
super
update_help_window
update_text_window
update_display_window
end
#--------------------------------------------------------------------------
# * Update Help Window
#--------------------------------------------------------------------------
def update_help_window
return unless @command_window.active
@help_window.set_text(help_text)
end
#--------------------------------------------------------------------------
# * Get Help Window Text
#--------------------------------------------------------------------------
def help_text
if @command_window.command_list == :subjects
sub = Datalog::HELP
main = Datalog::SUBJECT[@command_window.current_symbol][:help]
return sub + main
elsif @command_window.command_list == :contents
sub = Datalog::HELP
main = @command_window.command_name(@command_window.index)
post = Datalog::CONTENT[@subject][:help]
return sub + main + post
end
end
#--------------------------------------------------------------------------
# * Update Text Window
#--------------------------------------------------------------------------
def update_text_window
return unless @pages.active
@text_window.set_text(display_text)
end
#--------------------------------------------------------------------------
# * Get Display Window Text
#--------------------------------------------------------------------------
def display_text
if Datalog::CONTENT[@subject][@content].instance_of?(Array)
path = Datalog::CONTENT[@subject][@content]
return path[@pages.current_page - 1]
else
return Datalog::CONTENT[@subject][@content]
end
end
#--------------------------------------------------------------------------
# * Update Display Window
#--------------------------------------------------------------------------
def update_display_window
return unless @pages.active
if Input.trigger?(:LEFT)
unless @pages.current_page == 1
Sound.play_cursor
@pages.current_page -= 1
end
elsif Input.trigger?(:RIGHT)
unless @pages.current_page == @pages.max_page
Sound.play_cursor
@pages.current_page += 1
end
end
@pages.refresh
end
#--------------------------------------------------------------------------
# * Create Header Window
#--------------------------------------------------------------------------
def create_header_window
@header_window = Window_DatalogHeader.new
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_DatalogCommand.new
@command_window.set_handler(:cancel, method(:on_cancel))
set_subject_handlers
set_content_handlers
end
#--------------------------------------------------------------------------
# * Set Command Window Subject Handlers
#--------------------------------------------------------------------------
def set_subject_handlers
Datalog::SUBJECT.each do |key, value|
@command_window.set_handler(key, method(:command_subject))
end
end
#--------------------------------------------------------------------------
# * Set Command Window Content Handlers
#--------------------------------------------------------------------------
def set_content_handlers
Datalog::SUBJECT.each do |key, value|
value[:content].each do |content|
string = content.clone
string.slice!(/\s/) until !string.include?(" ")
symbol = string.downcase.to_sym
@command_window.set_handler(symbol, method(:command_content))
end
end
end
#--------------------------------------------------------------------------
# * Create Pages Window
#--------------------------------------------------------------------------
def create_pages_window
@pages = Window_DatalogPages.new
@pages.set_handler(:cancel, method(:on_display_cancel))
end
#--------------------------------------------------------------------------
# * Create Text Window
#--------------------------------------------------------------------------
def create_text_window
@text_window = Window_DatalogText.new
@text_window.x = 160
@text_window.y = 96
@text_window.width = 384
@text_window.height = 344
@text_window.opacity = 0
@text_window.arrows_visible = false
end
#--------------------------------------------------------------------------
# * [subject] Command
#--------------------------------------------------------------------------
def command_subject
set_subject
update_command_window
update_header_window
end
#--------------------------------------------------------------------------
# * [Content] Command
#--------------------------------------------------------------------------
def command_content
set_content
set_max_page
@command_window.deactivate
@pages.refresh
@pages.activate.select(0)
end
#--------------------------------------------------------------------------
# * [Cancel] Display
#--------------------------------------------------------------------------
def on_display_cancel
@text_window.clear
@pages.contents.clear
@pages.deactivate.unselect
@pages.current_page = 1
@command_window.activate
end
#--------------------------------------------------------------------------
# * [Cancel]
#--------------------------------------------------------------------------
def on_cancel
if @command_window.command_list == :subjects
SceneManager.return
elsif @command_window.command_list == :contents
update_command_window
update_header_window
end
end
#--------------------------------------------------------------------------
# * Set Subject
#--------------------------------------------------------------------------
def set_subject
subject = @subject = @command_window.current_symbol
@command_window.subject = subject
end
#--------------------------------------------------------------------------
# * Set Content
#--------------------------------------------------------------------------
def set_content
content = @content = @command_window.current_symbol
@command_window.content = content
end
#--------------------------------------------------------------------------
# * Set Max Page
#--------------------------------------------------------------------------
def set_max_page
if Datalog::CONTENT[@subject][@content].instance_of?(Array)
@pages.max_page = Datalog::CONTENT[@subject][@content].size
else
@pages.max_page = 1
end
end
#--------------------------------------------------------------------------
# * Update Command Window
#--------------------------------------------------------------------------
def update_command_window
@command_window.deactivate.unselect
if @command_window.command_list == :subjects
@command_window.command_list = :contents
@command_window.refresh
@command_window.activate.select(0)
elsif @command_window.command_list == :contents
@command_window.command_list = :subjects
@command_window.refresh
@command_window.activate.select_symbol(@subject)
end
end
#--------------------------------------------------------------------------
# * Update Header Window
#--------------------------------------------------------------------------
def update_header_window
if @command_window.command_list == :subjects
@header_window.text = Datalog::DATALOG
elsif @command_window.command_list == :contents
@header_window.text = Datalog::SUBJECT[@subject][:string]
end
@header_window.refresh
end
end

 

 

and here is the link to the original post of the script. http://www.rpgmakercentral.com/topic/18719-dbchests-datalog/

 

I know there are other scripts that have similar features, but this one by far is the one I prefer, and I have already used it a lot. 

 

I did a new post here since the scripter now only works on MV. 

Thanks in advance for your help! 

Edited by Seamsquall

Share this post


Link to post
Share on other sites

You should have put that script into a spoiler. Saves space when scrolling down.

 

I'm not a scripter or a master of ruby, but I try to help.

 

I downloaded the demo and tried it out. It also does not save information. The problem is that the script does not seem to be set to save information by default.

Without the script be rewritten (hopefully by the author) then don't put a lot of trust that someone will help with this (unless they have used it before).

 

I suspect that you will have to script a common event to check what the player has found (possibly by switches) and add the information into the datalog every time the player starts the game.

 

Good luck.

Share this post


Link to post
Share on other sites

Thank you for the advice. It is the first time I wrote a post so I didn't know. 

 

I don't think the fix is hard if you know how to use Ruby.  

 

The problem definitely comes from the script and not from interfering with other scripts indeed. I could indeed use switches however it would be very complicated since there is 120 pages of datalog already, and I plan to add another 100. I guess I will do that if no one finds out a way. 

 

Anyway, I might have found a lead. There was another script which had the same problem, DoctorTodd's  

http://rmrk.net/index.php?topic=46302.0

 

And someone just added this to the code to fix it : 

 

 

class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :todd_difficulty # save forbidden
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias todd_difficulty_gamesystem_init initialize
def initialize
@todd_difficulty = 0
todd_difficulty_gamesystem_init
end
end

 

 

I'm assuming the same code can be used and just change to the right class. I might be wrong though. 

Edited by Seamsquall

Share this post


Link to post
Share on other sites

How are you 'unlocking' new dialogues with this? Just adding stuff to the hashes dynamically? It doesn't seem to be designed with that in mind to me. The demo seems to be a broken link and there isn't much documentation in the script it's self, but I don't see how it was ever meant to work as something you can 'unlock' text in.

Share this post


Link to post
Share on other sites

You pretty much set categories in the script, add a title with a variable being equal to x, then with a scriptcall you do a script call (that I stole from the demo) like this one :

datalog = Datalog::SUBJECT
key = :story
value = :content
subject = "A new goal"
datalog[key][value].push subject unless
datalog[key][value].include?(subject)

 

The script works until you close the game and restart it, it then removes what you've added during the game. This also happens in the demo, so something is wrong with the script and its not interference from other scripts.

 

The fix is probably simple but I am not capable of fixing it myself right now. If it is needed I could upload the demo and link it here (if it is not available in the original link anymore.)

Share this post


Link to post
Share on other sites

Is that the way the original author said to do it? Because modifying a constant like that is usually bad practice, not to mention that it involves adding everything to the subjects rather then just unlocking the subject. It really seems like a kluge for a script that was never made to unlock things to me. A fix would require more then a few things to be rewriten I think.

Share this post


Link to post
Share on other sites

Yes it is, I just copied the script call used in the demo, it's how the script is supposed to work and it is explained as such in the script:

 

#==============================================================================
# ** Features
#------------------------------------------------------------------------------
#  access your datalog from your menu.
#  record and review important events, people, places, etc...
#  control the order in which commands and information is added to your log.

It is pretty much the point of the script, I just followed what the demo show really.

Share this post


Link to post
Share on other sites

Unfortunately for you, roninator and KZ are on the money about this one. Script is borked. Go play the demo again, if you save and then load the "updated" contents disappears afterwards. The guy just never implemented any way to save the extra information you put in during the script call. It's a bad script. The demo is actually still available, the dropbox link is broken but the mediafire one still works.

 

The "fix" is "simple" if you know how the script works and how to code, but I personally would not use this script. There's at least one problem with it (see the last paragraph of this post) that cannot be remedied without extensively rewriting the entire script.

 

If you still want to use this script, then try this:

Spoiler

Put this somewhere into your script editor.


class Game_System
  attr_accessor :datalogue_subjects
end

Insert this line somewhere into the saving process:


$game_system.datalogue_subjects = Datalog::SUBJECT.clone

You can put it in Scene_Save or DataManager or even in a script call after the datalog update call, it can be done anywhere along the saving process as long as it's before you save.

 

Finally, put this somewhere in the loading process:


$game_system.datalogue_subjects.each { |key, value|
   value[:content].each { |data| 
   Datalog::SUBJECT[key][:content].push(data) unless
   Datalog::SUBJECT[key][:content].include?(data) }
}

Scene_Load, DataManager, anywhere works as long as it is after DataManager extracts the $game_system data from the save file.

 

It's just a band-aid fix to save the whole Datalog::SUBJECT hash when you save game and then manually push back the entries on load. And it only loads the entries and not the topics, so if you used script calls to add additional topics (i.e. Story/Location/ect.) that don't exist in the main Datalog script, it will probably crash. I will not guarantee this will work cleanly if you have other clashing scripts. And no, I won't provide any further instructions on how to make it work.

 

On 10/9/2017 at 3:14 AM, Kayzee said:

I don't see how it was ever meant to work as something you can 'unlock' text in.

 

Yeah, you kinda have to look real closely to see how it was... meant... to work. It stores the main text for each entry in this "CONTENT" hash - everything there is all meant to be pre-written beforehand. The entry buttons to access that text are stored in a separate hash called "SUBJECT" and won't show up in the menu until you add them by script call. That is to say, they don't -exist- in the SUBJECT hash until they are manually created and pushed into it.

 

This "unlocks" the pre-written CONTENT text for viewing, but since the pushed SUBJECT entries are never saved the whole SUBJECT hash just wipes itself upon load. And how does dbchest link the script-call-created SUBJECT entries with the stuff in CONTENT? He actually wrote a parsing function to lowercase and whitespace-remove the strings that are the SUBJECT entries and then matches them against the symbol keys in CONTENT.

 

Which is kinda a shitty way to do it, because then if you wanted to have two different entries that would look the same without spaces, you can't (well you can but they end up linking to the same body of text). Example from the demo, there's an entry titled "A New Day" that links to text stored in CONTENT's :anewday. If you then wanted to make a different entry titled "Anew Day" then tough because it would link itself to the exact same text stored in :anewday.

Edited by Traverse
Seamsquall likes this

Share this post


Link to post
Share on other sites

Followed your steps and now it works perfectly fine.

 

I'm fine with not being able to put two entries with the same name so I'll keep using this script, now that it works.

 

Thank you very much for taking the time to look into this.

 

 

 

 

Edited by Seamsquall

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.