-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectList.lua
78 lines (61 loc) · 1.23 KB
/
ProjectList.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
--Program to display list of projects to remote displays
--by RebelTank
rednet.open("left") --Change to side of wireless
projects = {}
h = fs.open("projectlist.txt", "r")
i = 1
--Add info option if "?" entered.
--write file to array
if h then
row = h.readLine()
end
while row do
projects[i] = row
i = i + 1
row = h.readLine()
end
if h then
h.close()
end
--Modify given line
function upadeLine()
print("Enter line to change. ")
line = io.read()
print("What should it say? ")
text = io.read()
projects[tonumber(line)] = line..". "..text
end
--Clear given line
function clearLine()
print("Enter line to clear. ")
line = io.read()
projects[tonumber(line)] = line.."."
end
--Refresh all screens and file
function refresh()
h = fs.open("projectlist.txt", "w")
--broadcast array to boards and print to file
for i = 1, #projects do
rednet.broadcast(projects[i])
h.writeLine(projects[i])
end
h.close()
end
sleep(5)
refresh()
--Run the menu
while true do
term.clear()
term.setCursorPos(1,1)
print("Menu")
print("1. Add or change a line.")
print("2. Clear a line.")
print("(Enter to refresh screens.)")
ans = tonumber(io.read())
if ans == 1 then
updateLine()
elseif ans == 2 then
clearLine()
end
refresh()
end