Jump to content




Colors :36: Too Few Arguments


6 replies to this topic

#1 Arimus

  • Members
  • 15 posts

Posted 16 August 2013 - 06:28 AM

Hi everyone,

This is really driving me crazy. Let me say first that I am very new to programming and computercraft.

My situation:

I have a monitor setup with a computer under it. Going into the right side of the computer is a bundled cable connected to level emitters from my applied energistics storage system. These emitters control mob spawners. Each color in the bundle represents a mob spawner. I am trying to show on screen a number of buttons which are shown either red or green to indicate if the spawner is on or not. I am using a button API to draw the buttons on screen. This API lets me set the state...perfect!

I am using the following code: (just test code for now)

os.unloadAPI("button")
os.loadAPI("button")
local mon = peripheral.wrap("top")
mon.clear()
							 
button.setMon("top")	 
 
function check(button, wireColor)
print("test")
if (colors.test (rs.getBundledInput("right"), colors.wireColor)) == true then
  button.setState(button, false)
else
  button.setState(button, true)
end
end
 
button.add("endermen", "Endermen", "toggle", 5, 5, 20, 8, colors.lime, colors.red, colors.white, endermen)
button.setState("endermen", false)
button.draw()
while true do
check("endermen", white)
sleep(60)
end

When I run this program I get the message "colors :36: too few arguments" and I can't for the life of me figure out what it is. There are probably other errors in this code but I don't get that far as the program stops just after the "print("test") statement.

Does anyone have any suggestions?

Thanks!!

#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 16 August 2013 - 07:14 AM

colors.wireColor might be nil. I don't see its declaraion anywhere. And, if you pass a nil argument as the last argument, it's like you haven't passed that argument at all. Lua logic.

#3 nolongerexistant

  • Validating
  • 201 posts
  • LocationNetherlands

Posted 16 August 2013 - 07:21 AM

if (colors.test (rs.getBundledInput("right"), colors.wireColor)) == true then
colors.wireColor doesn't exist. You just need:

if (colors.test (rs.getBundledInput("right"), wireColor)) == true then
And pass wireColor to the function like:
colors.red
colors.green
colors.blue


#4 Tiin57

    Java Lunatic

  • Members
  • 1,412 posts
  • LocationIndiana, United States

Posted 16 August 2013 - 07:22 AM

You'll want to use "colors[wireColor]", not "colors.wireColor".

#5 albrat

  • Members
  • 162 posts
  • LocationA Chair

Posted 16 August 2013 - 07:36 AM

I know the problem... You are handing a "white" to the program as a varible... You should hand the varible "colors.white" to the function.

function check(button, wireColor)
print("test")
if (colors.test (rs.getBundledInput("right"), colors.wireColor)) == true then  --// you should use wireColor not colors.wireColor.
  button.setState(button, false)
else
  button.setState(button, true)
end
end

check("endermen", white)  --// You should send the colors.white here.


with these two changes the code should work.

Also white is not defined at all as a varible. so you program was handing a nil value to wireColor .

edit ::
Ah beaten to the chase... lol - I went to save my food from burning while posting.

Edited by albrat, 16 August 2013 - 07:37 AM.


#6 Arimus

  • Members
  • 15 posts

Posted 16 August 2013 - 08:06 AM

Thanks guys much appreciated. I will check it out when I get home!

#7 Arimus

  • Members
  • 15 posts

Posted 16 August 2013 - 09:44 AM

I got this program working. Many thanks everyone!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users