Posted 10 August 2012 - 10:06 PM
As i searched the forums i could only find passwordlocks for the use with 1 computer of with 2 but the client has to emit the redstone signal.
This easily bypassed with the use of a disk.
I made a little doorlock script witch require 2 computers connected with a modem.
The client side only asks for a password en sends that to the server. The server will check if the password is correct and emit a redstone signal.
Fairly safe.
I do admit that i'm a noob scripter so if anyone has a better code feel free to add ;)/>/>
Client code
Server code
This easily bypassed with the use of a disk.
I made a little doorlock script witch require 2 computers connected with a modem.
The client side only asks for a password en sends that to the server. The server will check if the password is correct and emit a redstone signal.
Fairly safe.
I do admit that i'm a noob scripter so if anyone has a better code feel free to add ;)/>/>
Client code
Spoiler
os.pullEvent = os.pullEventRaw
local server = 2 -- Here goes the server ID
local modemside = "back" -- Here goes the modem side
rednet.open(modemside)
while true do
term.clear()
term.setCursorPos(1, 1)
print("Remote Lock v. 1.0 Client")
print("Enter password:")
local pass = read("*")
rednet.send(server, pass)
local id, access
repeat
id, access = rednet.receive()
until id == server
if access == "granted" then
print("ACCESS GRANTED")
sleep(5)
else
print("ACCESS DENIED")
sleep(5)
end
end
Server code
Spoiler
os.pullEvent = os.pullEventRaw
local client = 3 -- Here goes the client id
local pass = "password" -- Here goes the password
local rsside = "left" -- Here goes the redstone output side
local rstime = "5" -- Here goes the time the redstone signal will stay on
local modemside = "back" -- Here goes the modem side
rednet.open(modemside)
term.clear()
term.setCursorPos(1, 1)
print("Remote Lock v. 1.0 Server")
while true do
local id, receivedpass
repeat
id, receivedpass = rednet.receive()
until id == client
if receivedpass == pass then
sleep(1)
rednet.send(client, "granted")
redstone.setOutput(rsside, true)
sleep(rstime)
redstone.setOutput(rsside, false)
sleep(2)
else
sleep(1)
rednet.send(client, "denied")
end
end