Jump to content


qwerty6543's Content

There have been 5 items by qwerty6543 (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#142134 Function Help!

Posted by qwerty6543 on 28 August 2013 - 05:43 PM in Ask a Pro

View Postqwerty6543, on 28 August 2013 - 05:34 PM, said:

View PostGopherAtl, on 28 August 2013 - 05:17 PM, said:

Put it in a while loop to make it repeat, instead of calling itself.

Also, use elseif, not else. As written it would be showing "command not recognized" twice if you weren't calling A again the first time, you should only have one final "else" at the end.

redstone.setOutput("right", true)
print "Type 'open' or 'close' to Open or close the airlock."
function A()
  while true do
	print ""
	write ">"
	input = read()
	if input == "open" then
	  print "Opening..."
	  redstone.setOutput("right", false)
	elseif input == "close" then
	  print "Closing..."
	  redstone.setOutput("right", true)
	else
	  print "Command not recognised."
	end
  end
end

I typed that in exactly and when i try to run it it gives me a 204 error.

Never mind I figured it out



#142133 Function Help!

Posted by qwerty6543 on 28 August 2013 - 05:34 PM in Ask a Pro

View PostGopherAtl, on 28 August 2013 - 05:17 PM, said:

Put it in a while loop to make it repeat, instead of calling itself.

Also, use elseif, not else. As written it would be showing "command not recognized" twice if you weren't calling A again the first time, you should only have one final "else" at the end.

redstone.setOutput("right", true)
print "Type 'open' or 'close' to Open or close the airlock."
function A()
  while true do
	print ""
	write ">"
	input = read()
	if input == "open" then
	  print "Opening..."
	  redstone.setOutput("right", false)
	elseif input == "close" then
	  print "Closing..."
	  redstone.setOutput("right", true)
	else
	  print "Command not recognised."
	end
  end
end

I typed that in exactly and when i try to run it it gives me a 204 error.



#142131 Function Help!

Posted by qwerty6543 on 28 August 2013 - 05:03 PM in Ask a Pro

I am trying to make a piston airlock and I was wondering how to make it so at a certant point it will go back to a place in the command, Here is my script:

redstone.setOutput("right", true)
print "Type 'open' or 'close' to Open or close the airlock."
function A()
print ""
write ">"
input = read()
if input == "open" then
   print "Opening..."
   redstone.setOutput("right", false)
   A()
else
   print "Command not recognised."
   A()
end
if input == "close" then
   print "Closing..."
   redstone.setOutput("right", true)
   A()
else
   print "Command not recognised."
   A()
end
end


When I try to run it it just says the first line and then goes to the normal console. I know it's bad to call a function in a function but I don't know what else to do!



#142126 piston airlock

Posted by qwerty6543 on 28 August 2013 - 04:47 PM in Ask a Pro

View Postjay5476, on 28 August 2013 - 04:44 PM, said:

@qwerty you never call A() and also its bad to call A() within A() it will lead to a stack error use a while loop

Do you think you could suggest to me how to make it better so it works?



#142123 piston airlock

Posted by qwerty6543 on 28 August 2013 - 04:36 PM in Ask a Pro

I am trying to make a piston airlock and I was wondering how to make it so at a certant point it will go back to a place in the command, Here is my script:

redstone.setOutput("right", true)
print "Type 'open' or 'close' to Open or close the airlock."
function A()
print ""
write ">"
input = read()
if input == "open" then
   print "Opening..."
   redstone.setOutput("right", false)
   A()
else
   print "Command not recognised."
   A()
end
if input == "close" then
   print "Closing..."
   redstone.setOutput("right", true)
   A()
else
   print "Command not recognised."
   A()
end
end


When I try to run it it just says the first line and then goes to the normal console. Help?