Jump to content




colors:36: Too few Arguments


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

#1 AadamZ5

  • Members
  • 12 posts

Posted 12 July 2013 - 10: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()


#2 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 13 July 2013 - 12:07 AM

tostring(rs.getBundledInput("bottom", colors.purple))
Try that instead.

#3 AadamZ5

  • Members
  • 12 posts

Posted 13 July 2013 - 12:18 AM

Still getting same error.

#4 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 13 July 2013 - 12:24 AM

I am trying your code out now. :)

#5 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 13 July 2013 - 12: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.

#6 AadamZ5

  • Members
  • 12 posts

Posted 13 July 2013 - 12:47 AM

Oh! Thank you very much!
Will try now.

#7 AadamZ5

  • Members
  • 12 posts

Posted 13 July 2013 - 12:49 AM

Ok, But now, Instead of it displaying a decimal in the function doorcheck(), is it possible to return a true/false?

#8 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 13 July 2013 - 12:55 AM

Do an if statement without the tostring()

if one then
 print("The door is open")
else
 print("The door is closed")
end


#9 AadamZ5

  • Members
  • 12 posts

Posted 13 July 2013 - 01: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.

#10 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 13 July 2013 - 01:30 AM

How is it set up? If the computer is powering the door, check rs.getBundledOutput()

#11 AadamZ5

  • Members
  • 12 posts

Posted 13 July 2013 - 01:43 AM

View PostZudoHackz, on 13 July 2013 - 01:30 AM, said:

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.
Posted Image

#12 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 13 July 2013 - 01:45 AM

OK, you have well and truely lost me. I used redpower for rednet, but now I don't use it at all :(

#13 AadamZ5

  • Members
  • 12 posts

Posted 13 July 2013 - 01:53 AM

lol. Alright, I might change my setup a little bit. So it works with your methods.
Thanks alot for the help!





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users