PhoenixTilea
Member
Okay, someone PLEASE help before I rip out all my hair! T_T
This is going to be difficult to explain because I'm working on a system, but I'm going to try:
What I'm writing is a quest log system for my own use. (Yes, I know there are others out there, but I'm doing a simpler one). For testing purposes, I have a data structure set up that has 2 titles and descriptions already defined (elements 0 and 1 of their respective arrays.) Now, what this window is supposed to do is list the titles of the quests whose matching element in the array 'available' equal 1.
However, it's only printing the first title and not the second, even though elements 0 and 1 of the 'available' array both equal 1.
Here's my data structure:
Now, I know all the values of 'available' are set to 0, but during runtime, the method get_quest is called for element 1, so that data is changed during the game but doesn't seem to effect the @list array in Window_InProgress.
So... It's as if it's not performing the 'push' method even though element 1 should be added....
Does this make sense, or should I just put my entire system up here? Sorry it's not commented, btw...?
This is going to be difficult to explain because I'm working on a system, but I'm going to try:
What I'm writing is a quest log system for my own use. (Yes, I know there are others out there, but I'm doing a simpler one). For testing purposes, I have a data structure set up that has 2 titles and descriptions already defined (elements 0 and 1 of their respective arrays.) Now, what this window is supposed to do is list the titles of the quests whose matching element in the array 'available' equal 1.
Code:
Â
class Window_InProgress < Window_Selectable
 attr_accessor :list
 attr_accessor :data
Â
 def initialize(qtitles)
  super(100, 80, 300, 400)
  self.contents = Bitmap.new(width - 32, height - 32)
  self.opacity = 0
  @quests = $data_quests
  @titles = @quests.title
  @description = @quests.description
  @available = @quests.available
  @list = []
  @data = []
  @column_max = 1
  refresh
  self.index = 0
 end
Â
 def refresh
  self.contents.clear
  self.contents.font.color = Color.new(0,0,0,255)
  @list[0] = @titles[0]
  @data[0] = @description[0]
  for i in [email=1..@titles.size]1..@titles.size[/email] - 1
   if @available[i] == 1
    @list.push(@titles[i])
    @data.push(@description[i])
   end
  end
  @item_max = @list.size
  for i in 0..@item_max
   if @list[i] != nil
    draw_quest_title(i)
   end
  end
  return
 end
Â
 def draw_quest_title(index)
  self.contents.draw_text(0, (index)*32, 500, 32, @list[index])
 end
end
Â
However, it's only printing the first title and not the second, even though elements 0 and 1 of the 'available' array both equal 1.
Here's my data structure:
Code:
Â
class Data_Quest
 attr_accessor :title
 attr_accessor :description
 attr_accessor :available
Â
 def initialize
  @title = []
  @description = []
  @available = []
  #No Quest
  @title[0] = 'Nothing'
  @description[0] = ["Nothing to do at the moment..."]
  @available[0] = 1
  #Quest 1
  @title[1] = 'Wtf...?'
  @description[1] = ["Okay, so I'm supposed to take notes in here...",
            "Let's see... I don't know where I am...",
            "I can't find the others....",
            "And there's some weird mage dude that knows",
            "way more than he should....",
            "I guess I should just get to work on finding",
            "everyone else for now..."]
 Â
  for i in [email=1..@title.size]1..@title.size[/email] - 1
   @available[i] = 0
  end
 end
Â
 def get_quest(quest)
  @available[quest] = 1
 end
Â
 def complete(quest)
  @available[quest] = 0
  $data_quests2.complete(quest)
 end
end
Â
class Game_System
 alias quest_log update
 def update
  quest_log
  $data_quests = Data_Quest.new
 end
end
Â
Now, I know all the values of 'available' are set to 0, but during runtime, the method get_quest is called for element 1, so that data is changed during the game but doesn't seem to effect the @list array in Window_InProgress.
So... It's as if it's not performing the 'push' method even though element 1 should be added....
Does this make sense, or should I just put my entire system up here? Sorry it's not commented, btw...?