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

[Request] Simple Touch interface to toggle 2 Machines

Started by mongini12, 01 February 2014 - 08:30 PM
mongini12 #1
Posted 01 February 2014 - 09:30 PM
hey guys :D/>

im new to computercraft, and lua language too. so i hoped to get some help here.
i googled for tutorials, searched here in the forum, but nothing seems to tell me what i need to know.

i want to create a simple touch interface to turn my autospawner and grinder on and off.

i thought about something like this:



i hope its possible to click directly on "active" or "inactive" to enable or disable the spawner / grinder

the grinder is connected on the left side of the computer, Spawner on the right via simple red alloy wire. so the touch have to enable or disable the redstone signal like a lever.

Would somebody do me that favor and can write such a program for me?
Edited on 02 February 2014 - 11:16 AM
Lyqyd #2
Posted 01 February 2014 - 10:48 PM
Ask a Pro isn't really the section for program requests, we mostly help people fix or finish the code they currently have.
Final Approach #3
Posted 01 February 2014 - 10:55 PM
I can probably write it, but do you want it on a monitor?
mongini12 #4
Posted 02 February 2014 - 07:43 AM
@Final
Yes i got a 2x2 block sized monitor on top of the computer

@Lyqyd
if it dont fits in here its ok if you move it to the right section of the forum :)/>
Final Approach #5
Posted 02 February 2014 - 08:44 PM
@Final
Yes i got a 2x2 block sized monitor on top of the computer

@Lyqyd
if it dont fits in here its ok if you move it to the right section of the forum :)/>/>/>
OK.
btw, Can you make it 1x1 instead?
I can make a layout like this
————-
|S|P|A|W|N|E|R|
————-
| |O|N| |O|F|F| |
——————
Empty row
——————
G R I N D E R
—————–
O N O F F
Edited on 02 February 2014 - 07:48 PM
ingie #6
Posted 02 February 2014 - 09:05 PM
i'd suggest watching this: http://www.youtube.com/watch?v=1nuMDtmnEjg

you say you're new to lua and CC, but you didn't say you're new to programming, so that video should be pretty simple to follow…
you could quickly get something running with it even if it didn't work… once you get that far [because that will be fun, i assure you] then you could post what you have got so far to pastebin and people can help…

the problem with just asking for "this thing" is that your appreciation of the request may differ from everyone else's who reads what you need… of course, your need sounds pretty simple - but because of that, you should be able to work out from dire's video exactly how to implement his touch screen button api… and if you don't you'll have at least learnt something in the process - and that's the fun, right? ;)/>
surferpup #7
Posted 02 February 2014 - 09:21 PM
Touch screens are fairly straight forward, and very satisfying to complete when you figure it out. Essentially, what you need to know:
  • How do I communicate with the monitor? A: (myMonitor = peripheral.wrap("monitor_1") and using the term API
  • Can I draw something on the monitor? Sure – look at term API
  • What is an event -> see Event Basics by [member='Engineer']
  • How can I handle monitor_touch events? (what x-y coordinate was the monitor touched at and is it in the bounds of my button)?
  • Basic Redstone events -> see my tutorial on Redstone Basics.
  • If you are really new to ComputerCraft, see [member='Lyqyd']'s Computer Basics 1 and Computer Basics 2 tutorials.
  • For beginning Lua, see my tutorial Lua Basics -- Variable Scope, Code Blocks and Control Structures.
Finally, have fun. Post your actual code problems in Ask a Pro and somebody will help you.
mongini12 #8
Posted 03 February 2014 - 05:42 AM
@Final: i would like to have an optical indicator if its on or off. just like the pic i posted initially.

@ingi… i would like to use that API and the base of the program… the only thing i need to add is the Redstone signal if the button is toggled

@surferpup thanks for the links… hope i can get something out of it

EDIT: i got it. i took the Direwolf API and shortened the table of the main programm, added a getTable function in the API to read the activity status, and added a redstone string in the main programm… works fine :D/>
Edited on 03 February 2014 - 09:40 PM
surferpup #9
Posted 05 February 2014 - 02:17 PM
Since then, I posted a full answer for you in response to a similar question, and a few of us are writing a full tutorial: