New account registration is temporarily disabled.

SELECTING AN ITEM

Posts

Pages: 1
I'm having trouble with displaying the selected item. What's happening is that the window displays the item selected previously, not the item currently selected. For example:
1st iteration: Selected option 2, displays nil
2nd iteration: Selected option 1, displays option 2
3rd iteration: Selected option 5, displays option 1
4th iteration: Selected option 4, displays option 5
and so forth.
The item being displayed is the selected item from Window_PartyList, and is displayed on Window_Header2.
Please help me... T___T



#==============================================================================
# Class Scene_Fusion < Scene_MenuBase
# This class is for displaying the Fusion screen. All options should
# open the next screen, Scene_Fusion2
#==============================================================================
class Scene_Fusion < Scene_MenuBase
  def start
    super
    # Fusion 1
    @header1 = Window_Header.new(0, 0, Graphics.width, 132)
    @list1   = Window_PartyList.new(0, 132, Graphics.width)
    @list1.set_handler(:ok, method(:continue))
    @list1.set_handler(:cancel, method(:return_scene))
    # Fusion 2
    @header2 = Window_Header2.new(0, 0, Graphics.width, 132)
    @list2   = Window_PartyList2.new(0, 132, Graphics.width)
    @list2.set_handler(:ok, method(:continue))
    @list2.set_handler(:cancel, method(:return_scene))
    
    # Setup Fusion 1 as the start point
    @list1.activate # Activate the first list.
    @list2.deactivate # Deactivate the second list.
    @list2.hide
    @header2.hide   # Hide the second list and header.
  end
  
  def continue
    @list1.deactivate
    @list1.hide
    @header1.hide
    @list2.show
    $selected = @list1.selected
    @header2.show
    @list2.activate
  end
end

#==============================================================================
# Class Window_Header < Window_Base
# This class displays the options at the top.
#==============================================================================
class Window_Header < Window_Base
  def initialize(x, y, width, height)
    super
    self.opacity = 0
    draw_headers
    @opening = @closing = false
  end #def initialize
  def dispose
    contents.dispose unless disposed?
    super
  end #def dispose

  def draw_headers
    line_height = 16
    change_color(system_color)
    draw_text(30, 0, 250, line_height, "Select First Demon")
    draw_text(30, 40, 85, line_height, "Race")
    draw_text(120, 40, 85, line_height, "Name")
    draw_text(265, 40, 85, line_height, "LV")
    for i in 1..10
      eval("draw_text(300+(30*#{i-1}), 0, 30, 10, #{i})")
    end # for
    change_color(normal_color)
  end #def draw_headers
end #class Window_Header

#==============================================================================
# Class Window_Header2 < Window_Base
# This class displays the options at the top.
#==============================================================================
class Window_Header2 < Window_Base
  def initialize(x, y, width, height)
    super
    self.opacity = 0
    #$selected = $list1.selected
    draw_headers
    @opening = @closing = false
  end #def initialize
  
  def dispose
    contents.dispose unless disposed?
    super
  end #def dispose
  
  def draw_headers
    line_height = 16
    change_color(system_color)
    draw_text(30, 0, 250, line_height, "Select Second Demon")
    draw_text(400, 0, 300, line_height, $selected.class.name)
#   draw_text(450, 0, 300, line_height, $selected.level)
    draw_text(30, 40, 85, line_height, "Race")
    draw_text(120, 40, 85, line_height, "Name")
    draw_text(265, 40, 85, line_height, "LV")
    draw_text(420, 40, 85, line_height, "Result")
    change_color(normal_color)
  end #def draw_headers
end #class Window_Header2


