Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SERVER_ID = 1;
- rednet.open("back");
- function ReceiveInput(message)
- term.setTextColor(colors.white)
- print("What action do you want to do?")
- local Input = string.lower(read());
- if Input == "add" then
- print("What do you want to add?")
- local toAdd = read();
- rednet.send(SERVER_ID, {true, toAdd});
- elseif Input == "remove" then
- print("What line do you want to remove?")
- local index = tonumber(read());
- if type(index) == "number" then
- rednet.send(SERVER_ID, {false, index});
- else
- term.setTextColor(colors.red)
- print("Not valid index")
- end
- elseif Input == "refresh" then
- rednet.send(SERVER_ID, "list")
- else
- PrintList(message)
- ReceiveInput(message)
- end
- end
- function MainThread()
- local id, message = rednet.receive();
- if id ~= SERVER_ID or type(message) ~= "table" then return end
- PrintList(message)
- parallel.waitForAll(ReceiveInput(message), MainThread())
- end
- function PrintList(List)
- term.clear()
- for i, v in pairs(List) do
- print(i..". "..v)
- end
- end
- function RequestList()
- rednet.send(SERVER_ID, "list")
- MainThread()
- end
- RequestList()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement