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.

Strange array problem

Description in the code.

Code:
class Improved_BD

 This is a improved bd that the game will acces later.

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

  # * Object Initialization

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

  attr_reader :crit_rate 

 

  def initialize

    # Create crit rate array

    @crit_rate = []

    define_crit_rate

  end

  

  def define_crit_rate

    actors = []

    classes = []

    weapons = []

    armors = []

    game_variables = []

 

    #----------Define your values here/Define los valores aqui------

    # By actor/Por personaje

    actors[1] = 5

    

    # By class/Por clase

    classes[1] = 66

 

    # By weapons/Por armas   

    weapons[1] = 19

    

    # By armors/Por armadras  

    armors[1] = 1

    

    # Game variables

    #game_variables.push(ID)

 

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

    @crit_rate.push(actors)

    @crit_rate.push(classes)

    @crit_rate.push(weapons)

    @crit_rate.push(armors)

    @crit_rate.push(game_variables)

  end

end

 

In scene Title:

 

    # Make each type of game object

    $improved_bd        = Improved_BD.new

    

Then i look for the stored information:

    

class Game_Actor < Game_Battler

 

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

  # * Calculate critical rate/Calcular critico

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

  def crit_rate

    var = super()

 

    # Check everytime that the value exist

    if $improved_bd.crit_rate[0[@actor_id]] != nil

      var += $improved_bd.crit_rate[0[@actor_id]]

    end

    

The error(line63) im having is that it tells me that is an array and not a fixnum, why?
 
This is your way
Code:
array = []

array[0] = [1]

p array[0[0]]
Return value "[1]"

My way
Code:
array = []

array[0] = [1]

p array[0][0]
Return value "1"

See the difference? You just have your brackets misplaced
 

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