17 posts
Posted 19 August 2013 - 07:27 AM
im trying to get this to work
rednet.open("back")
local senderId, message, distance = rednet.receive()
term.write(message)
if message == open then
redstone.setOutput("left", true)
end
it does not output
all that comes out is term.write(message) witch is open
the other half is
rednet.open("back")
rednet.send(9,"open",true)
32 posts
Location
UK
Posted 19 August 2013 - 08:06 AM
i believe you missed quotations
rednet.open("back")
local senderId, message, distance = rednet.receive()
term.write(message)
if message == "open" then -- here
redstone.setOutput("left", true)
end
17 posts
Posted 19 August 2013 - 08:08 AM
thank you doors now open on command
17 posts
Posted 19 August 2013 - 08:09 AM
now to just add that to the login code
32 posts
Location
UK
Posted 19 August 2013 - 08:19 AM
now to just add that to the login code
always fun, making it multi-user or just for one person?
17 posts
Posted 19 August 2013 - 08:30 AM
its multiuser i could only get one user working
so i found one on pastebin that works
rednet.open("back")
term.clear()
term.setCursorPos(1,1)
mrjosheyhalopass = "code1982"
mrjosheyhalopassold = "password"
write("Username: ")
user = read()
if user == "mrjosheyhalo" then
write("Password: ")
p1 = read(".")
if p1 == mrjosheyhalopass then
print("Welcome mrjosheyhalo")
sleep(4)
rednet.send(9,"open",true)
print("Door Open Please wait")
sleep(7)
os.reboot()
elseif p1 == mrjosheyhalopassold then
print("Welcome mrjosheyhalo")
print("Error")
print("Old password please")
print("See System Admin")
print("for new Password")
print("Error")
sleep(4)
os.reboot()
else
print("Welcome mrjosheyhalo")
print("Error")
print("Password Incorrect")
print("See System Admin")
print("for Password")
print("Error")
sleep(4)
os.reboot()
end
else
print("Error")
print("Username Incorrect")
print("See System Admin")
print("for Username")
print("Error")
sleep(2)
os.reboot()
end
lol it now has crazy spaces in it
17 posts
Posted 19 August 2013 - 08:32 AM
i have no other users to add though
17 posts
Posted 19 August 2013 - 08:35 AM
hm the code dont work on other side of door
the rednet bit the door wont open
i forgot to make the redstone comp os.reboot()
that and i removed the code for it
32 posts
Location
UK
Posted 19 August 2013 - 08:39 AM
look at storing the users in a table (if you actually need multi user)
17 posts
Posted 19 August 2013 - 08:42 AM
is that like mrjosheyhalopassold = "password" or not
17 posts
Posted 19 August 2013 - 08:43 AM
ok no
its like this
> t = {} – construct an empty table and assign it to variable "t"
> print(t)
table: 0035AE18
http://lua-users.org/wiki/TablesTutorial
17 posts
Posted 19 August 2013 - 08:46 AM
so
users = {mrjosheyhalo,user}
> t = {}
> t["mrjosheyhalo"] = code1982
?
17 posts
Posted 19 August 2013 - 08:48 AM
so its saves room
mrjosheyhalopass = "code1982"
mrjosheyhalopassold = "password"
is
pass = {"code1982", "password"}
32 posts
Location
UK
Posted 19 August 2013 - 11:51 AM
I was thinking more like
users = {
user1 = {"dave", "davesPassword"},
user2 = {"ted", "tedsPassword"}
}
tables on the wiki
199 posts
Location
Switzerland
Posted 19 August 2013 - 02:31 PM
Hi mrjoshey,
i modified your code from above a bit using a table (and remove that oldpassword stuff cause i dont know what it is good for)
hope that helps you with your multiuser thing.
rednet.open("back")
term.clear()
term.setCursorPos(1,1)
users = {} --create a table
users["mrjosheyhalo"] = "code1982" --adding an entry the key is the username and the value the password
users["loki"] = "1234" --adding another user
write("Username: ")
user = read()
if not users[user] then --check if this user exists by checking if the key is in the table
term.clearLine()
write("user does not exist") --errormessage
sleep(2)
os.reboot() --shutdown
else --if user exists go on
write("Password: ") --ask for password
p1 = read(".") --read the password to variable
if p1 == users[user] then --check if the password fits with the password value of the given user in the table
print("Welcome "..user) --rest should be clear
rednet.send(9,"open",true)
print("Door Open Please wait")
sleep(7)
os.reboot()
else
print("wrong password")
sleep(2)
os.reboot()
end
end
17 posts
Posted 20 August 2013 - 01:40 AM
thank you