Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local AdRegions = {"Vedrana","Goldshelm","SaltFlats"}
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function CUI(m) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(1,5)
- for i=1, #m, 1 do --traverse the table of options
- if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
- end
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- function EditItem(item,type)
- Clear()
- print("editing ",item)
- local file = fs.open("os/System/Client/Files/.UserFile.txt","r")
- local User = file.readLine()
- local Reg = file.readLine()
- local Tax = file.readLine()
- local Access = file.readLine()
- local Add = file.readLine()
- file.close()
- local Acc = fs.open("os/System/Client/Files/.UserFile.txt","w")
- local input
- if type == "text" then
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- elseif type == "Sel" and item == "region" then
- local options = AdRegions
- local n = CUI(options)
- input = options[n]
- end
- if item == "username" then
- User = input
- elseif item == "region" then
- Reg = input
- elseif item == "address" then
- Add = input
- end
- Acc.writeLine(User)
- Acc.writeLine(Reg)
- Acc.writeLine(Tax)
- Acc.writeLine(Access)
- Acc.writeLine(Add)
- Acc.close()
- end
- function Menu()
- Clear()
- local options = {"username","region","address","exit"}
- local n = CUI(options)
- if options[n] == "exit" then
- else
- if options[n] == "region" then
- EditItem(options[n],"Sel")
- else
- EditItem(options[n],"text")
- end
- Menu()
- end
- end
- Menu()
Add Comment
Please, Sign In to add comment