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

[Error] bit:40: bad argument: double expected, got nil

Started by mijoki, 26 June 2012 - 08:17 AM
mijoki #1
Posted 26 June 2012 - 10:17 AM
I am getting the error message: bit:40: bad argument: double expected, got nil
Here is the code:
function getStates()
curColour = rs.getBundledInput("right")
state =
{
[1] = colors.test(curColours, colors.white),
[2] = colors.test(curColours, colors.orange),
[3] = colors.test(curColours, colors.magenta),
[4] = colors.test(curColours, colors.lightBlue),
[5] = colors.test(curColours, colors.yellow),
[6] = colors.test(curColours, colors.lime),
[7] = colors.test(curColours, colors.pink),
[8] = colors.test(curColours, colors.gray),
[9] = colors.test(curColours, colors.lightGray),
[10] = colors.test(curColours, colors.cyan),
[11] = colors.test(curColours, colors.purple),
[12] = colors.test(curColours, colors.blue),
[13] = colors.test(curColours, colors.brown),
[14] = colors.test(curColours, colors.green),
[15] = colors.test(curColours, colors.red),
[16] = colors.test(curColours, colors.black),
}
return state
end
timer1 = os.startTimer(2)
pstate = getStates()
function rsEvent()
if rs.testBundledInput("right", colors.white) then
print("Furnaces = On")
else
print("Furnaces = Off")
end
cstate = getStates()
if (pstate[1] == false and cstate[1] == true) then
print("Furnaces Turned On")
end
pstate = cstate
end
function tick()
timer1 = os.startTimer(2)
end
repeat
local event,p1 = os.pullEvent()
if event == "redstone" then
rsEvent()
elseif event == "timer" then
if p1 == timer1 then
tick()
end
end
until event == "char" and p1 =="f"

Can anyone see where I have gone wrong?

I am trying to create a system which will tell me the status of certain devices and tell me about any changes. I am also going to add the monitor side of things at a later date once all device checks are in place.
Xtansia #2
Posted 26 June 2012 - 10:29 AM
In your getStates function you define the variable curColour but in your colors.test call you use curColours,
Just change:
curColour = rs.getBundledInput("right")
To:
curColours = rs.getBundledInput("right")
mijoki #3
Posted 26 June 2012 - 10:32 AM
Aha! Thank you, I was never good with the little mistakes. :P/>/>