[RESOLVED] Journals

Started by Lost_Hope, January 22, 2008, 12:24:37 pm

Previous topic - Next topic

Lost_Hope

January 22, 2008, 12:24:37 pm Last Edit: July 25, 2008, 04:11:36 pm by Blizzard
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...

Blizzard

January 22, 2008, 12:49:05 pm #1 Last Edit: January 22, 2008, 12:49:44 pm by Blizzard
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?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Lost_Hope

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.

Blizzard

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?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Lost_Hope

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...

Blizzard

Give me 20 minutes. (The instructions need like 10. >.< )
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Lost_Hope

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...

Blizzard

January 22, 2008, 01:18:13 pm #7 Last Edit: January 26, 2008, 09:06:32 am by Blizzard
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
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Lost_Hope

this aint calintz I dont do sprites...i do ARTWORK

Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Dark Dragon

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...

Blizzard

January 22, 2008, 04:05:20 pm #11 Last Edit: January 22, 2008, 04:08:17 pm by Blizzard
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
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Dark Dragon

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 ?

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Lost_Hope

# 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...

Calintz

Do I have the ok to use this??

Lost_Hope

i guess...i dont know how to work it though...

Nortos

Here's a demo just open up the project and run it to see how it's done http://www.sendspace.com/file/dv7r0b

Calintz

I'll take a look at it, and if Blizz doesn't tell you first, I'll see if I can elaborate, kk??

Nortos

it's fine I just put up a demo for him