please help me, i've been trying to make the 'cash' variable go up and it wont budge, does anyone know how to fix this?
function love.load()
numberOne = 0
numberTwo = 0
numberThree = 0
cash = 0
timesSpun = 0
end
function love.update(dt)
if numberOne > 9 then
numberOne = 1
elseif numberTwo > 9 then
numberTwo = 1
elseif numberThree > 9 then
numberThree = 1
elseif numberOne == numberTwo == numberThree then
cash = cash + 1
end
end
function love.keypressed(key)
if key == "enter" then
timesSpun = timesSpun + 1
else
numberOne = numberOne + love.math.random(1, 10)
numberTwo = numberTwo + love.math.random(1, 10)
numberThree = numberThree + love.math.random(1, 10)
end
function love.draw()
love.graphics.print(cash, 10, 10)
love.graphics.print(numberOne, 200, 300)
love.graphics.print(numberTwo, 300, 300)
love.graphics.print(numberThree, 400, 300)
love.graphics.print("Press 'Enter' to Spin!", 400, 10)
end
end
Please help, im trying something
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Please help, im trying something
Please use [code]...[/code] tags for wrapping code. I've done it for you above.bachadoo wrote: ↑Mon Nov 22, 2021 3:02 am please help me, i've been trying to make the 'cash' variable go up and it wont budge, does anyone know how to fix this?Code: Select all
function love.load() numberOne = 0 numberTwo = 0 numberThree = 0 cash = 0 timesSpun = 0 end function love.update(dt) if numberOne > 9 then numberOne = 1 elseif numberTwo > 9 then numberTwo = 1 elseif numberThree > 9 then numberThree = 1 elseif numberOne == numberTwo == numberThree then cash = cash + 1 end end function love.keypressed(key) if key == "enter" then timesSpun = timesSpun + 1 else numberOne = numberOne + love.math.random(1, 10) numberTwo = numberTwo + love.math.random(1, 10) numberThree = numberThree + love.math.random(1, 10) end function love.draw() love.graphics.print(cash, 10, 10) love.graphics.print(numberOne, 200, 300) love.graphics.print(numberTwo, 300, 300) love.graphics.print(numberThree, 400, 300) love.graphics.print("Press 'Enter' to Spin!", 400, 10) end end
The main problem is this line:
Code: Select all
elseif numberOne == numberTwo == numberThree then
Code: Select all
elseif (numberOne == numberTwo) == numberThree then
Code: Select all
elseif numberOne == numberTwo and numberTwo == numberThree then
Code: Select all
...
else
numberOne = numberOne + love.math.random(1, 10)
numberTwo = numberTwo + love.math.random(1, 10)
numberThree = numberThree + love.math.random(1, 10)
end -- ***** this is the `end` that you need to insert
end
There will be more problems when those issues are fixed, but I leave them up to you
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests