Jump to content




How To Make Rednet Start Redstone On Another Computer


  • You cannot reply to this topic
15 replies to this topic

#1 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 06: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)


#2 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 19 August 2013 - 07: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


#3 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07:08 AM

thank you doors now open on command

#4 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07:09 AM

now to just add that to the login code

#5 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 19 August 2013 - 07:19 AM

View Postmrjosheyhalo, on 19 August 2013 - 07:09 AM, said:

now to just add that to the login code

always fun, making it multi-user or just for one person?

#6 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07: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

#7 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07:32 AM

i have no other users to add though

#8 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07: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

#9 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 19 August 2013 - 07:39 AM

look at storing the users in a table (if you actually need multi user)

#10 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07:42 AM

is that like mrjosheyhalopassold = "password" or not

#11 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07: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.../TablesTutorial

#12 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07:46 AM

so
users = {mrjosheyhalo,user}

> t = {}
> t["mrjosheyhalo"] = code1982

?

#13 mrjosheyhalo

  • Members
  • 19 posts

Posted 19 August 2013 - 07:48 AM

so its saves room

mrjosheyhalopass = "code1982"
mrjosheyhalopassold = "password"

is
pass = {"code1982", "password"}

#14 Last1Here

  • Members
  • 32 posts
  • LocationUK

Posted 19 August 2013 - 10:51 AM

I was thinking more like

users = {
  user1 = {"dave", "davesPassword"},
  user2 = {"ted", "tedsPassword"}
}

tables on the wiki

#15 LordIkol

  • Members
  • 197 posts
  • LocationSwitzerland

Posted 19 August 2013 - 01: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


#16 mrjosheyhalo

  • Members
  • 19 posts

Posted 20 August 2013 - 12:40 AM

thank you





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users