Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Big hole in my array!

Aran

Member

For some reason the add_pet method won't permanately add anything to the @data array.  why?  does it have a big hole in it or something?

Code:
#===============================================================================
# ** Game_Petition
#-------------------------------------------------------------------------------
#
#===============================================================================
class Game_Petition
  
  def initialize
    @data = []
  end
  
  def add_pet(petner, gender, standpt)
    #petition = RPG::Petition.new
    #petition.name = petner
    #petition.gender = gender
    #petition.standpt = standpt
    #unless @data.include?(petner)
      @data.push(petner)
    #else
      #p "I've already signed your freakin' petition!"
    #end
    
  end
    
  def data
    return @data
  end
    
end
 

khmp

Sponsor

Why do you say its empty? I took the code you had right there and then had this right below the class definition. It works.

test = Game_Petition.new
test.add_pet('Monkey', 'Amazing', 'What?')
test.add_pet('Despain', 'Dude', 'Still no idea')
p test.data # ["Monkey", "Despain"]

Good luck with it Aran! :thumb:

By the way your sig is misspelled...
 

Aran

Member

?? why couldn't i do that from an event?

HEY, WAIT!! NEW PROBLEM
I'm not tryin to spam the forums with multiple support topics

new code:

Code:
#===============================================================================
# ** Window_RandomName_Select
#===============================================================================
class Window_RandomName_Select < Window_Selectable
  
  def initalize(width,commands)
    super(0,0,width,640)
    @item_max = commands.size
    @commands = commands
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.index = 0
  end
  
  def refresh
    self.contents.clear
    for i in 0...@item_max.size
      draw_item(i,normal_color)
    end
  end
  
   def draw_item(index, color)
    self.contents.font.color = Color.new(0, 0, 0, 255)
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  
end


#===============================================================================
# ** Scene_RandomThing
#===============================================================================
class Scene_RandomThing
  
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  
  def main
    ary = ["Bob","Jim","Sarah"]
    [b][color=red]@randselec_win = Window_RandomName_Select.new(160,ary)[/color][/b]
    @randselec_win.index = @menu_index
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      break if $scene != self
    end
    Graphics.freeze
    @randselec_win.dispose
  end
  
  def update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
  end
  
end


#===============================================================================
# ** Game_Map
#===============================================================================
class Game_Map
  
  alias rand_upd update
  
  def update
    rand_upd
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.buzzer_se)
      $scene = Scene_RandomThing.new
    end
    #rand_upd
  end
  
end
I get this error when I hit [Q] in the game:

Script '** Random' line 43: ArgumentError occured.
wrong number of arguments(2 for 4)
I'm only supposed to be passing two arguments into it. ???
 

khmp

Sponsor

Ok, you made the second mistake I made when I first came to this forum and that is... I misspelled initialize and searched forever for an error of grammar.

Code:
def initalize(width,commands)
is supposed to be:
Code:
def initialize(width,commands)

The reason you get that can not convert 4 to 2 error is because there was no initialize so it defaulted to Window_Selectable.initialize which takes 4 parameters.

Next error. In the refresh of your Window_RandomName_Select you have:
Code:
for i in 0...@item_max.size
is supposed to be:
Code:
for i in 0...@item_max

@item_max is an integer its size is 4 byte size perhaps? Anyway its supposed to just be @item_max.

Next error. In the update of Scene_RandomThing you don't have an update call for your window. So it just remains stagnant. So pop in a @randselec_win.update somewhere in there.

Next error. Change "class Game_Map" to "class Scene_Map" please. Not really an error just for the sake of not doing odd things in the RGSS.

There are other things but I think you can figure it out by just walking through it.

Good luck with it Aran! :thumb:
 

Aran

Member

wow!  thanx a whole lot khmp!  that was kinda embarassing on my part, but i needed it, i suppose =P. 

its slipped past me that .size returns an integer not an array.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top