Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Modem
- local Drive
- local ID
- local Key
- local Company
- local Client
- local EndTime = 0
- local V = "1.0"
- local SCh
- local LCh
- local function StopProgram()
- print("stopping terminal . . .")
- os.shutdown()
- end
- local function RunDrive()
- local Path
- if Drive.isPresent() then Path = Drive.getMethod() end
- if fs.exists(Path.."/BoxDetails.txt") then fs.copy(Path.."/BoxDetails.txt","Account.txt") end
- end
- local function CheckPeripherals()
- if peripheral.isPresent("modem") then Modem = peripheral.find("modem") end
- if peripheral.isPresent("drive") then Drive = peripheral.find("Drive") RunDrive() end
- end
- local function CheckCertificate()
- if fs.exists("Certificate.txt") then
- local file = fs.open("Certificate".txt","r")
- local Data = textutils.unserialize(file.readAll())
- file.close()
- SCh = Data[2]
- LCh = Data[3]
- end
- end
- local function CheckAccount()
- if fs.exists("Account.txt") then
- local file = fs.open("Account.txt","r")
- local Data = textutils.unserialize(file.readAll())
- file.close()
- ID = Data[1]
- Key = Data[2]
- Company = Data[3]
- Client = Data[4]
- EndTime = Data[5]
- print("account file found")
- print("ready")
- else
- print("account file missing")
- StopProgram()
- end
- end
- local function Message(MSG)
- local Data = {ID,Key,MSG}
- Modem.transmit(SCh,LCh,textutils.serialize(Data))
- Modem.open(LCh)
- local a, b, c, d, e
- repeat
- a, b, c, d, e = os.pullEvent("modem_message")
- until b == LCh
- return textutils.unseriaize(e)
- end
- local function Loop()
- while true do
- if os.day("ingame") > EndTime then redstone.setOutput("top",false) break else redstone.setOutput("top",true) end
- if Modem ~= nil and fs.exists("Certificate.txt")
- Modem.open(LCh)
- local a, b, c, d, e = os.pullEvent("modem_message")
- end
- end
- end
- local function DisplayText(text)
- term.clear()
- term.setCursorPos(1,1)
- print(text)
- end
- local function CMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("==Consumer=Menu==")
- print("Client: "..Client..", Company: "..Company)
- print("ID: "..ID)
- print("days til next invoice: "..(EndTime - os.day("ingame")))
- print("==Options==")
- print("1 - details")
- print("2 - payment")
- if Modem ~= nil and Drive ~= nil then print("3 - Download Certificate") else print("<requires Modem and Drive>")
- print("4 - continue boot")
- local a, b
- repeat
- a, b = os.pullEvent("key")
- until b == keys.one or b == keys.two or (b == keys.three and Modem ~= nil and Drive ~= nil) or b == keys.four
- if b == keys.one then
- DisplayText(Company.." Endorsed Power Unit Box")
- os.reboot(2)
- os.reboot()
- elseif b == keys.two then
- DisplayText("payment can be submitted at anytime")
- os.sleep(2)
- os.reboot()
- elseif b == keys.three and Modem ~= nil and Drive ~= nil then
- if Drive.isPresent() and fs.exists(fs.combine(Drive.getMethod(),"Certificate.txt")) then fs.copy(fs.combine(Drive.getMethod(),"Certificate.txt"),"Certificate.txt") os.reboot() end
- elseif b == keys.four then
- Loop()
- else
- os.reboot()
- end
- end
- local function Start()
- term.clear()
- term.setCursorPos(1,1)
- print("=======Power=Box="..V.."======")
- print("starting terminal . . .")
- CheckPeripherals()
- CheckAccount()
- if Modem ~= nil then CheckCertificate() end
- if Modem ~= nil and fs.exists("Certificate.txt") then if Message("auth_unit")[2] == false then StopProgram() end end
- local Time = os.time("ingame") + 0.01
- print("to enter consumer menu, press enter within 10 seconds")
- local a, b = os.pullEvent("key")
- repeat until b == keys.enter or os.time("ingame") > Time
- if b == keys.enter then CMenu() else Loop() end
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement