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

Touchscreen

Started by SSJVegetto, 09 January 2013 - 08:24 AM
SSJVegetto #1
Posted 09 January 2013 - 09:24 AM
Is anyone else having the same problems? Whenever i draw a line with paintutils on the Advanced Monitors it never draws it correctly and when using the os.pullEvents() i can see that the coordinates assigned are just completely off. it goed like this:

___________________________________________
| 1:14 | 10:1 |
| | |
| | |
| | |
| | |
| 9:64 | 19:6 |
|_____________________|_____________________|
| 1:76 | 10:7 |
| | |
| | |
| | |
| | |
| 9:13 | 9:12 |
|_____________________|_____________________|

Dit zijn dus 4 monitoren met de positie waarden van de hoeken. Doe ik nu wat fout of hoe kan dit?

Dit is de code:

local MonitorSide = "left"

function DrawGUI()
term.redirect(peripheral.wrap(MonitorSide))
paintutils.drawLine(10, 3, 12, 6, colors.blue)
paintutils.drawLine(9, 31, 7, 61, colors.blue)
term.restore()
end

DrawGUI()

while true do
term.redirect(peripheral.wrap(MonitorSide))
x = 0
y = 0
event, side, x, y = os.pullEvent()
if event == "monitor_touch" then
term.setCursorPos(1,1)
term.write(x .. ":" .. y)
end
end

Alright its all really inconsistent now it gives even coordinates of 200 or more so am i doing something wrong or is something wrong with the mod?

Groeten, Bob
Edited on 09 January 2013 - 08:29 AM
Cranium #2
Posted 09 January 2013 - 09:46 AM
You might want to put a space after your printing of the x and y.
term.write(x .. " :" .. y.." ") –add space so it only shows the single digits you select, and overwrites the old coordinates.