Module Hash Questions

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
So recently I picked back up scripting and I'm trying to build small, simple custom scripts for it. One of which is a Quest Log. Now, granted, I could use other people scripts to save time but this is a hurdle I want to cross myself. However, I cannot for the life of me figure out how to display the info in a hash from a module.

Here's my example:

Code:
module QuestList
    Quests = {}
    Quests[:questID01] = {
        :name => "Test Quest",
        :description => "This is a test quest.",
    }
end
[\code] 

Now what I want to do from here is to move it into a class that holds the values here based on which quest id is needed. I tried to decode both Vlue and ModernAlgebra's version of a quest script, but I cannot understand how they operate. Nor could I understand the quest script from Starfield. If anyone could help me figure out the direction I want to go to from here I'd be thankful. I have a fairly intermediate working knowledge of RGSS3, not so much Ruby in and of itself, so I would also like to see what I am missing here if anything.

Thank you for all the future help!
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
You mean, accessing the value like
Code:
QuestList::Quests[:questID01][:name]
QuestList::Quests[:questID01][:description]
I don't quite understand your question hmm....
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
Theo!!! Dude, I am a big fan of your games and scripts!!! Thank you for your feedback. Let me show you what I am trying to work with here.

Code:
module QuestSetup

  Quests = {}

  Quests[:questID01] = {

    :name => "Test Quest",

    :description => "This is a test quest",

  }

end


#==============================================================================

# ▼ Journal Scene

#------------------------------------------------------------------------------

#  This window appears when the Journal option is selected from the main menu.

#==============================================================================

class Journal < Scene_Base

  #--------------------------------------------------------------------------

  # ■ Start Processing

  #--------------------------------------------------------------------------

  def start

    super

    @questlist_window = QuestList_Window.new

    @questinfo_window = QuestInfo_Window.new

    create_background

  end

  #--------------------------------------------------------------------------

  # ■ Create Background

  #--------------------------------------------------------------------------

  def create_background

    @background_sprite = Sprite.new

    @background_sprite.bitmap = SceneManager.background_bitmap

    @background_sprite.color.set(16, 16, 16, 128)

  end

  #--------------------------------------------------------------------------

  # ■ Post-Start Processing

  #--------------------------------------------------------------------------

  def post_start

    super

  end

  #--------------------------------------------------------------------------

  # ■ Frame Update

  #--------------------------------------------------------------------------

  def update

    super()

    WEA::Core::play_sound(:cancel) if Input.trigger?(:B) # call sound effect from

                                                        # personal core script

    return_scene if Input.trigger?(:B)

  end

  #--------------------------------------------------------------------------

  # ■ Pre-Termination Processing

  #--------------------------------------------------------------------------

  def pre_terminate

  end

  #--------------------------------------------------------------------------

  # ■ Termination Processing

  #--------------------------------------------------------------------------

  def terminate

    super()

    @background_sprite.dispose

    @questlist_window.dispose

    @questinfo_window.dispose

  end

end # end Journal


#==============================================================================

# ▼ QuestList_Window

#------------------------------------------------------------------------------

#  This window displays the current found quests.

#==============================================================================

class QuestList_Window < Window_Base

  #--------------------------------------------------------------------------

  # ■ Initialize

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, (Graphics.width * 0.4), Graphics.height)

  end

  #--------------------------------------------------------------------------

  # ■ list_quests

  #--------------------------------------------------------------------------

  def list_quests

    # List the quests, both completed and active.

  end

end


#==============================================================================

# ▼ QuestList_Window

#------------------------------------------------------------------------------

#  This window displays the current found quests.

#==============================================================================

class QuestInfo_Window < Window_Base

  #--------------------------------------------------------------------------

  # ■ Initialize

  #--------------------------------------------------------------------------

  def initialize

    super(Graphics.width * 0.4, 0, (Graphics.width * 0.6), Graphics.height)

  end

  #--------------------------------------------------------------------------

  # ■ show_quest_description

  #--------------------------------------------------------------------------

  def show_quest_description

    # Show the hilghed quests description.

  end

end


#==============================================================================

# ▼ Window_MenuCommand

#------------------------------------------------------------------------------

#  This command window appears on the menu screen.

#==============================================================================

class Window_MenuCommand < Window_Command

  #--------------------------------------------------------------------------

  # ■ For Adding Original Commands

  #--------------------------------------------------------------------------

  alias :wyn_journal_wincmd_addcmd                    :add_original_commands  

  #--------------------------------------------------------------------------

  def add_original_commands

    wyn_journal_wincmd_addcmd # calls original method

    add_command("Journal", :journal, true)

  end

end # end Window_MenuCommand


#==============================================================================

# ▼ Scene_Menu

#------------------------------------------------------------------------------

#  This class performs the menu screen processing.

#==============================================================================

class Scene_Menu < Scene_MenuBase

  #--------------------------------------------------------------------------

  # ■ Create Command Window

  #--------------------------------------------------------------------------

  alias :wyn_journal_scenemenu_createcmdwindow        :create_command_window

  #--------------------------------------------------------------------------

  def create_command_window

    wyn_journal_scenemenu_createcmdwindow # calls original method

    @command_window.set_handler(:journal,  method(:command_journal))

  end

  #--------------------------------------------------------------------------

  # ■ Call Journal Scene

  #--------------------------------------------------------------------------

  def command_journal

    SceneManager.call(Journal)

  end

end # end Scene_Menu


#==============================================================================

# ▼ Game_Journal

#------------------------------------------------------------------------------

#  This class handles journal data. It saves all data related to the journal

# entires, both past descriptions and current objectives.

#==============================================================================

class Game_Journal

  #--------------------------------------------------------------------------

  # ■ Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor       :quest_id

  attr_accessor       :quest_name

  attr_accessor       :quest_description

  #--------------------------------------------------------------------------

  # ■ Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    # Initialize instance variables with info from module?

  end

end # end Game_Journal


#==============================================================================

# ▼ DataManager

#------------------------------------------------------------------------------

#  This module manages the database and game objects. Almost all of the

# global variables used by the game are initialized by this module.

#==============================================================================

module DataManager

    #------------------------------------------------------------------------

    # ■ Create Game Objects

    #--------------------------------------------------------------------------

    def self.create_game_objects

      $game_temp          = Game_Temp.new

      $game_system        = Game_System.new

      $game_timer         = Game_Timer.new

      $game_message       = Game_Message.new

      $game_switches      = Game_Switches.new

      $game_variables     = Game_Variables.new

      $game_self_switches = Game_SelfSwitches.new

      $game_actors        = Game_Actors.new

      $game_party         = Game_Party.new

      $game_troop         = Game_Troop.new

      $game_map           = Game_Map.new

      $game_player        = Game_Player.new

      $game_journal       = Game_Journal.new

    end

    #--------------------------------------------------------------------------

    # ■ Create Save Contents

    #--------------------------------------------------------------------------

    def self.make_save_contents

      contents = {}

      contents[:system]        = $game_system

      contents[:timer]         = $game_timer

      contents[:message]       = $game_message

      contents[:switches]      = $game_switches

      contents[:variables]     = $game_variables

      contents[:self_switches] = $game_self_switches

      contents[:actors]        = $game_actors

      contents[:party]         = $game_party

      contents[:troop]         = $game_troop

      contents[:map]           = $game_map

      contents[:player]        = $game_player

      contents[:journal]       = $game_journal

      contents

    end

    #--------------------------------------------------------------------------

    # ■ Extract Save Contents

    #--------------------------------------------------------------------------

    def self.extract_save_contents(contents)

      $game_system        = contents[:system]

      $game_timer         = contents[:timer]

      $game_message       = contents[:message]

      $game_switches      = contents[:switches]

      $game_variables     = contents[:variables]

      $game_self_switches = contents[:self_switches]

      $game_actors        = contents[:actors]

      $game_party         = contents[:party]

      $game_troop         = contents[:troop]

      $game_map           = contents[:map]

      $game_player        = contents[:player]

      $game_journal       = contents[:journal]

    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

  # Methods not added yet.

end

This is the current script I have to create a window that creates the scene to display the quests.

What I would like to know is how to get the info from the module to the Game_Journal class, and then saved/populated from the data manager. Additionally, I would like to know how to set up a method to activate/complete quests when they gotten/completed. I have been trying to figure this out for a few weeks now. I hope this helps a little more.[/code]
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
First, for a rule of thumb (or more preferable, "personally") do not necessarily create global variable of new game object and new save contents unless it's absolutely necessary (which I haven't really know the case). If you want a new Game_Journal instance, why not just putting it inside Game_System? Any new save contents can be made by using existing game object. For example
Code:
class Game_System
  <some alias method here>
  def initialize
    <call alias method>
    @journal = Game_Journal.new
  end
end
----------------
Second, while we are at it. I have no idea why would you need a Game_Journal. Are you plan to modify quest description and save it? If you have a database on QuestList::Quests, you don't need a new game object. What you save is the key / id of the quest. So my preferable approach would be
Code:
class Game_System
  attr_reader :quests
  <some alias method here>
  def initialize
    <call alias method>
    @quests = []
  end
end
Then if you want to add quest, you can use script call
Code:
$game_system.quests << :questID001
Maybe you can still use/create Game_Journal if you want to mark a quest as a complete, on going, canceled, or whatever you want
Then the structure would be different.
Code:
class Game_Journal
  #--------------------------------------------------------------------------
  # ■ Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor       :quest_id       # ID of the quest
  attr_accessor       :quest_state  # state of the quest
  #--------------------------------------------------------------------------
  # ■ Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Initialize instance variables with info from module?
  end
end # end Game_Journal
You don't need name and description variable since they will be pulled out of the quest list database. What you need is the state, for example 1 for on going quest, 2 for complete quest, 0 for failed / canceled quest, or so. It's the one that need to be saved in save contents. Not the name and descriptions

-----------------
Third, how to draw it on the window. We have the ID stored in $game_system.quests. Now fetch the information from the 'database'. How? for example, you want to draw description text.
Code:
class QuestInfo_Window < Window_Base
  #--------------------------------------------------------------------------
  # ■ Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(Graphics.width * 0.4, 0, (Graphics.width * 0.6), Graphics.height)
  end
  #--------------------------------------------------------------------------
  # ■ show_quest_description
  #--------------------------------------------------------------------------
  def show_quest_description(id)
    text = QuestList::Quests[id][:description]
    draw_text(........)
  end
end
How you pass the ID is up to you to decide.

Good luck!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I agree with Theo here, it's easier and safer to just add your new stuff as an instance variable of Game_System since it is already saved by default, this way you wont be needing to modify the data manager anymore.

Also, I would suggest that if you really want to modify the saved contents, just alias those methods instead of overwriting them. That would make them less susceptible to compatibility issues with other scripts that modify saved stuff.

And yeah, you can do this without the Game_Journal class.You can opt to just extend Theos idea of the @quest variable for game system and instead of just giving it the quest ID, you can instead give it an array which contains the ID and the state of the quest. You can also opt to just make the quest variable as a hash, use the quest ID as the key and just save the state

Code:
@quest ={} #instead of []

then to add a new quest

$game_system.quest[questID]=state
Then on your quest window, you just iterate thru the key,value pairs of the quest variable.
to determine the quests to show and their state, then use the ID(key) to get the name and description of that quest from your module

You can even initialize all quests with the "not yet obtained" state value at the start if you want, then just modify the state as you get them, complete them etc.
 
Last edited:

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
I agree with Theo here, it's easier and safer to just add your new stuff as an instance variable of Game_System since it is already saved by default, this way you wont be needing to modify the data manager anymore.

Also, I would suggest that if you really want to modify the saved contents, just alias those methods instead of overwriting them. That would make them less susceptible to compatibility issues with other scripts that modify saved stuff.

And yeah, you can do this without the Game_Journal class.You can opt to just extend Theos idea of the @quest variable for game system and instead of just giving it the quest ID, you can instead give it an array which contains the ID and the state of the quest. You can also opt to just make the quest variable as a hash, use the quest ID as the key and just save the state

Code:
@quest ={} #instead of []

then to add a new quest

$game_system.quest[questID]=state
Then on your quest window, you just iterate thru the key,value pairs of the quest variable.
to determine the quests to show and their state, then use the ID(key) to get the name and description of that quest from your module

You can even initialize all quests with the "not yet obtained" state value at the start if you want, then just modify the state as you get them, complete them etc.
how do you use the key, value iteration? thats a new one to me. and thank you both for your help!!!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Code:
Hash.each {|key,value| block}

or

Hash.each do |key,value|
  block
end
basically, if you call .each on a Hash it gives you the (key,value) pair unlike arrays which only give you the value

PS: If you want to know about what methods are available to the RGSS3 objects, I sugget reading the help file, it actually lists them down with explanations and sometimes samples too
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
sounds good. thank you. but i still don't quite understand the key, value thing? ist that just part of the syntax or is key and value like foo and bar, where they are just place holders for the values needed?

EDIT: Also, how do i set up the window where it lists the quests? like when i move the cursor up and down it lists the quest name? that was something else i don't understand. i know it doesn't have much to do with the hash issue, but working with input triggers is completely out of my wheelhouse.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Well, uhm, they arent values that are needed, they are the values given to you by the .each function. You can name them differently, but I personally prefer naming them key,value like the samples because they are descriptive.

Basically, the first object given by the .each method of a Hash is always the key, and the second is always the value stored in that key

on your case, for example lets use your Quests hash

Code:
QuestList::Quests.each do |key,value|
  p key #Prints the Key of the current Hash entry being iterated
  p value #Prints the values stored in key, namely the Hash containing :name and :description
  p value[:name] #Prints the value of name
end

#If we rename key,value they will still do the same thing

QuestList::Quests.each do |id,contents|
  p id #Prints the Key of the current hash entry being iterated
  p contents #Prints the values stored in key, namely the Hash containing :name and :description
  p contents[:name] #Prints the value of name
end
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
sounds good. thank you. but i still don't quite understand the key, value thing? ist that just part of the syntax or is key and value like foo and bar, where they are just place holders for the values needed?
Easy(?) way to learn. Throw this on your script editor, and don't forget to turn on the console
Code:
sum_hash = { :key1 => 1, :key2 => 2, :key3 => 3}
sum_hash.each do |key, val|
  p "#{key} -- #{val}"
end
It will print "key1 -- 1" and so on.

EDIT: Also, how do i set up the window where it lists the quests? like when i move the cursor up and down it lists the quest name? that was something else i don't understand. i know it doesn't have much to do with the hash issue, but working with input triggers is completely out of my wheelhouse.
Explaining this will require much time, but I suggest if you have time, try to understand how the default script is structured and why it structured that way. You might have no idea yet how the default script structure could teach you much better than trying to learn from someone's script. I've been there.

But for starter, you should have use Window_Selectable instead of Window_Base.
For learning leason, why not try to recreate selectable menu window first? breaking down the learning might help you. Instead of ambitiously want to create a quest system, first what you need to learn is to make a selectable window. Use placeholder variable like
Code:
menu = ["Potato", "Salad", "Meat"]
Or whatever you call it. Then you try to modify any existing selectable window to display those menu exactly with those text.
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
So ive spent the last 4 hours tinkering with window_selectable and I am more lost that a dyslexic man in Germany. XD I have no idea what I am missing. I can't for the life of me get that stupid array to print.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I think you'd want to look at a method in Window_Selectable called draw_items, iirc
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
I already found it, and I am already tinkering with it. Currently in trying to set up an array of quest ids in the class that draws the items. I currently am trying to relearn how to use arrays. XD I'm getting closer.
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
Ok, so here is my new issue.
I built a function to append each value in the quest module I built like so:
Code:
def build_list
  Setup::Quests.each do |key, value|
    @list << value[:name]
  end
