View difference between Paste ID: BUap7ksz and 20u5LdBA
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
	mon.setCursorPos(1,1);
11
end
12
13
function nl()
14
	if hasMon == true then
15
	local x,y = mon.getCursorPos();
16
	mon.setCursorPos(1, y+1);
17
	end
18
end
19
20
function printm(str)
21
	if type(str) ~= "string" then return end
22
	print(str);
23
	mon.write(str);
24
	nl();
25
end
26
27
function add()
28
	printm("\n Please enter the task");
29
	listAns = read();
30
	if type(listAns) == "string" then
31
		i = i +1;
32
		len = len +1;
33
		list[i] = i .. " - " .. listAns;
34
		printm(list[i]);
35
	end
36
end
37
38
function remove()
39
	print("removing");
40
end
41
42
function start()
43
	while true do
44
		print("What would you like to do?");
45
		print(" - Type \"add\" to add an item");
46
		print(" - Type \"remove\" to add an item");
47
		print(" - Type \"quit\" to save and quit");
48
		ans = read();
49
		if type(ans) == "string" then
50
			if ans == "add" then add() end
51
			if ans == "remove" then remove() end
52
			if ans == "quit" then 
53
				printm("Goodbye!");
54
				os.shutdown();
55
			end
56
		end
57
	end
58
end
59
60
start();