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.

Coerced into Fixnum?

Im getting at error that one of my classes can't be coerced in a fixnum.
Let me show you what im trying to do.
Code:
class Check_Stuff
  def initialize
    check_stage
  end
  def check_stage
    if $game_party.item_number(1) >= 1
      @pik_numb = 1
    elsif$game_party.item_number(2) >= 1
      @pik_numb = 2
    end
    @p = @pik_numb
    pik_using
  end
  def pik_using
    return @p
  end
end

class Mining_Stuff
  def initialize
  end
  def mining_stage_one_a
    print "You swing your pick against the vein."
    p = Check_Stuff.new()
    @r = rand(100)
    if @r <= (15 + p)
      print "yay"
    else
      print "You swing your pick again"
      if @r <= 35
        print "yay"
      else
        print "You swing your pick again"
        if @r <= 45
          print "yay"
        else
          print "You swing your pick again"
          if @r <= 55
            print "yay"
          else
            print "nay"
          end
        end
      end
    end
  end
end
This is the error of course:
Code:
p = Check_Stuff.new()
    @r = rand(100)
    if @r <= (15 + p)
Can someone please tell me what im doing wrong? I'm way bigger steps into scripting then ever and the problems are getting more complicated, thanks!
 
Can someone please tell me what im doing wrong?

p needs to be a number, Check_Stuff is a class. If you wanted it's pik_using, you'd do it like this:

(15 + p.pik_using)

That said, you could code that much, much cleaner. Someone else will probably stop by with some advice. :)
 
Agreed, you would probably cry if you saw something else im working on, im trying desperatly to clean it, but worrying too much about making it work, anyways appreciate your help, thanks :D
 

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