Jump to content




Just need a quick help

help

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

#1 Sir Gree

  • New Members
  • 3 posts

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 Lyqyd, 19 December 2012 - 06:09 PM.
added code tags


#2 Sir Gree

  • New Members
  • 3 posts

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

#3 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

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.

#4 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

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


#5 Sir Gree

  • New Members
  • 3 posts

Posted 20 December 2012 - 06:52 AM

Thank you both, it works perfectly now.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users