Jump to content




Button Menu

java computer

7 replies to this topic

#1 teunie_nl

  • Members
  • 4 posts

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?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,450 posts

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?

#3 teunie_nl

  • Members
  • 4 posts

Posted 17 December 2013 - 10:39 AM

Yes, that is the problem.
Do I need to call a function?

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,450 posts

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.

#5 teunie_nl

  • Members
  • 4 posts

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

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,450 posts

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")


#7 teunie_nl

  • Members
  • 4 posts

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. :)

#8 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

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).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users