View difference between Paste ID: RnuE27M0 and 9zAZF5pB
SHOW: | | - or go back to the newest paste.
1-
os.pullEvent = os.pullEventRaw
1+
tunnelLength = 100
2-
-- Local Variables --
2+
buffer = 2
3-
local root = ".ComputerLock/Lock/"
3+
tunnels = 10
4-
4+
placeTorches = true
5-
-- Functions --
5+
blocksBetweenTorches = 10
6-
--[[ Password ]]--
6+
autoRefuel = true
7-
function invalid()
7+
startLeft = false
8-
	term.clear()
8+
 
9-
	term.setCursorPos(1,1)
9+
trash = {
10-
	print("Invalid Input!")
10+
    dirt = true,
11-
	os.sleep(2)
11+
    cobblestone = true,
12-
	os.reboot()
12+
    stone = true,
13
    gravel = true,
14-
14+
    quartz = true,
15-
function uninstall()
15+
    resource = true,
16-
	print("\nDo You Want To Uninstall ComputerLock? Yes / No")
16+
    nugget = true,
17-
	write("\n> ")
17+
    redstone = true,
18-
	local input = read()
18+
    iron_ore = true,
19-
	if input == "Yes" or input == "yes" then
19+
    flint = true
20-
		write("\nEnter Current Password: ")
20+
}
21-
		local input = read("*")
21+
 
22-
		pr = fs.open(root .. "password", "r")
22+
local function check()
23-
		Password = pr.readLine()
23+
    for i=2,15 do
24-
		pr.close()
24+
        item = turtle.getItemDetail(i)
25-
		if input == Password then
25+
        if item ~= nil then
26-
			fs.delete(".ComputerLock")
26+
            print("Item: "..item.name)
27-
			fs.delete("startup")
27+
            print(trash[item.name])
28-
			print("\nComputerLock Uninstalled!")
28+
            
29-
			os.reboot()
29+
            colon = string.find(item.name, ":")
30-
		else
30+
            
31-
			print("\nIncorrect Password!")
31+
            if trash[string.sub(item.name, colon + 1)] ~= nil and item.count > 0 then
32-
			os.sleep(2)
32+
                print("That's trash, throw it out")
33-
			os.reboot()
33+
                turtle.select(i)
34-
		end
34+
                turtle.dropDown()
35-
	elseif input == "No" or input == "no" then
35+
            elseif item.name == "minecraft:coal" and autoRefuel then
36-
		os.reboot()
36+
                if turtle.getItemDetail(1).name == "minecraft:coal" then
37-
	else
37+
                    turtle.transferTo(1, item.count)
38-
		invalid()
38+
                end
39-
	end
39+
            
40
                if turtle.getFuelLevel() < 50 then
41-
41+
                    turtle.select(1)
42-
function reSetNewPass()
42+
                    turtle.refuel()
43-
	print("\nPasswords Do Not Match!")
43+
                end
44-
	os.sleep(2)
44+
            elseif item.name == "minecraft:torch" then
45-
	setNewPass()
45+
                turtle.transferTo(16, turtle.getItemCount(i))            
46
            end
47-
47+
        end
48-
function setNewPass()
48+
    end
49-
	write("\nEnter New Password: ")
49+
    
50-
	NewPass = read("*")
50+
    os.setComputerLabel("Fuel: "..turtle.getFuelLevel())
51-
	write("Confirm New Password: ")
51+
    turtle.select(1)
52-
	ConfirmNewPass = read("*")
52+
53-
	if NewPass == ConfirmNewPass then
53+
 
54-
		fs.delete(root .. "password")
54+
local function height()
55-
		pw = fs.open(root .. "password", "w")
55+
    turtle.dig()
56-
		pw.writeLine(ConfirmNewPass)
56+
    turtle.digUp()
57-
		pw.close()
57+
    turtle.digDown()
58-
		print("\nNew Password Set!")
58+
    
59-
		os.sleep(2)
59+
    isBlock, block = turtle.inspect()
60-
		login()
60+
    
61-
	else
61+
    if isBlock and block.name == "minecraft:gravel" then
62-
		reSetNewPass()
62+
        height()
63-
	end
63+
    end
64
end
65-
65+
 
66-
function changePass()
66+
local function length()
67-
	print("\nDo You Want To Change The Password? Yes / No")
67+
    for i=1,tunnelLength do
68-
	write("\n> ")
68+
        height()
69-
	local input = read()
69+
        
70-
	if input == "Yes" or input == "yes" then
70+
        if (i % (blocksBetweenTorches + 1)) == 0 and placeTorches and turtle.getItemDetail(16) ~= nil and turtle.getItemDetail(16).name == "minecraft:torch" then
71-
		write("\nEnter Current Password: ")
71+
            turtle.select(16)
72-
		local input = read("*")
72+
            turtle.placeDown()
73-
		pr = fs.open(root .. "password", "r")
73+
            turtle.select(2)
74-
		Password = pr.readLine()
74+
        end
75-
		pr.close()
75+
        
76-
		if input == Password then
76+
        if i % 15 == 0 then
77-
			setNewPass()
77+
            check()
78-
		else
78+
        end
79-
			print("\nIncorrect Password!")
79+
        
80-
			os.sleep(2)
80+
        turtle.forward()
81-
			os.reboot()
81+
    end
82-
		end
82+
83-
	elseif input == "No" or input == "no" then
83+
 
84-
		os.reboot()
84+
local function main()
85-
	else
85+
    for k=1,tunnels do
86-
		invalid()
86+
        length()
87-
	end
87+
        
88
        if startLeft then
89-
89+
            turtle.turnLeft()
90-
function reSetPass()
90+
        else
91-
	print("\nPasswords Do Not Match!")
91+
            turtle.turnRight()
92-
	os.sleep(2)
92+
        end
93-
	setPass()
93+
 
94
        for k=1,buffer + 1 do
95-
95+
            height()
96-
function setPass()
96+
            turtle.forward()
97-
	fs.makeDir(".ComputerLock")
97+
        end
98-
	fs.makeDir(".ComputerLock/Lock")
98+
        
99-
	write("\nPlease Enter Your Password: ")
99+
        if startLeft then
100-
	local PassEnter = read("*")
100+
            turtle.turnLeft()
101-
	write("Please Confirm Your Password: ")
101+
            startLeft = false
102-
	local PassConfirm = read("*")
102+
        else
103-
	if PassEnter == PassConfirm then
103+
            turtle.turnRight()
104-
		pw = fs.open(root .. "password", "w")
104+
            startLeft = true
105-
		pw.write(PassConfirm)
105+
        end
106-
		pw.close()
106+
    end
107-
		print("\nPassword Has Been Set!")
107+
108-
		os.sleep(2)
108+
 
109-
		login()
109+
main()