Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Lost_Hope on January 22, 2008, 12:24:37 pm

Title: [RESOLVED] Journals
Post by: Lost_Hope on January 22, 2008, 12:24:37 pm
ok so in my game there is a journal that is kept of the adventures.It is kinda like KH journal but I need a script for it.I was wondering if anyone could help me out here.I will do artwork for you (a selective amount) in return...
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 12:49:05 pm
Is it something like a quest logger or rather a script that simply shows text where you enable pieces of text after a couple of events?
Title: Re: Journals
Post by: Lost_Hope on January 22, 2008, 12:52:21 pm
it is not a quest log.the quest log is another thing Im going to do.the journal changes after a certain amount of events like in KH.That is what I need.
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 12:54:40 pm
This would be very easy to make. Like, you add a couple of texts in advance and after you use a command in an event, the text changes and the next one is being displayed?
Title: Re: Journals
Post by: Lost_Hope on January 22, 2008, 12:55:56 pm
ya like when you read it at one point in time it might say a little entry and when a big event happens in the story the next time you read it it will have a new entry...
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 01:02:39 pm
Give me 20 minutes. (The instructions need like 10. >.< )
Title: Re: Journals
Post by: Lost_Hope on January 22, 2008, 01:03:31 pm
well i'll look at it when I get home cuase I g2g...oh and what artwork do you want done?since I'm already doin that other thing for the Blizz RTP or somethin...
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 01:18:13 pm
I'll see later what I need. I could need another sprite for CP, though. xD Hm, you know what? instead of another sprite, how about you just put some extra effort into the current sprite and make it like I want it? ^_^

Journal Viewer Script: ShowHide
Code: Journal Viewer Script
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Journal Display by Blizzard
# Version: 2.0
# Type: Journal Viewer
# Date: 22.1.2008
# Date v2.0: 24.1.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
#   99% compatible with SDK v1.x. 90% compatible with SDK v2.x. Should be
#   compatible with everything else. WILL corrupt old savegames.
#
#
# Features:
#
#   - define texts that should be displayed
#   - easy change of the text that is being displayed
#   - returns to the scene that called it
#
# new in 2.0:
#   
#   - now able to unlock pages during game play
#   - display pages in unlocking order or a fixed order
#   - add now page title and text instead of text only
#
#
# Explanation:
#
#   This script will allow you to use a journal scene that shows some text that
#   you define in advance. You can change the text displayed to any other of
#   the predefined texts with one command.
#
#
# Configuration:
#   
#   Set up the configuration below and add your pictures to the folder you
#   specified. Call the scene with following syntax:
#   
#     $scene = Scene_Journal.new
#     
#   If you want to unlock another page, simply use a "Call Script" event
#   command with following syntax:
#   
#     $game_system.unlock_journal(PAGE_NUMBER)
#   
#   PAGE_NUMBER - page number to unlock
#   
#   
# IMPORTANT NOTE:
#   
#   If one of your texts is too long to fit in one page, simply split it into
#   two pages into two titles and unlock all the pages that you need. You can
#   also use something like
#   
#   
#   
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#==============================================================================
# module BlizzCFG
#==============================================================================

module BlizzCFG
 
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  # font name in which the journal should be displayed
  JOURNAL_FONTNAME = 'Arial'
  # font size in which the journal should be displayed
  JOURNAL_FONTSIZE = 22
  # 0 = left, 1 = center, 2 = right
  JOURNAL_FONTALIGN = 0
  # if you set this to true, pages will be displayed in the order you unlock them
  IN_ORDER = false
  # entries, the template is ["Title", "Text"]
  JOURNAL_ENTRIES = [
      ["Getting started", "This is the first entry."],
      ["Second entry", "Don't forget that the last entry does NOT have a comma after the string."],
      ["Testing text slicer", "This text repeats itself. This text repeats itself. This text repeats itself. This text repeats itself. This text repeats itself. This text repeats itself. Oh yeah, this is entry 2."],
      ["This text is too long", "I have copy-pasted a text here that doesn't fit into one page to demonstrate how to split a text that is simply too long to fit in one page. L3X has his own will. He destroyed his own extern controller module due to the fact that his Tech4X AI was developed enough so he could do it. He would have never done it if it wasn't for the Scord virus attack. There is no known way to manipulate this cyborg from within anymore. As a model of the limited L3X1-MU5 series he has close combat abilities beyond those of a mere" +
       "human. L3X himself was not originally implement with the Tech4X AI, he was fighting during Scord War 1 with the Tech3 AI. As a reward he was upgraded with the Tech4X AI due to his excellent performance in Scord War 1. Well, since this text"],
      ["This text is too long (continued)", "actually exactly fits into one page, I have added those last words to simply prolong it."]
  ]
     
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  attr_reader :journal
 
  alias init_journal_later initialize
  def initialize
    init_journal_later
    @journal = []
  end
 
  def unlock_journal(id)
    @journal.push(id-1) unless @journal.include?(id-1)
  end
 
end
 
#==============================================================================
# Window_Base
#==============================================================================

class Window_Base
 
  def slice_text(text, width)
    result, last_word, current_text = [], 0, ''
    (0..text.size).each {|i|
        if text[i, 1] == ' ' || i == text.size
          word = text[last_word, i-last_word]
          if self.contents.text_size("#{current_text} #{word}").width > width
            result.push(current_text)
            current_text = word
          else
            current_text += (current_text == '' ? word : " #{word}")
          end
          last_word = i+1
        end}
    result.push("#{current_text} #{text[last_word, text.size-last_word]}")
    return result
  end
 
end

#==============================================================================
# Window_JournalDisplay
#==============================================================================

class Window_JournalDisplay < Window_Base
 
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = BlizzCFG::JOURNAL_FONTNAME
    self.contents.font.size = BlizzCFG::JOURNAL_FONTSIZE
    @index, @journal = 0, $game_system.journal.clone
    @journal.sort! unless BlizzCFG::IN_ORDER
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.draw_text(4, 416, 252, 32, 'Page', 2)
    self.contents.draw_text(4, 416, 292, 32, (@index+1).to_s, 2)
    self.contents.draw_text(4, 416, 600, 32, '/', 1)
    self.contents.draw_text(312, 416, 292, 32, @journal.size.to_s)
    return if @journal.size == 0
    self.contents.draw_text(4, 0, 600, 32, BlizzCFG::JOURNAL_ENTRIES[@journal[@index]][0], 1)
    text = slice_text(BlizzCFG::JOURNAL_ENTRIES[@journal[@index]][1], 592)
    text.each_index {|i| self.contents.draw_text(4, (i+1)*32+16, 600, 32, text[i], BlizzCFG::JOURNAL_FONTALIGN)}
  end
 
  def update
    super
    if Input.repeat?(Input::RIGHT)
      if @journal.size == 0
        $game_system.se_play($data_system.buzzer_se)
      else
        $game_system.se_play($data_system.cursor_se)
        @index = (@index+1) % @journal.size
        refresh
      end
    elsif Input.repeat?(Input::LEFT)
      if @journal.size == 0
        $game_system.se_play($data_system.buzzer_se)
      else
        $game_system.se_play($data_system.cursor_se)
        @index = (@index+@journal.size-1) % @journal.size
        refresh
      end
    end
  end
 
end

#==============================================================================
# Scene_Journal
#==============================================================================

class Scene_Journal
 
  def initialize
    @scene = $scene.class
  end
 
  def main
    @window = Window_JournalDisplay.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      @window.update
      break if Input.trigger?(Input::C) || Input.trigger?(Input::B)
    end
    $game_system.se_play($data_system.cancel_se)
    Graphics.freeze
    @window.dispose
    $scene = @scene.new
  end
 
end
Title: Re: Journals
Post by: Lost_Hope on January 22, 2008, 02:20:50 pm
this aint calintz I dont do sprites...i do ARTWORK
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 02:40:34 pm
Sorry... <_<; You know that I'm in a mess right now and sometimes mess up names... >.< anyway, if I need something, I'll let you know.
Title: Re: Journals
Post by: Dark Dragon on January 22, 2008, 03:27:23 pm
Blizz you mean you did that in 20 minutes ? You're kidding right ? O_O
Damn ... it would it take me at least 1 hour to do that...
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 04:05:20 pm
It's easy. I mean, just look at the code. It's as good as copy-paste only. I had the slice_text method in my Bestiary and Advanced Analyze System already, the rest really is as good as copy paste except for the instructions.

EDIT:

Look at the time difference between my posts. The first says 19:02:39 and the second says 19:18:13. :3
Title: Re: Journals
Post by: Dark Dragon on January 22, 2008, 04:21:05 pm
Oh awesome I was looking for that text_slice thingy for ages :D
Who should I credit if I use it ? you, or someone else ?
Title: Re: Journals
Post by: Blizzard on January 22, 2008, 04:34:28 pm
It's mine. :)
Title: Re: Journals
Post by: Lost_Hope on January 22, 2008, 09:45:00 pm
# Configuration:
#   
#   Set up the configuration below and add your pictures to the folder you
#   specified. Call the scene with following syntax:
#   
#     $scene = Scene_Journal.new
#     
#   If you want to change the display, simply change the assigned variable's
#   value to the key corresponding to the given text.

I dont understand any of this...
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:05:31 pm
Do I have the ok to use this??
Title: Re: Journals
Post by: Lost_Hope on January 22, 2008, 10:07:50 pm
i guess...i dont know how to work it though...
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:09:23 pm
Here's a demo just open up the project and run it to see how it's done http://www.sendspace.com/file/dv7r0b (http://www.sendspace.com/file/dv7r0b)
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:09:34 pm
I'll take a look at it, and if Blizz doesn't tell you first, I'll see if I can elaborate, kk??
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:10:05 pm
it's fine I just put up a demo for him
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:12:44 pm
I noticed, Lol...and I downloaded it  :P

Credits to you Nortos?? I think I'm gonna use this...
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:15:41 pm
no Blizz I just accidently cut off his name at the top of the script lol
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:20:00 pm
Lol...
*accidently*

All right, I'll credit him. Do you get any credit at all??
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:23:49 pm
nah all I did was make a demo
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:24:46 pm
All right...thnx for being honest ;D
Title: Re: Journals
Post by: Sally on January 22, 2008, 10:28:58 pm
this seams cool. i think imma use it! :)

credit to:

blizard for script

seaniorsr  for idea
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:33:38 pm
If you put too much text in this window, what happens??
I really think that the script that Fantasist made for my Artwok Viewer would be perfect for this script!! The screen panning one.
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:37:17 pm
Well it would just go off the viewpoint probably but I don't think you would need to much text also want me to see about getting the paning? though I don't know why would want it in a journal
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:40:10 pm
Well, can this script handle pages??

Like:                                                               
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~And by pressing left and right, you scroll through pages...

<<                         Page 1                         >>
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:47:13 pm
yeah but the pans not avaliable as he;s using text and in a window class I hadn't looked at his code
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:48:43 pm
I'm sure it could be modified in some manner, but don't worry about it. If I can use pages, I'm not concerned with the pan feature. Ok, so how do I use pages with this script??
Title: Re: Journals
Post by: Nortos on January 22, 2008, 10:53:25 pm
I'll do it it'll be pretty easy and than I'll put up a demo for you
Title: Re: Journals
Post by: Calintz on January 22, 2008, 10:56:35 pm
All right, and another Q...

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Text Database
#
#   This is your Text Database. Add any of the texts with a corresponding key.
#   Configure it like this template:
#
#   when KEY then return "TEXT"
#   
#   KEY  - a number
#   TEXT - the corresponding text
#   
#   The text will automatically be formatted.
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    when 0 then return "You haven't written anything in your journal yet!!"
    when 1 then return "The variable was changed to 1."
    when 2 then return "This text repeats itself. This text repeats itself!!"

So the # is actually the value of the variable that handles this script??
Title: Re: Journals
Post by: Nortos on January 22, 2008, 11:06:45 pm
yeah the default variable for that script is 10 and than you can either set it to whichever one you want for script or easiest way might just be make a common event that adds 1 to that variable and everytime you want a new entry you call that common event
Title: Re: Journals
Post by: Dark Dragon on January 23, 2008, 01:11:03 am
Yep and just in case you don't know :
you edit this global variable to change the text :
$game_variables[JOURNAL_VARIABLE_ID]
For example
Day1
$game_variables[JOURNAL_VARIABLE_ID] = 1
text = "I just killed my dog today"
Day2
$game_variables[JOURNAL_VARIABLE_ID] +=1
text = "I killed myself today"
Title: Re: Journals
Post by: Calintz on January 23, 2008, 02:13:58 am
I think I understand...That kinda makes it a condition, right??
Title: Re: Journals
Post by: Nortos on January 23, 2008, 02:29:16 am
I may as well just use Blizz's bestiary and edit that that would be a lot easier
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 06:31:43 am
My bad, it should be:

#   Call the scene with following syntax:
#   
#     $scene = Scene_Journal.new
#     
#   If you want to change the display, simply change the assigned variable's
#   value to the key corresponding to the given text.
#   

*edits post above*

@Calintz: Sure, you can use it. If you really have that much text so you need more pages, I can add that feature.
Title: Re: Journals
Post by: Nortos on January 23, 2008, 08:17:07 am
Calintz :( sorry I can't get it to work with event switches and text I'm a nub :P if you don't mind I'll post a copy and you just have the entry as an image or someone else can do it
Title: Re: Journals
Post by: Lost_Hope on January 23, 2008, 09:24:58 am
nvm...I kinda wanted it like KH but I still don't understand this shit...
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 10:02:48 am
(-_-')
Use a "Call Script" command and type "$scene = Scene_Journal.new". Make another event that increases Variable #10 by 1. Run the game and talk to the event with the call script command. Look at the text. Now end it and talk to the event that increases that variable. And now talk to the event with the script call command again. End the game, open the script editor and take a look at the configuration of the script. This script is easy to use, you're just lazy.
Title: Re: Journals
Post by: Fantasist on January 23, 2008, 10:08:22 am
slice_text... I still don't understand it when I see it... I really need it... i'm stupid... :cry:

j/k about cry, you're awesome Bliz :D
Title: Re: Journals
Post by: Lost_Hope on January 23, 2008, 12:39:51 pm
http://img242.imageshack.us/img242/3936/clipboard01fz7.jpg

Is it possible to put the journal command in with these commands in the menu???
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 02:52:19 pm
Sure, that's easy. Ok, let's put it below the Status option. Open your script editor and open Scene_Menu. Find this here:

    s5 = "Save"
    s6 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])


