I wanted to know what the code is for detecting a touchscreen at certain points.
and is there a payment system that is currently working right now for computercraft?
local event, p1, p2, p3 = os.pullEvent()
if event == "monitor_touch" then
print("Side: " .. p1 .. " x: " .. p2 .. " y: " .. p3)
end
local event, p1, p2, p3 = os.pullEvent() if event == "monitor_touch" then print("Side: " .. p1 .. " x: " .. p2 .. " y: " .. p3) end
edit: you might want to put it in a loop
monitor = peripheral.wrap("right")
mside = "right"
local event, side, x, y = os.pullEvent()
local function writeGUI()
monitor.setCursorPos(1,1)
monitor.write("/ A / / B /")
monitor.setCursorPos(1,3)
monitor.write("Please press one")
end
local function clearScreen()
monitor.clear()
writeGUI()
end
clearScreen()
while true do
clearScreen()
if os.pullEvent() then
if event == "monitor_touch" then
if (x == 1 or x == 2 or x == 3 or x == 4 or x == 5 ) and y == 1 then
monitor.setCursorPos(1,4)
monitor.write("Stupid Shit")
sleep(1)
elseif (x == 13 or x == 10 or x == 11 or x == 12 or x == 9) and y == 1 then
monitor.setCursorPos(1,4)
monitor.write("Shit Stupid")
sleep(1)
end
else
monitor.setCursorPos(18, 3)
monitor.write("Program functioning.")
os.startTimer(2)
end
end
end
local function writeGUI()
monitor.setCursorPos(1,1)
monitor.write("/a/ /b/")
monitor.setCursorPos(1,2)
monitor.write("Select one")
end
local function clearScreen()
monitor.clear()
writeGUI()
end
monitor = peripheral.wrap(mside)
mside = "right"
while true do
clearScreen()
local event, side, x, y = os.pullEvent("monitor_touch")
os.pullEvent()
if event == "monitor_touch" then
if x == 1 or x == 2 or x == 3 then
if y == 1 then
monitor.setCursorPos(1,3)
monitor.write("Herbalife")
sleep(1)
end
elseif x == 5 or x == 6 or x == 7 then
if y == 1 then
monitor.setCursorPos(1,3)
monitor.write("But stud.")
sleep(1)
end
end
end
end