0
Need some help with Redstone inputs please :)
Started by Bmasta8899, Jul 23 2012 10:07 PM
api lua help
23 replies to this topic
#1
Posted 23 July 2012 - 10:07 PM
Hey Guys I am attempting to create a door that flush with the wall in my room, i can open it useing the command on the console its self but im having trouble getting it to open a from the inside when i press the button
shell.run("clear")
print("Window's 7")
print("Piratebay edition")
print()
print("What would you like to do ben?")
input = read()
sc = "oldpeopleburning"
if input == sc then
print("Opening Private safe...")
sleep (1.0)
rs.setBundledOutput("bottom", colors.magenta)
sleep(0.5)
rs.setBundledOutput("bottom", colors.white)
sleep(10.0)
rs.setBundledOutput("bottom", colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom", colors.black)
end
if rs.testInput("back") == true then
print("Opening Private safe...")
sleep (1.0)
rs.setBundledOutput("bottom", colors.magenta)
sleep(0.5)
rs.setBundledOutput("bottom", colors.white)
sleep(10.0)
rs.setBundledOutput("bottom", colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom", colors.black)
end
shell.run("startup")
(Im useing RS latches and wireless RS to apply power to the door at the time it needs is)
shell.run("clear")
print("Window's 7")
print("Piratebay edition")
print()
print("What would you like to do ben?")
input = read()
sc = "oldpeopleburning"
if input == sc then
print("Opening Private safe...")
sleep (1.0)
rs.setBundledOutput("bottom", colors.magenta)
sleep(0.5)
rs.setBundledOutput("bottom", colors.white)
sleep(10.0)
rs.setBundledOutput("bottom", colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom", colors.black)
end
if rs.testInput("back") == true then
print("Opening Private safe...")
sleep (1.0)
rs.setBundledOutput("bottom", colors.magenta)
sleep(0.5)
rs.setBundledOutput("bottom", colors.white)
sleep(10.0)
rs.setBundledOutput("bottom", colors.orange)
sleep(0.5)
rs.setBundledOutput("bottom", colors.black)
end
shell.run("startup")
(Im useing RS latches and wireless RS to apply power to the door at the time it needs is)
#2
Posted 24 July 2012 - 02:38 AM
Bump really need a hand, please help if u can
#3
Posted 24 July 2012 - 02:42 AM
1: For that empty print make it print(" ")
2: What is your error? - IF there is one.
2: What is your error? - IF there is one.
#4
Posted 24 July 2012 - 06:20 AM
Thank you for replying, even tho i press the button it wont run though the function
#5
Posted 24 July 2012 - 06:28 AM
you are calling the read() function, the program then stops and waits for you to enter your password so it won't check the back for redstone input until you have entered a password
#6
Posted 24 July 2012 - 06:30 AM
ohhhhh ok, How would i fix that? Put the input before the read() function?
#8
Posted 24 July 2012 - 07:41 AM
You lost me a bit, i added that but still nothing....
#10
Posted 24 July 2012 - 07:48 AM
neither of those options will work, you will either have to have 2 separate computers, one for password input and one to listen for redstone input or develop a new read function that pulls events to get your key presses for a password and simultaneously checks for a redstone event, sorry but that's the only way to get this working
#11
Posted 24 July 2012 - 08:05 AM
KaoS, on 24 July 2012 - 07:48 AM, said:
neither of those options will work, you will either have to have 2 separate computers, one for password input and one to listen for redstone input or develop a new read function that pulls events to get your key presses for a password and simultaneously checks for a redstone event, sorry but that's the only way to get this working
#13
Posted 24 July 2012 - 09:09 AM
How would i implement that? haha once again sorry, Im new, this was like my 3rd attempt at writing a program haha
#14
Posted 24 July 2012 - 09:11 AM
and im running startup at the end beacuse that's the name of the file and it restarts the programs after i A: type in a password or B: (hopefully haha) run the if statment with the Rs input
#15
Posted 24 July 2012 - 09:12 AM
Make 2 functions
add While true loop at the end.
EDIT: 400th post.
add While true loop at the end.
function input() -- Input (read) sht here -- end function rs() -- Redstone if's here -- end while true do parallel.waitForAny(input, rs) end
EDIT: 400th post.
#16
Posted 24 July 2012 - 09:15 AM
Gottcha ill go try that, Gratz on the 400th post
#18
Posted 24 July 2012 - 09:28 AM
still won't work... parallel api is complicated, I don't understand it fully but it will wait for the read() function to close
#19
Posted 24 July 2012 - 09:38 AM
KaoS, on 24 July 2012 - 09:28 AM, said:
still won't work... parallel api is complicated, I don't understand it fully but it will wait for the read() function to close
it is plausible to make two separate loops (coroutine) run at the same time(well a microsecond gap)
look at my program here specifically the WIFI section
http://www.computerc...esting-utility/
it is running a read while listening for rednet messages.
#20
Posted 24 July 2012 - 09:54 AM
This should do the trick
it is untested
Spoiler
it is untested
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users