Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addList(txtline)
- fs.makeDir("disk/todo/"..txtline)
- end
- local function checkList(id)
- local msg = {}
- msg[1] = fs.list("disk/todo/")[1]
- msg[2] = fs.list("disk/todo/")[2]
- msg[3] = fs.list("disk/todo/")[3]
- msg[4] = fs.list("disk/todo/")[4]
- msg[5] = fs.list("disk/todo/")[5]
- msg[6] = fs.list("disk/todo/")[6]
- msg[7] = fs.list("disk/todo/")[7]
- msg[8] = fs.list("disk/todo/")[8]
- msg[9] = fs.list("disk/todo/")[9]
- msg[10] = fs.list("disk/todo/")[10]
- sleep(2)
- local txtr = textutils.serialize(msg)
- rednet.send(id, txtr)
- textutils.unserialize(txtr)
- end
- local function delList(item)
- if fs.exists("disk/todo/"..item) then
- fs.delete("disk/todo/"..item)
- return true
- else
- return false
- end
- end
- rednet.open("top")
- while true do
- id, cmd = rednet.receive()
- if cmd == "create" then
- print("Add: "..id)
- sleep(5)
- rednet.send(id, "What would you like to add?")
- sleep(0.5)
- idb, txtb = rednet.receive()
- print(txtb)
- print("------------------------")
- addList(txtb)
- elseif cmd == "delete" then
- print("Delete: "..id)
- sleep(5)
- rednet.send(idb, "What would you like to delete?")
- ida, txta = rednet.receive()
- print(txta)
- print("----------------------")
- if not delList(txta) then
- print(" Failed: Does not Exist.")
- end
- elseif cmd == "read" then
- print("Read: "..id)
- print("------------------------")
- checkList(ida)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment