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

colors:36: Too few Arguments

Started by AadamZ5, 12 July 2013 - 09:36 PM
AadamZ5 #1
Posted 12 July 2013 - 11:36 PM
To few Arguments?

well, I was kinda trying to make a control computer for doors and such, but it seems to be giving me trouble at line 36, or so it says. I keep getting the error "colors:36 To few Arguments"
What does this mean and how can I fix it?
You will probably find even more bugs, so if you do, let me know.
EDIT:
Seems to me like the function of colors isnt working? Because, If im correct, it should "Nameofyourprogramhere:96 Stupid error".
Wrong colors?

Code:

function clear()
  term.clear()
  term.setCursorPos(1, 1)
end
function password()
  clear()
  while true do
	term.write("Password: ")
	local pass = read("*")
	if pass == "1598" then
	  doors()
	else
	  clear()
	  print("Password Incorrect.")
	  sleep(1)
	end
  end
end
function doorcheck()
  local one = colors.test(rs.getBundledInput("bottom", colors.purple))
  print("Is Door 1 Open? "..one)
end

function doors()
  while true do
	clear()
	doorcheck()
	print("Which door to manipulate? (1, 2, or 3)")
	local door = read()
	if door == '1' then
	  rs.setBundledOutput("bottom", colors.brown)
	  sleep(0.2)
	  rs.setBundledOutput("bottom", 0)
	  local one = rs.getBundledInput("bottom", colors.purple)
	  if one == true then
		print("Door 1 is Open.")
		sleep(0.8)
	  else
		print("Door 1 is Closed.")
		sleep(0.8)
	  end
	elseif door == '2' then
	  rs.setBundledOutput("bottom", colors.black)
	  sleep(0.2)
	  rs.setBundledOutput("bottom", 0)
	  local two = rs.getBundledInput("bottom", colors.blue)
	  if two == true then
		print("Door 2 is Open.")
		sleep(0.8)
	  else
		print("Door 2 is Closed.")
		sleep(0.8)
	  end
	elseif door == '3' then
	  rs.setBundledOutput("bottom", colors.white)
	  sleep(0.2)
	  rs.setBundledOutput("bottom", 0)
	  local three = rs.getBundledInput("bottom", colors.red)
	  if three == true then
		print("Door 3 is Open.")
		sleep(0.8)
	  else
		print("Door 3 is Closed.")
		sleep(0.8)
	  end
	else
	  print("Unrecignized Command.")
	  sleep(1)
	end
  end
end
password()
Zudo #2
Posted 13 July 2013 - 01:07 AM

tostring(rs.getBundledInput("bottom", colors.purple))
Try that instead.
AadamZ5 #3
Posted 13 July 2013 - 01:18 AM
Still getting same error.
Zudo #4
Posted 13 July 2013 - 01:24 AM
I am trying your code out now. :)/>
Zudo #5
Posted 13 July 2013 - 01:27 AM

function clear()
  term.clear()
  term.setCursorPos(1, 1)
end

function doorcheck()
  local one = tostring(rs.getBundledInput("bottom", colors.purple))
  print("Is Door 1 Open? "..one)
end

function doors()
  while true do
		clear()
		doorcheck()
		print("Which door to manipulate? (1, 2, or 3)")
		local door = read()
		if door == '1' then
		  rs.setBundledOutput("bottom", colors.brown)
		  sleep(0.2)
		  rs.setBundledOutput("bottom", 0)
		  local one = rs.getBundledInput("bottom", colors.purple)
		  if one == true then
				print("Door 1 is Open.")
				sleep(0.8)
		  else
				print("Door 1 is Closed.")
				sleep(0.8)
		  end
		elseif door == '2' then
		  rs.setBundledOutput("bottom", colors.black)
		  sleep(0.2)
		  rs.setBundledOutput("bottom", 0)
		  local two = rs.getBundledInput("bottom", colors.blue)
		  if two == true then
				print("Door 2 is Open.")
				sleep(0.8)
		  else
				print("Door 2 is Closed.")
				sleep(0.8)
		  end
		elseif door == '3' then
		  rs.setBundledOutput("bottom", colors.white)
		  sleep(0.2)
		  rs.setBundledOutput("bottom", 0)
		  local three = rs.getBundledInput("bottom", colors.red)
		  if three == true then
				print("Door 3 is Open.")
				sleep(0.8)
		  else
				print("Door 3 is Closed.")
				sleep(0.8)
		  end
		else
		  print("Unrecignized Command.")
		  sleep(1)
		end
  end
end

function password()
  clear()
  while true do
		term.write("Password: ")
		local pass = read("*")
		if pass == "1598" then
		  doors()
		else
		  clear()
		  print("Password Incorrect.")
		  sleep(1)
		end
  end
end

password()


That worked for me.

When you say the function isn't working, it actually does work, but it was passed the wrong parameters.
AadamZ5 #6
Posted 13 July 2013 - 01:47 AM
Oh! Thank you very much!
Will try now.
AadamZ5 #7
Posted 13 July 2013 - 01:49 AM
Ok, But now, Instead of it displaying a decimal in the function doorcheck(), is it possible to return a true/false?
Zudo #8
Posted 13 July 2013 - 01:55 AM
Do an if statement without the tostring()


if one then
 print("The door is open")
else
 print("The door is closed")
end
AadamZ5 #9
Posted 13 July 2013 - 02:14 AM
So this?

function doorcheck()
  local one = rs.getBundledInput("bottom", colors.purple)
  if one then
    print("Door 1 is Open.")
  else
    print("Door 1 is Closed.")
  end
end
Because I'm always getting:
"Door 1 is Open."
Without ever changing even when it is closed.
Zudo #10
Posted 13 July 2013 - 02:30 AM
How is it set up? If the computer is powering the door, check rs.getBundledOutput()
AadamZ5 #11
Posted 13 July 2013 - 02:43 AM
How is it set up? If the computer is powering the door, check rs.getBundledOutput()

Im using Toggle Latches with say a brown wire leading to the toggle connected to the bundle and a purple wire connected to the output of the toggle, door and bundle.
The bundle is connected to the computer.
Zudo #12
Posted 13 July 2013 - 02:45 AM
OK, you have well and truely lost me. I used redpower for rednet, but now I don't use it at all :(/>
AadamZ5 #13
Posted 13 July 2013 - 02:53 AM
lol. Alright, I might change my setup a little bit. So it works with your methods.
Thanks alot for the help!