I dont like bundled cables and use a API to handle them. Which means i dont know how it works.
But for the second piece of code. You need "==" not "="
"==" compares one to another. "=" is setting one to another.
Controlling Computer
rednet.open("top") -- Opens a modem on top of the computer
User = {} -- Makes a table
ID = 0 --Set this to the computerID of the one you are controlling
--For the User and Password. You can add multiple users and a password per user.
--For just one user. Delete User[2]. To add a user use User[3] User[4] etc.
--You need to do the same thing for Password. But with a password.
--You proberly dont want to use capitalized letters. Its caps specific. As in you need to type the caps in correctly too.
User[1] = "Jack"
User[2] = "Sam"
Password = {}
Password[1] = "Jill"
Password[2] = "Dam"
function Clear()
term.clear()
term.setCursorPos(1,1)
end
function OpenDoor(UserName)
Clear()
print("Welcome "..UserName)
rednet.send(ID, "Open")
sleep(5)
rednet.send(ID, "Close")
end
while true do -- While true is true do this
Clear() -- Calls on function Clear() which clears the screen
write("User: ")
local Ignore,UserTry = pcall(read, "*") -- pcall catches errors and throws it as a status
write("Password: ")
local Ignore,PassTry = pcall(read, "*")
for n=1,#User do -- Starting from 1 to the max Users there is. Look for this user.
if User[n] == UserTry and PassTry == Password[n] then -- If the user exists and the pass is correct. Do it!
OpenDoor(User[n])
break -- Exit the loop, We dont want any duplicate user errors, And this loop no longer needs to run
end
end
end
And the slave computer
rednet.open("top")
ID = 0 --Set this to the master Computer
term.setCursorPos(1,1)
term.clear()
print("Dobby says you may NOT touch this computer!")
while true do
event,param1,param2 = os.pullEventRaw() -- os.pullEvent() is a modified version of os.pullEventRaw() in that its safer to use. But its not Ctrl+T proof
if event == "rednet_message" and param1 == ID then
if param2 == "Open" then
rs.setOutput("back", true)
elseif param2 == "Close" then
rs.setOutput("back", false)
end
end
end
I didnt put bundled in :
This is also Ctrl+T proof.
Just setup the users/ID's and rename as startup.
Then restart the computers.
Viola!
If you dont want it Ctrl+T proof then rename os.PullEventRaw() to os.pullEvent() and pcall(read, "*") to read()
So anyways.
You should be able to use/look at that