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

Computercraft coding, return back to start.

Started by MikkelDm, 17 November 2012 - 07:59 AM
MikkelDm #1
Posted 17 November 2012 - 08:59 AM
Hi i've been coding a program, but i have a problem.

My problem is that i want my pc to return if fase. Like return without using the shell.run("startup").

Like this:

term.clear()
term.setCursorPos(1,1)
password = "test"
debug = "testreset"
print("This door is protected by password!")
write("Please enterpassword: ")
A = read("X")
if A == password then
...blalalalal....
else return - Here i wan it to retur up to "if A == password then" if false! And only if false!

Any help?
Sammich Lord #2
Posted 17 November 2012 - 09:11 AM
Hi i've been coding a program, but i have a problem.

My problem is that i want my pc to return if fase. Like return without using the shell.run("startup").

Like this:

term.clear()
term.setCursorPos(1,1)
password = "test"
debug = "testreset"
print("This door is protected by password!")
write("Please enterpassword: ")
A = read("X")
if A == password then
...blalalalal....
else return - Here i wan it to retur up to "if A == password then" if false! And only if false!

Any help?
Just use a while loop:

os.pullEvent = os.pullEventRaw --Prevent CTRL+T
term.clear()
term.setCursorPos(1,1)
local password = "test"
local debug = "testreset"
print("This door is protected by password!")
while true do
  write("Please enterpassword: ")
  a = read("*")
  if a == password then
    print("Correct password. Door now opening.")
    rs.setOutput("left", true)
    sleep(5)
    rs.setOutput("left", false)
  else
    print("Incorrect password! Please try again.")
end
Tiin57 #3
Posted 17 November 2012 - 02:20 PM
Would someone teach these people to read?!
This is the APIS AND UTILITIES SECTION OF THE PROGRAMS SUBFORUM. Where in that sentence is there anything saying, "Post problems here!"?
For f***'s sake. -.-
Cruor #4
Posted 17 November 2012 - 10:42 PM
Moved to ask a pro
Sammich Lord #5
Posted 17 November 2012 - 10:44 PM
Would someone teach these people to read?!
This is the APIS AND UTILITIES SECTION OF THE PROGRAMS SUBFORUM. Where in that sentence is there anything saying, "Post problems here!"?
For f***'s sake. -.-
I actually didn't notice that :)/>/> I reply to most threads I see in the "New Content" section.
MikkelDm #6
Posted 18 November 2012 - 04:28 AM
Hi i've been coding a program, but i have a problem.

My problem is that i want my pc to return if fase. Like return without using the shell.run("startup").

Like this:

term.clear()
term.setCursorPos(1,1)
password = "test"
debug = "testreset"
print("This door is protected by password!")
write("Please enterpassword: ")
A = read("X")
if A == password then
...blalalalal....
else return - Here i wan it to retur up to "if A == password then" if false! And only if false!

Any help?
Just use a while loop:

os.pullEvent = os.pullEventRaw --Prevent CTRL+T
term.clear()
term.setCursorPos(1,1)
local password = "test"
local debug = "testreset"
print("This door is protected by password!")
while true do
  write("Please enterpassword: ")
  a = read("*")
  if a == password then
	print("Correct password. Door now opening.")
	rs.setOutput("left", true)
	sleep(5)
	rs.setOutput("left", false)
  else
	print("Incorrect password! Please try again.")
end

Okay, but I get a error i guess the end doesnt support while loop.
MikkelDm #7
Posted 18 November 2012 - 04:29 AM
Hi i've been coding a program, but i have a problem.

My problem is that i want my pc to return if fase. Like return without using the shell.run("startup").

Like this:

term.clear()
term.setCursorPos(1,1)
password = "test"
debug = "testreset"
print("This door is protected by password!")
write("Please enterpassword: ")
A = read("X")
if A == password then
...blalalalal....
else return - Here i wan it to retur up to "if A == password then" if false! And only if false!

Any help?
Just use a while loop:

os.pullEvent = os.pullEventRaw --Prevent CTRL+T
term.clear()
term.setCursorPos(1,1)
local password = "test"
local debug = "testreset"
print("This door is protected by password!")
while true do
  write("Please enterpassword: ")
  a = read("*")
  if a == password then
	print("Correct password. Door now opening.")
	rs.setOutput("left", true)
	sleep(5)
	rs.setOutput("left", false)
  else
	print("Incorrect password! Please try again.")
end

Okay, but I get a error i guess the end doesnt support while loop.
Oooh nvm, I found out. The while loop didn't end.

THANKKKSS!