View difference between Paste ID: g6zLRS9U and resvVgHv
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
	print("Enter your 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
		print(i .. " - " .. list[i]);
36
	end
37
end
38
39
function remove()
40
	print("Which task would you like to remove?");
41
	removeAns = read();
42-
	if type(listAns) == "number" then
42+
	if type(tonumber(listAns)) == "number" then
43
		print("Removing: " .. listAns);
44
	end
45
	print("Nothing");
46
end
47
48
function start()
49
	while true do
50
		print("What would you like to do?");
51
		print(" - Type \"add\" to add an item");
52
		print(" - Type \"remove\" to add an item");
53
		print(" - Type \"quit\" to save and quit");
54
		ans = read();
55
		if type(ans) == "string" then
56
			if ans == "add" then add() end
57
			if ans == "remove" then remove() end
58
			if ans == "quit" then 
59
				printm("Goodbye!");
60
				os.shutdown();
61
			end
62
		end
63
	end
64
end
65
66
start();