Well, that's because in the button actions action
increases the variable chips
and not cookies
, which is what is used for points, so in initUI
, you must change chips
to global.cookies
in the line that I indicate (And set it to increase points, that is, += 1
)
initUI = function()
buttons = []
buttons.push(
object
x = -90
y = -50
width = 80
height = 25
text = "cookie!"
action = function () chips +=0 end <-- (HERE, Also put += 1)
...
Something like that:
initUI = function()
buttons = []
buttons.push(
object
x = -90
y = -50
width = 80
height = 25
text = "cookie!"
action = function () global.cookies +=1 end
scale = 1
alpha = 1
end
)
end
This is because in the line where it draws the number of clicks or cookies, it uses the variable cookies
draw = function()
screen.clear()
screen.drawMap("map", x+0, y+0, 400,200)
screen.drawSprite("basicshopbutton", x+100, y+35, 200,125)
screen.drawSprite("basicshopbutton", x+100, y-20, 200,125)
screen.drawSprite("basicshopbutton", x+100, y-75, 200,125)
screen.drawSprite("chocolatechip", x-150, y+80, 25,25)
screen.drawSprite("shopimage", x+100, y+85,75,75)
screen.drawText("Chips: " + cookies, -75, +80, 30, "#FFFFFF") <-- (HERE)
...
Another solution is to change the cookies
to chips
and set it to change global.chips
, since if you don't set it to global
, it won't modify it