This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
teunie_nl's profile picture

Button Menu

Started by teunie_nl, 16 December 2013 - 04:16 PM
teunie_nl #1
Posted 16 December 2013 - 05:16 PM
I'm fairly new to computercraft, but not very new to programming.
Still I'm struggling with ComputerCraft and making a touchscreen button menu.
I've tried the Touchpoint API from Lygyd but that didn't work:

print("Starting...")
os.loadAPI("touchpoint")
local t = touchpoint.new("right")
It's all saved on a disk in the same folder with touchpoint (API) and start in the directory.
Yet I can't figure out what I'm doing wrong, and most videos or topics I find are outdated.
Any help?
Lyqyd #2
Posted 16 December 2013 - 08:52 PM
Well, that bit of code is a good start, but it obviously won't do anything by itself. You've got to add some buttons and make it draw! Are you getting errors from that code?
teunie_nl #3
Posted 17 December 2013 - 10:39 AM
Yes, that is the problem.
Do I need to call a function?
Lyqyd #4
Posted 17 December 2013 - 11:31 AM
Yep. Check out the documentation in the topic. You'll want to call t:add() with the proper arguments to create some buttons and t:draw() to make them draw onto the screen, among other things. You'll have to create the program yourself, the Touchpoint API is simply designed to manage the buttons for you. You still have to create the buttons you want it to manage.
teunie_nl #5
Posted 17 December 2013 - 12:34 PM
I've tried http://pastebin.com/GnwK0Z4M
I'm getting this error:

File not found
Start:3: attempt to index ?
So that means the API can't be loaded because the file isn't found.
But it is in the same directory, so it should work right?

EDIT: to last post.
http://pastebin.com/RzGq92pV
Is the code I'm using, made a mistake there when posting
Lyqyd #6
Posted 17 December 2013 - 03:35 PM
As long as the Touchpoint API was in the root of the computer's drive, that would work. If you've put it in a folder on the computer (like it sounds like you have), you'd need to specify the path to the Touchpoint API file. For instance, if you put it in a folder named foo, you'd need to load it like this:


os.loadAPI("/foo/touchpoint")
teunie_nl #7
Posted 17 December 2013 - 03:44 PM
That solved the problem for me.
I was thinking it would access the file in the same folder as the file you are executing.
Thanks. :)/>
Bomb Bloke #8
Posted 17 December 2013 - 04:56 PM
You can work out what that folder is with shell.resolve(). For example:

os.loadAPI(shell.resolve(".").."/touchpoint")

… will load the API so long as it's in the folder you were in when starting the script (assuming that script doesn't further change the working directory).