How can I display a variable on screen?

I'm using a variable to keep track of money, but I'm unsure of how to convert that into text to display on the screen.

Using Lua you don't need to convert it

https://sdk.play.date/inside-playdate/#f-graphics.drawText

playdate.graphics.drawText(money, 200, 120)

You might want to format the output, like $12.34

playdate.graphics.drawText(string.format("$%2.2f", money), 200, 120)

These answers are a mix of Playdate SDK and Lua docs.

2 Likes

Thanks for the help, but how can I clear the text so it doesn't keep overlapping itself when the variable increases?

One way is to clear the screen at the start of the update function.

I suggest looking at the examples that are included with the SDK and/or reading the documentation "Inside Playdate".

1 Like