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

touchpoint questions

Started by brainytwoo, 01 February 2017 - 02:33 AM
brainytwoo #1
Posted 01 February 2017 - 03:33 AM
Is there a way to use multiple monitors with this API?

Even though i somehow managed to fix the error i was getting, the original question still stands. Is there a way to get it to pull the touch event from more then one monitor?
I currently have two 4x8 monitors, an Induction matrix, 4 drac energy cores, 3 reactors, and 12 turbines connected via wired modems as a test setup. The program grab everything putting them in there assigned tables. Currently the program will give you as many buttons as you have turbines and they are each click-able and working. It will also give you a reactor button that does nothing at the moment as it is on a different monitor and I cannot figure out how to get touchpoint to pull events from multiple monitors. the reactor button should toggle if it registers a touch on it. If there is anyone that knows how to do this that would be great.

– Old
–I anyone is willing to help me that would be awesome.
–I am trying to make a great BigReactors program that uses this API. The problem is that I am new to CC and keep getting loads of errors that I don't understand but somehow
–manage to fix(most of the time). Currently I am getting an error with the name of my buttons or something – touchpoint:171: Expected string –. I am currently writing the code in
–parts as it makes it much easier to edit. Here is the pastebin for this specific part - http://pastebin.com/c3e4V0EJ - If you plan on going over the code on pastebin itself
–recommend getting a dark theme as the code is quite large for a sample code.

Good luck and thanks in advance to anyone willing to use their time to help me.
Edited on 01 February 2017 - 10:23 PM
Lupus590 #2
Posted 01 February 2017 - 09:01 PM
Is there a way to use multiple monitors with this API?

Even though i somehow managed to fix the error i was getting, the original question still stands. Is there a way to get it to pull the touch event from more then one monitor?
I currently have two 4x8 monitors, an Induction matrix, 4 drac energy cores, 3 reactors, and 12 turbines connected via wired modems as a test setup. The program grab everything putting them in there assigned tables. Currently the program will give you as many buttons as you have turbines and they are each click-able and working. It will also give you a reactor button that does nothing at the moment as it is on a different monitor and I cannot figure out how to get touchpoint to pull events from multiple monitors. the reactor button should toggle if it registers a touch on it. If there is anyone that knows how to do this that would be great.


Good luck and thanks in advance to anyone willing to use their time to help me.

I would use two touchpoint instances, one for each monitor and keep track of which one belongs to which monitor and effectively treat them separately from then on.

Monitors queue an event when clicked and that event tells you which monitor queue the event, which can then be used to figure out which touchpoint instance should process the event.
brainytwoo #3
Posted 01 February 2017 - 09:40 PM
Don't you need touchpoint to handle the event? – local event,click = touch:handleEvents(os.pullEvent()) – Also, why does it error out when you remove the "local" bit?

I will give it a shot when I get back if its not too late.

I am sorry about all the edits on my post, cant remove a post before someone sees it when it need to be verified first and your asleep when it finally does :P/>
Edited on 02 February 2017 - 02:04 AM
Bomb Bloke #4
Posted 01 February 2017 - 11:27 PM
Don't you need touchpoint to handle the event? – local event,click = touch:handleEvents(os.pullEvent())

The touchpoint instance you use either returns a modified event if it detects a click to its assigned display, or the original event if it doesn't. So to use multiple displays it's simply a case of passing the event data through each of them in turn:

os.loadAPI("touchpoint")

local t1 = touchpoint.new("top")
local t2 = touchpoint.new("bottom")

-- Add buttons, draw buttons...

while true do
  local event, p1, p2 = t1:handleEvents( t2:handleEvents( os.pullEvent() ) )

  if event == etc ...
brainytwoo #5
Posted 02 February 2017 - 03:03 AM
Wow, that is nothing compared to what I just did to make my own touch screen thing.
Mine basically just pulls the monitor the event happened on and scans a monitor specific table for the button that was touched.

Using toucpoint with that bit of code you gave there would be sooo much easier.

Thanks man!