Undefined method and i need some help

Hi, i’m a beginner in Ruby and i’m doing a really easy “game”.

My problem is that i want to test if the user press 1 then roll some
dices but i can’t use my method ><’

I join you the code and thank you for hepling

tot = 0
def rollDice
tot = 0
puts “You roll the dices”
d1 = rand(1…6)
puts “Dice 1: #{d1}”
d2 = rand(1…6)
puts “Dice 2: #{d2}”
d3 = rand(1…6)
puts “Dice #{d3}”
tot = d1 + d2 + d3
puts “Your score is #{tot}”
return tot
end

[some puts but not important for the coding ]

puts “Press 1 to play or 2 to leave”
value = gets.chomp
if value == “1”
s1 = self.rollDice
puts “Why it doesnt work :C #{s1}”

[i have a player class but its not important for the moment]
#player1 = Joueur.new(j1)
#player2 = Joueur.new(j2)

    #player1.score
    #player2.score
elsif value== "2"
    exit
end

up please

s1 = self.rollDice >>>> s1 = rollDice

I am ‘up’ enough ?

Regis d’Aubarede wrote in post #1185066:

s1 = self.rollDice >>>> s1 = rollDice

I am ‘up’ enough ?

It change nothing i still have the error with the method :confused:
But thank you for helping me

Jerome Jeje wrote in post #1185069:

Regis d’Aubarede wrote in post #1185066:

s1 = self.rollDice >>>> s1 = rollDice

I am ‘up’ enough ?

It change nothing i still have the error with the method :confused:
But thank you for helping me

http://pastebin.com/DiGV4nHC this is all my code

I have found the solution, the problem was i didn’t do a “static” method
but now i have modified my code and all work on purpose :smiley:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs