Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size = {term.getSize()}
- function loadUI()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.lightGray)
- function grayBar()
- for i = 1,size[1]-1 do
- term.write(" ")
- end
- print(" ")
- end
- for i = 1,3 do
- grayBar()
- end
- title = "Smithernet Explorer 1.0"
- term.setTextColor(colors.lightBlue)
- term.setCursorPos((size[1]/2)-(#title/2),1)
- term.write(title)
- term.setCursorPos(2,2)
- term.setBackgroundColor(colors.gray)
- term.write(" Home ")
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- term.setBackgroundColor(colors.gray)
- term.write(" ")
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- term.setBackgroundColor(colors.gray)
- term.write(" Refresh ")
- term.setCursorPos(1,4)
- end
- if term.isColor() then
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setCursorPos(1,1)
- else
- term.clear()
- term.setCursorPos(1,1)
- end
- if not fs.exists("smithernetexplorer/cfg/config.cfg") then
- fs.makeDir("smithernetexplorer/cfg/")
- print("Thank you for purchasing your SMITHNET SERVER!")
- print("You will now be guided through the installation")
- size = {term.getSize()}
- for i = 1,size[1]-1 do
- term.write("-")
- end
- print("-")
- term.write("What side is the modem on? :: ")
- side = read()
- term.write("What number is the house?")
- housenumber = read()
- print("Thank you for configuring the SMITHNET SERVER!")
- file = fs.open("smithernetexplorer/cfg/config.cfg","w")
- t = {}
- t["side"] = side
- t["housenumber"] = tonumber(housenumber)
- file.write(textutils.serialize(t))
- file.close()
- end
- --Main Program loop
- config = fs.open("smithernetexplorer/cfg/config.cfg","r")
- tbl = textutils.unserialize(config.readAll())
- config.close()
- p = peripheral.wrap(tbl["side"])
- p.open(tbl["housenumber"])
- loadUI()
- while true do
- evnt = {os.pullEvent()}
- if evnt[1] == "mouse_click" then
- if evnt[4] == 2 then
- if evnt[3] > 8 and evnt[3] < 41 then
- term.setCursorPos(9,2)
- input = read()
- p.transmit(80,tbl["housenumber"],tbl["housenumber"]..":req:ws:"..input)
- evnt1 = {os.pullEvent("modem_message")}
- term.setCursorPos(1,4)
- term.setBackgroundColor(colors.white)
- for i = 1,size[2]-4 do
- for i = 1,size[1]-1 do
- term.write(" ")
- end
- print(" ")
- end
- term.setCursorPos(1,4)
- args = {}
- if string.match(evnt1[5],"\n") then
- for word in string.gmatch(evnt1[5], '(.-)\\n') do
- table.insert(args,word)
- end
- else
- args[1] = evnt1[5]
- end
- for i = 1,#args do
- print(args[i])
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement