This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sir Gree's profile picture

Just need a quick help

Started by Sir Gree, 19 December 2012 - 04:03 PM
Sir Gree #1
Posted 19 December 2012 - 05:03 PM
I'm trying to edit the startup program to ask for a username and password, and when both are correct that it sends a redpulse on the right to a piston door setup for 20 seconds. Without the redpulse string the program works fine, when both the username and pass are good, it unlocks the shell, and when they are bad it says goodbye and shuts down. but with the redpulse string in there everytime i run Startup, it gives me i get a Bios:206: [string "startup"]:7 '=' expected ,i am completely new to computercraft and programing in itself. i have looked through the tutorial thread and couldn't find a solution to my problem in particular. Please check my code and explain what i code do to fix it.


write"Username:"
input = io.read()
print"Password:"
input = io.read()
if input2 == "password" and input == "admin" then
print("welcome")
redpulse right 1 20
else
print"goodbye"
sleep(2)
os.shutdown
end
Edited by
Sir Gree #2
Posted 19 December 2012 - 05:07 PM
Forgot to Mention this is the latest tekkit version that im using, i have no idea if that make a difference or not
Grim Reaper #3
Posted 19 December 2012 - 05:12 PM

redpulse right 1 20
Is interpreted by the Lua interpreter as you trying to access the variable 'redpulse' and sees it's nil, however, the problem occurs when the interpreter tries to use 'right' as an operator on the variable 'redpulse'.

'redpulse' is actually a program. If you want to use that program within yours, then you can run it quite simply with the following line:

shell.run("redpulse", "1", "20")
This loads the 'redpulse' script and throws it on to the top of the program stack with the arguments "1" and "20". Thus, you get your desired redpulse of 20 seconds.

Hope I helped.
remiX #4
Posted 20 December 2012 - 12:29 AM
write"Username:"
input = io.read()
print"Password:"
input = io.read()
if input2 == "password" or input == "admin" then  -- Needs to be OR not AND
    print("welcome")
    shell.run("redpulse", "right", "1", "20") -- Don't konw if the numbers should be in " "
else
    print"goodbye"
    sleep(2)
    os.shutdown
end
Sir Gree #5
Posted 20 December 2012 - 06:52 AM
Thank you both, it works perfectly now.