SHOW:
|
|
- or go back to the newest paste.
| 1 | - | while true do |
| 1 | + | local monitor = peripheral.wrap( "left" ) |
| 2 | - | event, side, xPos, yPos = os.pullEvent("monitor_touch")
|
| 2 | + | term.redirect(monitor) |
| 3 | - | print(event .. " => Side: " .. tostring(side) .. ", " .. |
| 3 | + | paintutils.drawPixel(3, 3 , colors.pink ) |
| 4 | - | "X: " .. tostring(xPos) .. ", " .. |
| 4 | + | |
| 5 | - | "Y: " .. tostring(yPos)) |
| 5 | + | touchEvents = {};
|
| 6 | - | end |
| 6 | + | |
| 7 | function getTouchEvents() | |
| 8 | while true do | |
| 9 | event, side, xPos, yPos = os.pullEvent("monitor_touch")
| |
| 10 | table.insert(touchEvents, tostring(xPos) .. tostring(yPos)) | |
| 11 | ||
| 12 | print(event .. " => Side: " .. tostring(side) .. ", " .. | |
| 13 | "X: " .. tostring(xPos) .. ", " .. | |
| 14 | "Y: " .. tostring(yPos)) | |
| 15 | end | |
| 16 | end | |
| 17 | ||
| 18 | function main() | |
| 19 | boolwert = true | |
| 20 | while boolwert do | |
| 21 | if table.getn(touchEvents ) > 0 then | |
| 22 | for k,v in pairs(touchEvents) do | |
| 23 | print(k, v) | |
| 24 | end | |
| 25 | ||
| 26 | turtle.drop(1) | |
| 27 | os.sleep(0.1) | |
| 28 | boolwert = false | |
| 29 | end | |
| 30 | end | |
| 31 | end | |
| 32 | ||
| 33 | parallel.waitForAny(getTouchEvents, main) |