Change it to:

    s5 = 'Journal'
    s6 = 'Save'
    s7 = 'End Game'
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.height = 224


Now go further below and fine those lines here:

      when 4  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 5  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new


Change them to:

      when 4  # journal
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to journal screen
        $scene = Scene_Journal.new
      when 5  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 6  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new


That should do the job.
Title: Re: Journals
Post by: Calintz on January 23, 2008, 03:02:43 pm
Yeah Blizzard, I would really appreciate it if you would add the pages feature to this script...
- It's not so much that there may be soo much text, that it can't fit on the page, but I would like defferent pages for different
- areas in the game. I'm gonna have Blake fill info in the journal for every new place that he goes to, and I think it would be better organized if each place had it's own page.
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 03:05:32 pm
Oh, you want a journal that can display every of the old logs? No problem. I'll edit the script as soon as I can as this might take some more time to implement.
Title: Re: Journals
Post by: Calintz on January 23, 2008, 03:10:28 pm
Yeah...
Is that asking too much?

P.S. do you think you could add a center text feature?? Activated with = true/false ??
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 03:16:15 pm
Sure. It's like 1 little edit. In Window_JournalDisplay, where it says "draw_text", you need to add another argument after the string. Like
test[i]) -> text[i], 1)

and it will be centered.
Title: Re: Journals
Post by: Calintz on January 23, 2008, 03:22:46 pm
I'm not o sure I understand...

I know where you're talking about, but what exactly does that argument mean?? Is the actual text supposed to get placed in the spot??
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 03:32:14 pm
Find this line:

self.contents.draw_text(4, i*32, 600, 32, text[i])


and change it to

self.contents.draw_text(4, i*32, 600, 32, text[i], 1)


if you want the text to be centered.
Title: Re: Journals
Post by: Calintz on January 23, 2008, 03:34:12 pm
Yeah, I figured that out, Lol...
I tried to edit my post, but my CPU is gay sometimes, because UTorrent sucks on my bandwidth like a succubus!! Sometimes, I get errors until I pause all my downloads...
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 03:37:04 pm
Hey, it's better that it eats your bandwidth and downloads like crazy then eats your RAM and CPU like all the other BitTorrent clients. You can always set a download/upload limit, lol!
Title: Re: Journals
Post by: Calintz on January 23, 2008, 03:51:41 pm
Thats true, but I like having the things get done quick so.....
I normally do set the uplad limit to 10kb/sec, but I leave the download to unlimited...

Bah...I like to post stuff to, Lol...*drops max dwnld rate to 50kb/sec*... ;D
Title: Re: Journals
Post by: Nortos on January 23, 2008, 05:26:16 pm
hmm Blizz with pages would you just do the journal window.index and have each one working when the event switch is activated? I think I get it better it was 2am last night when I looked at it lol...
Title: Re: Journals
Post by: Calintz on January 23, 2008, 05:30:14 pm
Yeh, I think I would really like to be able to use pages in this script!! It would def. make it more useful.
Title: Re: Journals
Post by: Nortos on January 23, 2008, 06:47:28 pm
Blizz have you started the journal or should I bother cos if I do it would take a lot longer lol and I'm still not sure if on right track with .index and the event switches
Title: Re: Journals
Post by: Blizzard on January 23, 2008, 06:49:46 pm
Leave it to me. I'll do it ASAP.
Title: Re: Journals
Post by: Nortos on January 23, 2008, 07:15:53 pm
k I'll look at your code after than and see :)
Title: Re: Journals
Post by: Calintz on January 23, 2008, 09:28:24 pm
Thnx Blizz...
Title: Re: Journals
Post by: Blizzard on January 26, 2008, 09:07:16 am
Ok, I updated the script in the post on the first page to v2.0. Enjoy it. :)
Title: Re: Journals
Post by: Calintz on January 26, 2008, 12:24:28 pm
Checking it out now...   ;D

Edit
All right!! This is great Blizz....I know that they're not much, but I think that the Journal, TUT, and Journal viewer
s deserve a spot in the script databse, don't you??  :o
Title: Re: [RESOLVED] Journals
Post by: Subsonic_Noise on April 01, 2011, 05:22:50 am
Has this been made yet? I don't want to use the search function because I'm too sexy for that.