How would I go about this?
I thought maybe I could have both monitors in an array but I don't know if this is possible.
function() return otherFunction(touch[i]) end
And then use unpack on this array inside a parallel.waitForAny() call.
os.loadAPI("touchpoint")
local function runButtons(t)
while true do
local event = {t:handleEvents()}
if event == "button_click" then
if t.buttonList[event[2]].func then
t.buttonList[event[2]].func()
end
end
end
end
--#Declare table monSides to contain either the side next to the computer, or the name of the monitor like "monitor_666"
local touch = {}
for a,v in ipairs(monSides) do
touch[a] = touchpoint.new(v)
end
--#Define your buttons here. As well as any functions they should run
local runTable = {}
for a,v in ipairs(touch) do
runTable[a] = function() return runButtons(touch[a]) end
end
parallel.waitForAny(unpack(runTable))
Coded it up on a whim because it was an interesting problem, mind you anything you want your buttons to do you have to code, but this 'should' allow for you to set up touchpoints on each monitor, as well as automatically handle buttons and running functions per buttons.From both monitors? It's possible yeah. Difficult given that Lyqyd didn't create an in built way to do so.
*snip*
--#Declare table monSides to contain either the side next to the computer, or the name of the monitor like "monitor_666"
monSides = {"monitor_0","monitor_1"}
local touch = {}
for a,v in ipairs(monSides) do
touch[a] = touchpoint.new(v)
end
--#Define your buttons here. As well as any functions they should run
local runTable ={add("b1", t:flash(event[2]),1,1,4,1,colours.red,colours.lime)
}
for a,v in ipairs(touch) do
runTable[a] = function() return runButtons(touch[a]) end
end
parallel.waitForAny(unpack(runTable))
function() touch[number]:flash("b1") end
touch[1]:add("b1",function() touch[1]:flash("b1") end,1,1,4,1,colors.red,colors.llime)
--#Declare table monSides to contain either the side next to the computer, or the name of the monitor like "monitor_666"
local monSides = {"monitor_0","monitor_1"}
local touch = {}
for a,v in ipairs(monSides) do
touch[a] = touchpoint.new(v)
end
--#Define your buttons here. As well as any functions they should run
--#This loop adds and draws buttons to all screens
for a,v in ipairs(monSides) do
touch[a]:add("b1",function() touch[a]:flash("b1") end,1,1,4,3,colors.red,colors.lime)
touch[a]:draw()
end
local runTable ={}
for a,v in ipairs(touch) do
runTable[a] = function() return runButtons(touch[a]) end
end
parallel.waitForAny(unpack(runTable))
os.loadAPI("touchpoint")
local function runButtons(t)
while true do
local event = {t:handleEvents()}
if event == "button_click" then
if t.buttonList[event[2]].func then
t.buttonList[event[2]].func(t,event[2])
end
end
end
end
--#Declare table monSides to contain either the side next to the computer, or the name of the monitor like "monitor_666"
local monSides = {"monitor_0","monitor_1"}
local touch = {}
for a,v in ipairs(monSides) do
touch[a] = touchpoint.new(v)
end
--#Define your buttons here. As well as any functions they should run
--#This loop adds and draws buttons to all screens
for a,v in ipairs(monSides) do
touch[a]:add("b1",function(self,param1) self:flash(param1) end,1,1,4,3,colors.red,colors.lime)
touch[a]:draw()
end
local runTable ={}
for a,v in ipairs(touch) do
runTable[a] = function() return runButtons(touch[a]) end
end
parallel.waitForAny(unpack(runTable))
os.loadAPI("touchpoint")
local function runButtons(t)
while true do
local event = {t:handleEvents()}
if event == "button_click" then
if t.buttonList[event[2]].func then
t.buttonList[event[2]].func(t,event[2])
end
end
end
end
--#Declare table monSides to contain either the side next to the computer, or the name of the monitor like "monitor_666"
local monSides = {"monitor_0","monitor_1","term"}
local touch = {}
for a,v in ipairs(monSides) do
touch[a] = touchpoint.new(v)
end
--#Define your buttons here. As well as any functions they should run
--#This loop adds and draws buttons to all screens
for a,v in ipairs(monSides) do
touch[a]:add("b1",function(self,param1) self:flash(param1) end,1,1,4,3,colors.red,colors.lime)
touch[a]:draw()
end
local runTable = {}
for a,v in ipairs(touch) do
runTable[a] = function() return runButtons(touch[a]) end
end
parallel.waitForAny(unpack(runTable))
if event[1] == "button_click" then
Lol, I screwed up in the runButtons function.
On the if statement inside the runButtons function, add [1] after event.if event[1] == "button_click" then
os.loadAPI("touchpoint")
local function runButtons(t)
while true do
local event = {t:handleEvents()}
if event[1] == "button_click" then
if t.buttonList[event[2]].func then
t.buttonList[event[2]].func(t,event[2])
end
end
end
end
--#Declare table monSides to contain either the side next to the computer, or the name of the monitor like "monitor_0"
local monSides = {"monitor_0","monitor_1","term"}
local touch = {}
for a,v in ipairs(monSides) do
touch[a] = touchpoint.new(v)
end
--#Define your buttons here. As well as any functions they should run
--#This loop adds and draws buttons to all screens
for a,v in ipairs(monSides) do
touch[a]:add("b1",function(self,param1) self:flash(param1) end,1,1,4,3,colors.red,colors.lime)
touch[a]:add("b2",function(self,param1) self:flash(param1) end,5,1,9,3,colors.red,colors.lime)
touch[a]:draw()
end
local runTable = {}
for a,v in ipairs(touch) do
runTable[a] = function() return runButtons(touch[a]) end
end
parallel.waitForAny(unpack(runTable))