end
Then I built the draw item function

Code:
def draw_item
  for element in @list do
    p @list[element]
  end
end
Then it throws an error right when I go to print the values in the array. At p @list[element] it says cannot convert string into integer. Why is it doing this?
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
First, @list is an array, and then you are doing

Code:
for element in @list
which actually returns the contents of the array and then you are trying to use those contents as the index
Code:
@list[element]

Thats basically like calling

@list[@list[index]]
basically "elements" in that case is already the value of value[:name] which is a string, that is why the error says cannot convert string to integer

If you are using "for" iterator, your code block should be simply,

Code:
for element in @list do
  p element
end
if you want to manually call the contents i.e. use @list[element]

you should be using

Code:
@list.each_index do |element|
  p @list[element]
end
basically if we have an array
Code:
test = []
test.push("a")
test.push("b")

for element in test do
  p element
end
#prints a
#prints b

test.each do |element|
  p element
end
#prints a
#prints b

test.each_index do |element|
  p test[element]
end
#prints a
#prints b
 
Last edited:

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
I finally understood what you guess were getting at today. I finally had that epiphany. XD thank you guys for being patient with me. But I finally have an idea on what I need to do now. XD
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
So I am trying to pass the quest I into the function like you showed theo, about showing the quest description, and I can't figure out how to pass a symbol as an argument. Any thoughts?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I don't have much time to fully explain that at the moment. But I will tell you the hint.
It's located in "def update_help" from Window_Selectable. Look at how other Window classes did that for more clue.
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
I already figured it out. :D like literally 10 min after I posted the question I figured our how to do it. Sad part is it was staring me in the face the whole time. I need to stop posting questions. XD cause its like as soon as I ask he question, I find the answer a few minutes later. XD but I will loop into update help though. Cause now I'm curious.
 

Wyn Wizard

Arcane Specialist
Veteran
Joined
Feb 23, 2013
Messages
979
Reaction score
80
First Language
English
Primarily Uses
RMVXA
So here is what I have thus far:

Code:
module Setup
  Quests = {}
  Quests[:questid01] = {
    :name => "So it begins.",
    :state => "Undescovered",
    :description => "The starting cliche quest to every adventure.",
  }
  #---------------------------------------------------------------------------
  # ■ Word Wrapper
  #---------------------------------------------------------------------------
  def self.word_wrapper(window, text)
    current_text_pos = 0
    for i in 0..(text.length - 1)
      if text[i] == "\n"
        current_text_pos = 0
        next
      end
      current_text_pos += window.text_size(text[i]).width
     
      if current_text_pos >= window.width - 32
        current_element = i
        while(text[current_element] != " ")
          break if current_element == 0
          current_element -= 1
        end
        temp_text = ""
        for j in 0..(text.length - 1)
          temp_text += text[j]
          temp_text += "\n" if j == current_element
        end 
        text = temp_text
        i = current_element
        current_text_pos = 0
      end 
    end 
    return text
  end # end word_wapper
end

#==============================================================================
# ▼ Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ■ Create Command Window
  #--------------------------------------------------------------------------
  alias :new_create_command_window         :create_command_window
  #--------------------------------------------------------------------------
  def create_command_window
    new_create_command_window # calls original method
    @command_window.set_handler(:test_scene,   method(:command_test))
  end
  #--------------------------------------------------------------------------
  # ■ Call Journal Scene
  #--------------------------------------------------------------------------
  def command_test
    SceneManager.call(Test)
  end
end # end Scene_Menu

#==============================================================================
# ▼ Window_MenuCommand
#------------------------------------------------------------------------------
#  This command window appears on the menu screen.
#==============================================================================
class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # ■ For Adding Original Commands
  #--------------------------------------------------------------------------
  alias :new_add_original_commands                     :add_original_commands   
  #--------------------------------------------------------------------------
  def add_original_commands
    new_add_original_commands # calls original method
    add_command("Test Scene", :test_scene, true)
  end
