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

attempt to call nill using rs. commands

Started by Blunty, 13 July 2012 - 07:41 AM
Blunty #1
Posted 13 July 2012 - 09:41 AM
so here is the function that errors

function powerup2()
print("powering all redstone lines")
rs.setBundledOutput("left", colors.cyan)
rs.setBundledOuput("left", (colors.combine(rs.getBundledInput("left"), colors.red))) <—- code errors here with attempt to call nill
rs.setBundledOuput("left", (colors.combine(rs.getBundledInput("left"), colors.green)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledInput("left"), colors.yellow)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledInput("left"), colors.orange)))
print("all redstone lines engaged")
listen()
end

any ideas? am i approaching the redpower commands wrong? the idea is to get computers talking on the bundled cable , is this possible on one bundle?

thanks in advance
blunty (bnbserver.co.uk)
KevinW1998 #2
Posted 13 July 2012 - 09:50 AM
"Ouput"
You need to write "Output"
attempt to call nil = syntax error
Blunty #3
Posted 13 July 2012 - 09:55 AM
like so ?

function powerup2()
print("powering all redstone lines")
rs.setBundledOutput("left", colors.cyan)
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.red))) <—- attempt to call nil error here still
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.green)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.yellow)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.orange)))
print("all redstone lines engaged")
listen()
end

have also tried various other ays of using the commands , such as spreading them out to multiple steps and using variables , all to no avail
Blunty #4
Posted 13 July 2012 - 10:15 AM
so i set up a test rig and this is the new error

rs.setBundledOutput("left", colors.cyan)
d = colors.test (rs.getBundledInput("left"), colors.cyan)
print(d) <— returns "true"
rs.setBundledOutput("left", (color.combine(rs.getBundledInput("left"), colors.red))) <—- errors here with "attempt to index ? (a nil value)"
e = rs.testBundledOutput("left", colors.red)
print(e)

note have tried both BundledInput and BundledOutput and get the same result

edit : have now found the lua prompt , entering that line into it provides no errors on its own
KevinW1998 #5
Posted 13 July 2012 - 10:23 AM
rs.setBundledOutput("left", (color.combine(rs.getBundledInput("left"), colors.red))) – "colors.combine" and not "color.combine"
Blunty #6
Posted 13 July 2012 - 10:30 AM
exclent the test rig now works , but i cant spot any errors in the original function , ill post the whole program now as it might be a wider issue


-- master control program
function healthcheck()
x = 0
y = 0
z = 0
rs.setBundledOutput("left", colors.black)
if rs.testBundledInput("left", colors.black) == true then
print("conection confirmed")
powerup2()
else
print("connection broken")
end
end
function powerup2()
print("powering all redstone lines")
rs.setBundledOutput("left", colors.cyan)
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.red)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.green)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.yellow)))
rs.setBundledOuput("left", (colors.combine(rs.getBundledOutput("left"), colors.orange)))
print("all redstone lines engaged")
listen()
end
function listen()
print("listening for change of redstone state on red wire")
red = rs.testBundledInput("left", colors.red)
while red == true do
red = rs.testBundledInput("left", colors.red)
print("retrying in 20 seconds")
sleep(20)
end
if red == false then
print("change of state found")
phase2()
end
end
function phase2()
print("phase 2 now active")
x = (x + 1)
d = rs.getBundledInput("left")
e = colors.combine(d, colors.red)
rs.setBundledOutput("left", e)
print("red line reactivated")
d = rs.getBundledInput("left")
e = colors.subtract(d, colors.green)
rs.setBundledOutput("left", e)
print("green line deactivated")
if x == 8 then
x = 0
phase3()
else
listen()
end
end
function phase3()
print("phase 3 now active")
y = (y + 1)
d = rs.getBundledInput("left")
e = colors.subtract(d, colors.yellow)
rs.setBundledOutput("left", e)
print("yellow line deactivated")
if y == 8 then
y = 0
phase4()
else
listen()
end
end
function phase4()
print("phase 4 now active")
z = (z + 1)  
d = rs.getBundledInput("left")
e = colors.subtract(d, colors.orange)
rs.setBundledOutput("left", e)
print("orange line deactivated")
print("this factory has made", z, "HV solar cells")
listen()
end
healthcheck()

KevinW1998 #7
Posted 13 July 2012 - 10:32 AM
So whats the error?
Blunty #8
Posted 13 July 2012 - 10:34 AM
factoryv2:17:attempt to call nill
KevinW1998 #9
Posted 13 July 2012 - 10:37 AM
"Ouput"
You need to write "Output"
attempt to call nil = syntax error
You've should read this post
Blunty #10
Posted 13 July 2012 - 10:38 AM
*HEADDESK* now i feel silly