View difference between Paste ID: LxMNGsPj and pibsGcBr
SHOW: | | - or go back to the newest paste.
1
hasMon = false;
2
list = {}
3
i = 0;
4
len = 0;
5
if peripheral.isPresent("top") then
6
	hasMon = true;
7
	mon = peripheral.wrap("top");
8
	print("Monitor was found!");
9
	mon.clear();
10
end
11
12
function nl()
13
	if hasMon == true then
14
	local x,y = mon.getCursorPos();
15
	mon.setCursorPos(0, y+1);
16
	end
17
end
18
19
function printm(str)
20
	if type(str) ~= "string" then return end
21
	print(str);
22
	mon.write(str);
23
	nl();
24
end
25
26
function add()
27
	printm("\n Please enter the task");
28
	listAns = read();
29
	if type(listAns) == "string" then
30
		i = i +1;
31
		len = len +1;
32
		list[i] = i .. " - " .. listAns;
33
	end
34
end
35
36
function remove()
37
	printm("removing");
38
end
39
40
function start()
41
	while true do
42
		printm("What would you like to do?");
43
		printm(" - Type \"add\" to add an item");
44
		printm(" - Type \"remove\" to add an item");
45
		printm(" - Type \"quit\" to save and quit");
46
		ans = read();
47
		if type(ans) == "string" then
48
			if ans == "add" then add() end
49
			if ans == "remove" then remove() end
50
			if ans == "quit" then 
51
				printm("Goodbye!");
52
				os.shutdown();
53
			end
54
		end
55
	end
56
end
57
58
start();