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

Need help with error (Colors:36)

Started by GgnoreZz, 29 July 2014 - 03:35 PM
GgnoreZz #1
Posted 29 July 2014 - 05:35 PM
When i try to run this program, i get the error "colors:36: to few arguments" I would like some help,


local cableSide = "bottom"  -- Or where ever your cable is.

local mon = peripheral.wrap("top") -- Or where ever your colour monitor is.
mon.setTextColor(colours.white)
mon.setBackgroundColor(colours.black)
mon.clear()

local xLen, yLen = mon.getSize()

local myEvent

-- Menu items.
-- Add as desired, but don't exceed 16 entries.
local switches = {
   ["Power Tower #1"] = {colour = colours.orange,  screenRow =  1},
   ["Power Tower #2"] = {colour = colours.magenta,  screenRow =  2},
   ["Power Tower #3"] = {colour = colours.lightBlue,  screenRow =  3},
   ["Power Tower #4"] = {colour = colours.yellow,  screenRow =  4},
   ["Power Tower #5"] = {colour = colours.lime,  screenRow =  5},
   ["Power Tower #6"] = {colour = colours.pink,  screenRow =  6},
   ["Power Tower #7"] = {colour = colours.gray,  screenRow =  7},
   ["Power Tower #8"] = {colour = colours.lightGray,  screenRow =  8},
   ["Power Tower #9"] = {colour = colours.cyan,  screenRow =  9}}


-- Initial menu render:
for key,value in pairs(switches) do
   mon.setBackgroundColor(colours.black)
   mon.setCursorPos(2,value.screenRow)
   mon.write(key)
   mon.setCursorPos(xLen-5,value.screenRow)
  
   if colours.test(rs.getBundledOutput(cableSide),value.colour) then
	 mon.setBackgroundColor(colours.green)
	 mon.write(" On  ")
   else
	 mon.setBackgroundColor(colours.red)
	 mon.write(" Off ")
   end
end   

-- Main program loop.
while true do
   myEvent = {os.pullEvent("monitor_touch")}
  
   for key,value in pairs(switches) do if myEvent[4] == value.screenRow then
	 mon.setCursorPos(xLen-5,value.screenRow)

	 if not colours.test(rs.getBundledOutput(cableSide),value.colour) then
	   mon.setBackgroundColor(colours.green)
	   mon.write(" On  ")
	   rs.setBundledOutput(cableSide,colours.combine(rs.getBundledOutput(cableSide),value.colour))
	 else
	   mon.setBackgroundColor(colours.red)
	   mon.write(" Off ")
	   rs.setBundledOutput(cableSide,colours.subtract(rs.getBundledOutput(cableSide),value.colour))
	 end
	
	 break
   end end
end
hbomb79 #2
Posted 29 July 2014 - 09:42 PM
As far as I know your spelling of colour is not how the game would like it… Try

colors.black with no caps…
flaghacker #3
Posted 29 July 2014 - 09:57 PM
As far as I know your spelling of colour is not how the game would like it… Try

colors.black with no caps…

http://computercraft.info/wiki/Colors_(API)

You can use both. Are you sure that's the exact code and error? And what is the name of your program?
Edited on 30 July 2014 - 04:33 AM
hbomb79 #4
Posted 29 July 2014 - 10:22 PM
As far as I know your spelling of colour is not how the game would like it… Try

colors.black with no caps…

http://computercraft.info/wiki/Colors_(API)

You can use both. Are you sure that's the exact code and error? And what is the name of your program?

That URL does not work, I don't see any evidence of being able to use both on the official colours api web page, maybe it just doesn't say.. If I was at the PC I would test

another thing, your local event, could that be causing problems because it wasn't defined?

Also, the value screenRow is that causing problems? I don't really use that too much, is value some sort of operator or similar?
KingofGamesYami #5
Posted 29 July 2014 - 10:58 PM

colour = colours.lightGrey
colour = colours.grey
GgnoreZz #6
Posted 30 July 2014 - 02:47 AM
I found the fix, turns out all i needed to do was, change "Colours" to colors.
flaghacker #7
Posted 30 July 2014 - 06:32 AM
I found the fix, turns out all i needed to do was, change "Colours" to colors.

That's strange!
colors wikipage said:
For the non-American English version just replace 'colors' with 'colours' and it will use the other API, colours—which is exactly the same, except in non-American English (e.g. gray is spelt grey and lightGray is spelt lightGrey).
KingofGamesYami #8
Posted 30 July 2014 - 03:05 PM
You can use colours instead, but you did not use the correct spelling of lightGray & gray. When using colours, they are spelled lightGrey & grey.