3DS: How to display text in LövePotion
Note from Wololo: This tutorial on How to display text in LövePotion was initially published by /Talk member Daffy, as part of our monthly tutorial contest. Daffy won the December/January tutorial contest for the 3DS (a $10 PSN code) with this entry. You can find the original post here.
Index
- Introduction
- Raw Code
- Code Explanation
- Understanding love.graphics.print
- Conclusion
Introduction
This tutorial will teach you how to display text using LövePotion. To do so, you will need:
- Any text editor.
- A way to launch 3DS homebrew.
- LövePotion set and ready to go.
Raw Code
-- How to draw text
function love.draw()
love.graphics.setScreen("top")
love.graphics.print("Top screen.", 0, 0)
love.graphics.setScreen("bottom")
love.graphics.print("Bottom screen.", 0, 0)
end
Code Explanation
What you see below is a comment. Comments are ignored by LövePotion and are left there for various purposes, such as leaving personal notes. To leave a comment, two hyphens must be together before your text. This is required for every line of comment that is in your code.
-- How to draw text
This opens the function that draws to the screen.
function love.draw()
This sets the focus to the top screen.
love.graphics.setScreen("top")
This displays the given text in the given coordinates.
love.graphics.print("Top screen.", 0, 0)
This sets the focus to the bottom screen.
love.graphics.setScreen("bottom")
This displays the given text in the given coordinates.
love.graphics.print("Bottom screen.", 0, 0)
This closes the function.
end
Understanding love.graphics.print
To draw text on the screens, it is important that you first understand how love.graphics.print works.

The image above is the same resolution as the top screen of the 3DS. (X, Y) is where the text will be drawn. If I tell LövePotion love.graphics.print(“Text”, 10, 20 ), LövePotion will draw whatever is inside the quotes, in this case “Text”, on the (X, Y) coordinates that I gave it, here being (10, 20). Starting from (0, 0), LövePotion will move 10 pixels to the right, 20 pixels down, and will finally draw “Text”.

Know that you’re visually restricted to the resolution of the screen, 400×240 for the top and 320×240 for the bottom. If you use values greater or smaller than that of the resolution, part of the text may show cut off, or may not show at all. Here is an example where X is -15 and Y is 20.

To display text on the bottom screen, you can follow the same guide for the top screen, keeping in mind the resolution.



Conclusion
Open up any text editor and type what is in the Raw Code section of this tutorial. You are free to experiment and change things to your liking. Once everything is done, save it as main.lua instead of whateverthetextwouldnormallybe.txt, and place it in a directory where LövePotion can read it.
Boot LövePotion and that’s that for now.
Want a chance to win a $10 PSN Code and be featured on the blog with your own guide? Join our monthly tutorial contest here!
First, For winning this trophy I would like to thank myself and…..no-one else. I dd all this on my own to get here and become the “first” Champion, i worked hard to get here first to do this. So i congratulate myself! *pats back*
Vita hack continue?
The Vita scene is pretty dead/stagnant, very few people want to bother with it when there’s really no reason.
No it was me I thought of this! It was my idea and I was the first one to think of this. Its because im better than you!!!
Stupid question,
Why don’t we port ONS into 3DS?
These are perfect for last minute presents. All the different fishing techniques that is out there. For example, the standard process, in the industry, for distilling an oil may include high temperature and high pressure during distillation, to maximize yield. ‘The public perception of Monaco is often that it’s a glamourous football shirts cheap which is home to multi millionaires, the Monte Carlo casino and the Monaco Grand Prix – and that’s it’, say Tribune, who through their online presence
Excellent post. Keep writing such kind of information on your page.
Im really impressed by your blog.
Hey there, You have performed a great job. I’ll certainly
digg it and individually recommend to my friends.
I am confident they’ll be benefited from
this web site.