Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear( ... )
- shell.run("clear")
- end
- function cWrite(text,y)
- x = math.floor(#text/2)
- term.setCursorPos(x,y)
- term.write()
- end
- local function getFromHttp(url,path)
- local file = http.get(url)
- if file then
- file = file.readAll()
- h=fs.open(path,"w")
- h.write(file)
- h.close()
- else
- error("Github server is not aviable.")
- end
- end
- selected = false
- local c = 1
- xt,yt = term.getSize()
- xc = xt/2
- yc = yt/2
- function Cprint(txt,y)
- xt,yt = term.getSize()
- term.setCursorPos(xt / 2 - #txt / 2,tonumber(y))
- print(txt)
- end
- function slect1( ... )
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- Cprint("Install sender",yc-2)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- function slect2( ... )
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- Cprint("Install receiver",yc)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- function slect3( ... )
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- Cprint(" Exit ",yc+2)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- function unsall( ... )
- term.setTextColor(colors.gray)
- Cprint("Install sender",yc-2)
- Cprint("Install receiver",yc)
- Cprint(" Exit ",yc+2)
- end
- function InstSender( ... )
- clear()
- Cprint("Installing wr_connect...",yc)
- getFromHttp("https://raw.githubusercontent.com/JustGekto/CC-wireless-monitor/master/wr_connect","wr_connect")
- getFromHttp("https://raw.githubusercontent.com/JustGekto/CC-wireless-monitor/master/wr_monitor","wr_monitor")
- term.clear()
- Cprint("Installed wr_conect!",yc)
- os.pullEvent("char")
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- term.clear()
- selected = true
- return
- end
- function InstReceiver( ... )
- clear()
- Cprint("Installing wr_receiver...",yc)
- getFromHttp("https://raw.githubusercontent.com/JustGekto/CC-wireless-monitor/master/wr_receiver","wr_receiver")
- term.clear()
- Cprint("Installed wr_receiver!",yc)
- os.pullEvent("char")
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- term.clear()
- selected = true
- return
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.black)
- Cprint("Wireless monitor installer",yc-5)
- term.setTextColor(colors.gray)
- Cprint("Install sender",yc-2)
- Cprint("Install receiver",yc)
- Cprint(" Exit ",yc+2)
- slect1()
- while not selected do
- local event, code = os.pullEvent("key")
- if code == 208 then --down
- if c == 3 then
- c = 1
- else
- c = c+1
- end
- end
- if code == 200 then --up
- if c == 1 then
- c = 3
- else
- c = c-1
- end
- end
- if code == 28 then
- if c == 1 then
- InstSender()
- elseif c == 2 then
- InstReceiver()
- elseif c == 3 then
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- term.clear()
- return
- end
- end
- if c == 1 and not selected then
- unsall()
- slect1()
- end
- if c == 2 and not selected then
- unsall()
- slect2()
- end
- if c == 3 and not selected then
- unsall()
- slect3()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment