Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w, h = term.getSize()
- local nastaveni={barva=colors.blue}
- local f=fs.open("/C/system/.core/colors","r")
- local cnt=f.readAll()
- f.close()
- local nastaveni=textutils.unserialize(cnt)
- local f=fs.open("/C/system/.core/textcol","r")
- local tnt=f.readAll()
- f.close()
- local text=textutils.unserialize(tnt)
- local function prc(text, y)
- local w = term.getSize()
- local _, cy = term.getCursorPos()
- term.setCursorPos(math.ceil((w-#text)/2), y or cy)
- write(text)
- end
- local f=fs.open("/C/system/RAM/user","r")
- user=f.readLine()
- f.close()
- local idTurtle = ""
- local connected = false
- local modem = peripheral.wrap('back')
- idPC = os.getComputerID()
- -- zamenit XXX
- function minimalizace ()
- if not fs.exists ("/C/system/.core/setting/mineditor") then
- shell.run ("pastebin get EiKMubhV /C/system/.core/setting/mineditor")
- minimalizace()
- end
- if fs.exists ("/C/system/RAM/"..user.."/RobotCon") then
- fs.delete ("/C/system/RAM/"..user.."/RobotCon")
- end
- local data = fs.open ("/C/system/RAM/"..user.."/RobotCon", "w")
- data.writeLine(funkce)
- data.close ()
- local data = fs.open ("/C/system/RAM/"..user.."/prlists", "w")
- data.writeLine ("RobotCon")
- data.close ()
- shell.run ("/C/system/.core/setting/mineditor")
- end
- function ukonceni ()
- fs.delete ("/C/system/RAM/RobotCon")
- shell.run("/C/system/api/closeApp")
- end
- function resus ()
- if fs.exists ("/C/system/RAM/RobotCon") then
- local data = fs.open ("/C/system/RAM/RobotCon", "r")
- local funkce = data.readLine ()
- data.close ()
- local myFuncs = {
- ["setting"] = function()
- setting ()
- end,
- }
- myFuncs[funkce]()
- menu ()
- end
- end
- function start ()
- resus ()
- modem.open(idPC)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear ()
- if not fs.exists ("/C/Programs/PepekSoft/RobotCon.nft") then
- shell.run("pastebin get a4pju742 /C/Programs/PepekSoft/RobotCon.nft")
- end
- local image = paintutils.loadImage("/C/Programs/PepekSoft/RobotCon.nft")
- paintutils.drawImage(image, w/2-7, 4)
- prc ("Robot Control", 16)
- sleep (1)
- menu ()
- end
- function prijem()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- timerRX = os.startTimer(2)
- while true do
- local event,p1,p2,p3,p4 = os.pullEvent()
- if event == ("modem_message") then
- if (p3 == 1) then
- term.setCursorPos(1,1)
- term.write(p4)
- if (p4 == "ok") then
- connected = true
- else
- connected = false
- end
- return
- end
- elseif event == "timer" then
- if p1 >= timerRX then
- term.setCursorPos(5,12)
- write"error - timer out"
- connected = true
- sleep(1)
- return
- end
- end
- end
- end
- function menu()
- term.setBackgroundColor(colors.white)
- term.clear ()
- if connected then
- term.setTextColor(colors.green)
- term.setCursorPos(13,4)
- write"Connected "
- else
- term.setTextColor(colors.red)
- term.setCursorPos(13,4)
- write"Disconected"
- end
- term.setTextColor(colors.black)
- term.setCursorPos(2,2)
- write"Turtle ID: "
- term.setCursorPos(2,4)
- write "Status: "
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(13,2)
- write " "
- term.setCursorPos(13,2)
- write (idTurtle)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos(19,2)
- write " Connect "
- term.setCursorPos(2,18)
- write" Setting "
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.blue)
- term.setCursorPos(w/2-5,h-1)
- write " Pepek"
- term.setCursorPos(w/2+3,h-1)
- write "Soft "
- term.setCursorPos(w/2+2,h-1)
- term.setTextColor(colors.lime)
- write "@"
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(10,8)
- write"<"
- term.setCursorPos(16,8)
- write">"
- term.setCursorPos(13,6)
- write"^"
- term.setCursorPos(13,10)
- write"V"
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if x >= 2 and x <= 12 and y == 18 and button == 1 then
- setting()
- elseif x == 13 and y == 6 and button == 1 then
- modem.transmit(tonumber(idTurtle),2,"forward")
- elseif x == 13 and y == 10 and button == 1 then
- modem.transmit(tonumber(idTurtle),2,"back")
- elseif x == 16 and y == 8 and button == 1 then
- modem.transmit(tonumber(idTurtle),2,"right")
- elseif x == 10 and y == 8 and button == 1 then
- modem.transmit(tonumber(idTurtle),2,"left")
- elseif x >= 13 and x <= 17 and y == 2 and button == 1 then
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos(13,2)
- write " "
- term.setCursorPos(13,2)
- idTurtle = read()
- menu()
- elseif x >= 19 and x <= 27 and y == 2 and button == 1 then
- modem.transmit(tonumber(idTurtle),1,idPC)
- prijem()
- menu()
- elseif x >= 5 and x <= 14 and y == 13 and button == 1 then
- elseif x >= 5 and x <= 14 and y == 15 and button == 1 then
- elseif x >= 5 and x <= 14 and y == 17 and button == 1 then
- else
- paintutils.drawLine(1, 1, w, 1, colors.black)
- paintutils.drawPixel (w,1, colors.red)
- term.setCursorPos (w,1)
- term.setTextColor(text.barva)
- print "*"
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if x == w and y == 1 then
- ukonceni ()
- else
- menu()
- end
- end
- break
- end
- end
- end
- function editmenu()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.blue)
- term.setCursorPos(20,19)
- write" Pepek"
- term.setCursorPos(28,19)
- write"Soft "
- term.setCursorPos(27,19)
- term.setTextColor(colors.lime)
- write"@"
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if x >= 5 and x <= 28 and y == 7 and button == 1 then
- instalace = 1
- else
- paintutils.drawLine(1, 1, w, 1, colors.black)
- paintutils.drawPixel (w,1, colors.red)
- term.setTextColor(colors.white)
- term.setCursorPos (w,1)
- print "*"
- paintutils.drawPixel (w-1,1, colors.lightGray)
- term.setCursorPos (w-1,1)
- print "<"
- paintutils.drawPixel (49,1, colors.lightGray)
- term.setCursorPos (49,1)
- print "_"
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if x == w and y == 1 then
- ukonceni ()
- elseif x == w-1 and y == 1 then
- menud ()
- elseif x == 49 and y == 1 then
- minimalizace ()
- else
- editmenu()
- end
- end
- break
- end
- end
- end
- function setting()
- funkce = "setting"
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear ()
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.setCursorPos(5,7)
- write "Stranka 2"
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if x >= 5 and x <= 45 and y == 10 and button == 1 then
- elseif x >= 41 and x <= w and y == 18 and button == 1 then
- else
- paintutils.drawLine(1, 1, w, 1, colors.black)
- paintutils.drawPixel (w,1, colors.red)
- term.setTextColor(colors.white)
- term.setCursorPos (w,1)
- print "*"
- paintutils.drawPixel (w-1,1, colors.lightGray)
- term.setCursorPos (w-1,1)
- print "<"
- paintutils.drawPixel (49,1, colors.lightGray)
- term.setCursorPos (49,1)
- print "_"
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- xy = x..","..y
- if x == w and y == 1 then
- ukonceni ()
- elseif x == w-1 and y == 1 then
- menu () -- predchozi stranka
- elseif x == 49 and y == 1 then
- minimalizace ()
- else
- setting()
- end
- end
- end
- end
- end
- start ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement