Here is the full Code I have written yet:
mon = peripheral.wrap("top")
mon.setTextScale(0.5)
mon.setTextColor(colors.pink)
mon.setBackgroundColor(colors.pink)
mon.clear()
mon.setBackgroundColor(colors.black)
Buttons = 0
firstX = {}
firstY= {}
secondX = {}
secondY = {}
function writeButton(Name,x,y,Bg,Txt)
Buttons = Buttons+1
mon.setBackgroundColor(colors[Bg])
mon.setTextColor(colors[Txt])
mon.setCursorPos(x,y)
i = #Name
xt = x-1
yt = y-1
firstX[""..Buttons..""] = xt
firstY[""..Buttons..""] = yt
while i>0 do
mon.write(" ")
i = i-1
end
y = y+1
mon.setCursorPos(x,y)
mon.write(Name)
y = y+1
mon.setCursorPos(x,y)
i = #Name
while i>0 do
mon.write(" ")
i = i-1
end
xt = x+1
yt = y+1
secondX[""..Buttons..""] = xt
secondY[""..Buttons..""] = yt
end
function Feedback() -- Kommt noch
end
writeButton(" Haupttor ",3,2,"black","pink")
writeButton(" Hintertor ",21,2,"black","pink")
writeButton(" Maschinenraum ",39,2,"black","pink")
writeButton(" Yoshi ",3,6,"black","pink")
writeButton(" Reaktortor ",21,6,"black","pink")
mon.setBackgroundColor(colors.black)
mon.setCursorPos(1,10)
mon.write(" ")
while true do
event,top,x,y=os.pullEvent("monitor_touch")
if x>firstX[1] and x<secondX[1] and y>firstY[1] and y<secondY[1] then
writeButton(" Nein ",2,2,"yellow","red")
end
end
I am coding LUA since yesterday so don't be mad at me if it looks confusing.
Is your Touchpoint API usable in Multiplayer too?
//Edit: I didnt want to use your APIs because I am not that far into ComputerCraft so I want to learn more myself.
To finish that little Project I made That pretty long but basic Code.
Spoiler
mon = peripheral.wrap("top")
mon.setTextScale(0.5)
mon.setTextColor(colors.pink)
mon.setBackgroundColor(colors.pink)
mon.clear()
mon.setBackgroundColor(colors.black)
Buttons = 0
firstX = {}
firstY= {}
secondX = {}
secondY = {}
B1 = 1
B2 = 1
B3 = 1
B4 = 1
B5 = 1
function writeButton(Name,x,y,Bg,Txt)
Buttons = Buttons+1
mon.setBackgroundColor(colors[Bg])
mon.setTextColor(colors[Txt])
mon.setCursorPos(x,y)
i = #Name
while i>0 do
mon.write(" ")
i = i-1
end
y = y+1
mon.setCursorPos(x,y)
mon.write(Name)
y = y+1
mon.setCursorPos(x,y)
i = #Name
while i>0 do
mon.write(" ")
i = i-1
end
end
writeButton(" Haupttor ",3,2,"black","pink")
writeButton(" Hintertor ",21,2,"black","pink")
writeButton(" Maschinenraum ",39,2,"black","pink")
writeButton(" Yoshi ",3,6,"black","pink")
writeButton(" Reaktortor ",21,6,"black","pink")
mon.setBackgroundColor(colors.black)
mon.setCursorPos(1,10)
mon.write(" ")
while true do
event,top,x,y=os.pullEvent("monitor_touch")
if x>2 and x<20 and y>1 and y<5 then
if B1==1 then
writeButton(" Haupttor ",3,2,"gray","pink")
B1 = 0
else
writeButton(" Haupttor ",3,2,"black","pink")
B1 = 1
end
elseif x>20 and x<38 and y>1 and y<5 then
if B2==1 then
writeButton(" Hintertor ",21,2,"gray","pink")
B2 = 0
else
writeButton(" Hintertor ",21,2,"black","pink")
B2 = 1
end
elseif x>38 and x<46 and y>1 and y<5 then
if B3==1 then
writeButton(" Maschinenraum ",39,2,"gray","pink")
B3 = 0
else
writeButton(" Maschinenraum ",39,2,"black","pink")
B3 = 1
end
elseif x>2 and x<20 and y>5 and y<9 then
if B4==1 then
writeButton(" Yoshi ",3,6,"gray","pink")
B4 = 0
else
writeButton(" Yoshi ",3,6,"black","pink")
B4 = 1
end
elseif x>20 and x<38 and y>5 and y<9 then
if B5==1 then
writeButton(" Reaktortor ",21,6,"gray","pink")
B5 = 0
else
writeButton(" Reaktortor ",21,6,"black","pink")
B5 = 1
end
end
end