#==============================================================================
# Class Window_PartyList < Window_Selectable
# This class displays the list of party members. Should not include the
# main actor. 
#==============================================================================
class Window_PartyList < Window_Selectable
  def initialize(x, y, width)
    super(x, y, width, Graphics.height - y)
    self.opacity = 0
    data = []
    self.index = 0 #Do not include the main actor!
    activate
    refresh
  end #def initialize

  def item_max
    @data ? @data.size : 1
  end #def item_max
    
  def make_item_list
    @data = $game_party.members.compact
    @data.delete_at(0) #Ensures that the first party member isn't bothered.
  end #def make_item_list
  
  def draw_item(index)
    line_height = 16
    item = @data[index]
    if item
      rect = item_rect_for_text(index)
      #draw_text(rect, item.id)
      draw_text_ex(0, rect.y, item.id)
      #draw_text_ex(rect.x + 15, rect.y, item.class.name)
      draw_text_ex(30, rect.y, item.class.name)
      #draw_text_ex(rect.x + 100, rect.y, item.name)
      draw_text_ex(120, rect.y, item.name)
      #draw_text_ex(rect.x + 180, rect.y, item.level)
      draw_text_ex(265, rect.y, item.level)
      for i in 1..10
        if index==i-1
          #If same actor, cannot be fused
          eval("draw_text(300+(30*#{i-1}), rect.y, 30, line_height, '-')")
        elsif item.class == @data[i-1].class
          #else if same class, cannot be fused
          eval("draw_text(300+(30*#{i-1}), rect.y, 30, line_height, 'No')")
        else
          #else, can be fused
          eval("draw_text(300+(30*#{i-1}), rect.y, 30, line_height, 'Yes')")
          #@data[i-1].set_handler(:ok, SceneManager.call(Scene_Fusion2))
        end #end if else

      end #end for
    end #end if
  end #def draw_item
  
  #def selected(value)
  #  @selected = value
  #end
  
  def refresh
    contents.clear
    make_item_list
    create_contents
    draw_all_items
  end #def refresh
  
  def selected
    #return @data[self.index]
    if @data[self.index]
      $selected = @data[1]
    else
      $selected = @data[self.index]
    end
  end #def selected
  
end #class Window_PartyList


#==============================================================================
# Class Window_PartyList2 < Window_Selectable
# This class displays the list of party members. Should not include the
# main actor. 
#==============================================================================
class Window_PartyList2 < Window_Selectable
  def initialize(x, y, width)
    super(x, y, width, Graphics.height - y)
    self.opacity = 0
    data = []
    #$resultClass = Table.new(37,37)
    $resultClass = []
    self.index = 0 #Do not include the main actor!
    initializeTable
    activate
    refresh
  end #def initialize
  
  def initializeTable
$resultClass[0] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
    #	Avatar
$resultClass[1] = [37, 6, 6, 22, 20, 24, 16, 14, 24, 30, 15, 32, 14, 19, 29, 29, 14, 5, 24, 9, 22, 5, 14, 29, 19, 34, 34, 5, 5, 22, 10, 31, 5, 20, 6]
#	Avian
$resultClass[2] = [6, 37, 15, 22, 11, 29, 11, 5, 29, 24, 6, 24, 3, 22, 6, 3, 25, 6, 23, 1, 22, 5, 7, 6, 11, 22, 24, 24, 32, 3, 1, 20, 22, 29, 25]
#	Beast
$resultClass[3] = [6, 15, 37, 11, 2, 1, 20, 19, 11, 11, 9, 29, 34, 1, 20, 34, 34, 29, 1, 30, 35, 2, 29, 15, 9, 1, 34, 14, 1, 9, 7, 7, 19, 16, 10]
#	Brute
$resultClass[4] = [22, 22, 11, 37, 22, 35, 25, 14, 25, 21, 3, 22, 34, 23, 6, 30, 13, 22, 11, 7, 11, 29, 14, 11, 22, 22, 14, 31, 3, 22, 17, 17, 30, 14, 11]
#	Deity
$resultClass[5] = [20, 11, 2, 22, 37, 24, 32, 24, 29, 22, 7, 31, 31, 22, 34, 9, 10, 22, 24, 31, 4, 9, 24, 22, 32, 31, 31, 26, 26, 22, 32, 31, 22, 30, 24]
#	Divine
$resultClass[6] = [24, 29, 1, 35, 24, 37, 10, 24, 1, 31, 24, 32, 14, 5, 7, 2, 29, 24, 9, 22, 22, 11, 24, 1, 29, 5, 13, 24, 24, 3, 5, 2, 19, 1, 29]
#	Dragon
$resultClass[7] = [16, 11, 20, 25, 32, 10, 37, 23, 10, 3, 16, 29, 29, 15, 10, 34, 29, 6, 9, 2, 22, 15, 14, 20, 11, 30, 14, 19, 34, 34, 16, 31, 23, 15, 1]
#	Entity
$resultClass[8] = [14, 5, 19, 14, 24, 24, 23, 37, 24, 22, 23, 5, 4, 23, 14, 5, 4, 31, 22, 31, 14, 14, 14, 5, 4, 1, 32, 5, 14, 26, 26, 31, 14, 4, 24]
#	Fairy
$resultClass[9] = [24, 29, 11, 25, 29, 1, 10, 24, 37, 6, 10, 11, 17, 4, 3, 20, 25, 15, 24, 16, 35, 32, 35, 34, 29, 16, 17, 19, 3, 3, 34, 30, 23, 2, 19]
#	Fallen
$resultClass[10] = [30, 24, 11, 21, 22, 31, 3, 22, 6, 37, 7, 15, 32, 32, 31, 9, 25, 31, 3, 3, 4, 20, 14, 11, 17, 32, 13, 23, 24, 2, 26, 2, 23, 7, 21]
#	Femme
$resultClass[11] = [15, 6, 9, 3, 7, 24, 16, 23, 10, 7, 37, 24, 34, 23, 30, 9, 13, 24, 23, 3, 34, 15, 22, 6, 21, 24, 13, 24, 10, 9, 34, 31, 22, 1, 4]
#	Fiend
$resultClass[12] = [32, 24, 29, 22, 31, 32, 29, 5, 11, 15, 24, 37, 32, 5, 5, 9, 32, 16, 24, 15, 7, 32, 24, 32, 29, 24, 31, 26, 24, 22, 26, 22, 22, 7, 32]
#	Foul
$resultClass[13] = [14, 3, 34, 34, 31, 14, 29, 4, 17, 32, 34, 32, 37, 30, 25, 34, 4, 32, 10, 16, 11, 34, 32, 32, 4, 31, 32, 10, 10, 34, 17, 17, 30, 3, 29]
#	Fury
$resultClass[14] = [19, 22, 1, 23, 22, 5, 15, 23, 4, 32, 23, 5, 30, 37, 23, 15, 30, 15, 22, 34, 11, 23, 32, 5, 23, 5, 22, 32, 22, 15, 5, 31, 5, 30, 19]
#	Genma
$resultClass[15] = [29, 6, 20, 6, 34, 7, 10, 14, 3, 31, 30, 5, 25, 23, 37, 6, 25, 5, 35, 2, 9, 29, 11, 3, 19, 24, 23, 24, 5, 1, 32, 22, 19, 32, 14]
#	Ghost
$resultClass[16] = [29, 3, 34, 30, 9, 2, 34, 5, 20, 9, 9, 9, 34, 15, 6, 37, 3, 11, 6, 10, 30, 32, 11, 32, 10, 30, 10, 5, 7, 15, 11, 5, 5, 30, 2]
#	Haunt
$resultClass[17] = [14, 25, 34, 13, 10, 29, 29, 4, 25, 25, 13, 32, 4, 30, 25, 3, 37, 29, 10, 16, 32, 34, 32, 11, 35, 31, 32, 4, 4, 34, 13, 10, 30, 21, 21]
#	Hero
$resultClass[18] = [5, 6, 29, 22, 22, 24, 6, 31, 15, 31, 24, 16, 32, 15, 5, 11, 29, 37, 5, 15, 22, 26, 24, 31, 31, 24, 31, 26, 5, 22, 29, 26, 6, 1, 29]
#	Holy
$resultClass[19] = [24, 23, 1, 11, 24, 9, 9, 22, 24, 3, 23, 24, 10, 22, 35, 6, 10, 5, 37, 1, 3, 23, 1, 6, 9, 28, 34, 6, 22, 9, 1, 10, 22, 9, 6]
#	Jaki
$resultClass[20] = [9, 1, 30, 7, 31, 22, 2, 31, 16, 3, 3, 15, 16, 34, 2, 10, 16, 15, 1, 37, 15, 15, 11, 11, 34, 22, 31, 31, 6, 34, 11, 15, 22, 7, 15]
#	Jirae
$resultClass[21] = [22, 22, 35, 11, 4, 22, 22, 14, 35, 4, 34, 7, 11, 11, 9, 30, 32, 22, 3, 15, 37, 29, 3, 23, 13, 22, 13, 5, 10, 9, 34, 17, 22, 32, 3]
#	Kishin
$resultClass[22] = [5, 5, 2, 29, 9, 11, 15, 14, 32, 20, 15, 32, 34, 23, 29, 32, 34, 26, 23, 15, 29, 37, 14, 30, 11, 24, 31, 6, 6, 26, 10, 20, 14, 16, 11]
#	Lady
$resultClass[23] = [14, 7, 29, 14, 24, 24, 14, 14, 35, 14, 22, 24, 32, 32, 11, 11, 32, 24, 1, 11, 3, 14, 37, 14, 22, 24, 22, 5, 11, 11, 24, 11, 22, 17, 25]
#	Megami
$resultClass[24] = [29, 6, 15, 11, 22, 1, 20, 5, 34, 11, 6, 32, 32, 5, 3, 32, 11, 31, 6, 11, 23, 30, 14, 37, 10, 32, 31, 5, 9, 2, 0, 26, 5, 9, 22]
#	Night
$resultClass[25] = [19, 11, 9, 22, 32, 29, 11, 4, 29, 17, 21, 29, 4, 23, 19, 10, 35, 31, 9, 34, 13, 11, 22, 10, 37, 32, 32, 10, 10, 34, 25, 23, 14, 35, 6]
#	Omega
$resultClass[26] = [34, 22, 1, 22, 31, 5, 30, 1, 16, 32, 24, 24, 31, 5, 24, 30, 31, 24, 28, 22, 22, 24, 24, 32, 32, 37, 32, 1, 22, 11, 5, 7, 22, 10, 10]
#	Raptor
$resultClass[27] = [34, 24, 34, 14, 31, 13, 14, 32, 17, 13, 13, 31, 32, 22, 23, 10, 32, 31, 34, 31, 13, 31, 22, 31, 32, 32, 37, 31, 13, 29, 14, 14, 5, 32, 17]
#	Seraph
$resultClass[28] = [5, 24, 14, 31, 26, 24, 19, 5, 19, 23, 24, 26, 10, 32, 24, 5, 4, 26, 6, 31, 5, 6, 5, 5, 10, 1, 31, 37, 0, 2, 10, 6, 22, 6, 24]
#	Snake
$resultClass[29] = [5, 32, 1, 3, 26, 24, 34, 14, 3, 24, 10, 24, 10, 22, 5, 7, 4, 5, 22, 6, 10, 6, 11, 9, 10, 22, 13, 0, 37, 22, 7, 5, 22, 30, 25]
#	Touki
$resultClass[30] = [22, 3, 9, 22, 22, 3, 34, 26, 3, 2, 9, 22, 34, 15, 1, 15, 34, 22, 9, 34, 9, 26, 11, 2, 34, 11, 29, 2, 22, 37, 29, 15, 26, 29, 3]
#	Tyrant
$resultClass[31] = [10, 1, 7, 17, 32, 5, 16, 26, 34, 26, 34, 26, 17, 5, 32, 11, 13, 29, 1, 11, 34, 10, 24, 0, 25, 5, 14, 10, 7, 29, 37, 5, 14, 20, 25]
#	Vile
$resultClass[32] = [31, 20, 7, 17, 31, 2, 31, 31, 30, 2, 31, 22, 17, 31, 22, 5, 10, 26, 10, 15, 17, 20, 11, 26, 23, 7, 14, 6, 5, 15, 5, 37, 22, 10, 21]
#	Wargod
$resultClass[33] = [5, 22, 19, 30, 22, 19, 23, 14, 23, 23, 22, 22, 30, 5, 19, 5, 30, 6, 22, 22, 22, 14, 22, 5, 14, 22, 5, 22, 22, 26, 14, 22, 37, 14, 14]
#	Wilder
$resultClass[34] = [20, 29, 16, 14, 30, 1, 15, 4, 2, 7, 1, 7, 3, 30, 32, 30, 21, 1, 9, 7, 32, 16, 17, 9, 35, 10, 32, 6, 30, 29, 20, 10, 14, 37, 3]
#	Yoma
$resultClass[35] = [6, 25, 10, 11, 24, 29, 1, 24, 19, 21, 4, 32, 29, 19, 14, 2, 21, 29, 6, 15, 3, 11, 25, 22, 6, 10, 17, 24, 25, 3, 25, 21, 14, 3, 37]
#	Elements
$resultClass[36] = [6, 25, 10, 11, 24, 29, 1, 24, 19, 21, 4, 32, 29, 19, 14, 2, 21, 29, 6, 15, 3, 11, 25, 22, 6, 10, 17, 24, 25, 3, 25, 21, 14, 3, 37]
  end
  
  def item_max
    @data ? @data.size : 1
  end #def item_max
    
  def make_item_list
    @data = $game_party.members.compact
    @data.delete_at(0) #Ensures that the first party member isn't bothered.
  end #def make_item_list
  
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect_for_text(index)
      draw_text(rect, item.id)
      draw_text_ex(rect.x + 15, rect.y, item.class.name)
      draw_text_ex(rect.x + 100, rect.y, item.name)
      draw_text_ex(rect.x + 180, rect.y, item.level)
      #Compute the resulting demon
      #draw_text_ex(rect.x + 350, rect.y, show_result(item.id, index))
#      @classid = $resultClass[$selected.class-1][item.class_id-1]
#      draw_text_ex(rect.x + 350, rect.y, $data_classes[@classid].name)
    end #end if
  end #def draw_item
  
  #should print out the resulting demon.
  #def show_result(item, index)
  #    return $resultClass[item][index]
  #end #show_result
  
  def refresh
    contents.clear
    make_item_list
    create_contents
    draw_all_items
  end #def refresh
  
  #set handler for showing the next screen
end #class Window_PartyList2
bump?
I just need to learn how to select an item and display it... T___T
Well, If I were you, I would take a look at the "Window_Selectable" class as you will get a better understanding of how a selection is made.

Also who made this script? Perhaps you should contact them for assistance. Actually upon further inspection, I'm going to assume you made this-- since it uses very "strange" syntax, such as defining global variables to store indexes.

Anyway, if you want a window to change its selection simply use the function: "select(i)", of course you would replace the "i" with whatever id of the index you wish to select.

Hopefully that helps, good luck!
Yeah, I'm the one who made this. I'm still trying to grasp the language. I've taken a look at the Window_Selectable class enough that I could get an item displayed... but it's somewhat delayed XD
Lol, I see-- yeah these things take time. Just keep practicing. Also, try downloading other scripts with similar functionality to see what they did, it always helped me!

Hmm... honestly, I'm not sure if there's something similar, but I'll go ahead and check. Hopefully I can pull this off so I can proceed with other things. :D
Pages: 1