end # end Window_MenuCommand

#==============================================================================
# ▼ Journal Scene
#------------------------------------------------------------------------------
#  This window appears when the Journal option is selected from the main menu.
#==============================================================================
class Test < Scene_Base
  #--------------------------------------------------------------------------
  # ■ Start Processing
  #--------------------------------------------------------------------------
  def start
    super
    @questlist_window = Window_QuestList.new
    @questdescription_window = Window_DescriptionList.new
    create_background
  end
  #--------------------------------------------------------------------------
  # ■ Create Background
  #--------------------------------------------------------------------------
  def create_background
    @background_sprite = Sprite.new
    @background_sprite.bitmap = SceneManager.background_bitmap
    @background_sprite.color.set(16, 16, 16, 128)
  end
  #--------------------------------------------------------------------------
  # ■ Post-Start Processing
  #--------------------------------------------------------------------------
  def post_start
    super
  end
  #--------------------------------------------------------------------------
  # ■ Frame Update
  #--------------------------------------------------------------------------
  def update
    super()
    WEA::Core::play_sound(:cancel) if Input.trigger?(:B) # call sound effect from
                                                         # personal core script
    return_scene if Input.trigger?(:B)
  end
  #--------------------------------------------------------------------------
  # ■ Pre-Termination Processing
  #--------------------------------------------------------------------------
  def pre_terminate
  end
  #--------------------------------------------------------------------------
  # ■ Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super()
    @background_sprite.dispose
    @questlist_window.dispose
    @questdescription_window.dispose
  end
end # end Journal

#==============================================================================
# ▼ Window_DescriptionList
#------------------------------------------------------------------------------
#  Test class for quest description
#==============================================================================
class Window_DescriptionList < Window_Base
  #----------------------------------------------------------------------------
  # ■ Initialize
  #----------------------------------------------------------------------------
  def initialize
    super(Graphics.width * 0.4, 0, Graphics.width * 0.6, Graphics.height)
    build_description_list
  end
 
  def build_description_list
    Setup::Quests.each do |key, value|
      draw_quest_description(key)
    end
  end
 
  def draw_quest_description(quest_id)
    text = Setup::Quests[quest_id][:description]
    Setup::word_wrapper(self, text)
    draw_text_ex(0, 0, text)
  end
end

#==============================================================================
# ▼ Test Quest List Scene
#------------------------------------------------------------------------------
#  Test class for selectable quest list. Window_DescriptionList
#==============================================================================
class Window_QuestList < Window_Selectable
  #----------------------------------------------------------------------------
  # ■ Initialize
  #----------------------------------------------------------------------------
  def initialize
    super(0, 0, Graphics.width * 0.4, Graphics.height)
    @list = []
    build_list
    draw_item
  end
 
  def build_list
    Setup::Quests.each do|key, value|
      @list << value[:name]
    end
  end
 
  #--------------------------------------------------------------------------
  # ■ Draw Item
  #--------------------------------------------------------------------------
  def draw_item
    for element in @list do
      text = element
      draw_text_ex(0, 0, text)
    end
  end
end

#==============================================================================
# ▼ 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_reader   :quests

  #--------------------------------------------------------------------------
  # ■ Object Initialization
  #--------------------------------------------------------------------------
  alias :new_gamesystem_init                                      :initialize
  #--------------------------------------------------------------------------
  def initialize
    new_gamesystem_init
    @quests = []
    build_questid_list
  end
 
  #--------------------------------------------------------------------------
  # ■ build_questid_list *new method*
  #--------------------------------------------------------------------------
  def build_questid_list
    Setup::Quests.each do |key, value|
      @quests << key
    end
  end
end
But now my issue is that my word wrapper that I built won't wrap the description text in the window correctly. if you print the text the function returns to the screen it adds a "\n" right before the word "every" so it should move to the next line. however, it does not. Maybe I need to change the text size? Thoughts? BTW, how does one change text size anyhow?
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,569
Latest member
Shtelsky
Top