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.

Case Variable

Im trying to get this snippit to work but i get and error on this line "loot2 = rand($LOOT.size)"

Code:
  def gain_random_loot
   case $game_variables[2] 
    when 1
        $LOOT = [153, 154, 155, 156, 157, 158, 159]
    when 5
        $LOOT = [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]
   end
  loot2 = rand($LOOT.size)
  $game_party.gain_item($LOOT[loot2], 1)
  @help_window.set_text("You stole a " + $data_items[$LOOT[loot2]].name + "!", 1)
  loop do
    Graphics.update
    Input.update
    if Input.trigger?(Input::C)
      break
    end
  end
  $game_variables[2] += 1
  $scene = Scene_Map.new
end
 
maybe $game_variables[2]  == nil or != 1 && 5
you should try:
Code:
case $game_variables[2] 
    when 1
        $LOOT = [153, 154, 155, 156, 157, 158, 159]
    when 5
        $LOOT = [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]
    else
        $LOOT = []
end
 

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