I just made this small script in computercraft:
running = true
Door = "nil"
while running == true do
Door = read()
if Door == "exit()" then
running = false
elseif Door == "1" then
serialData (1, 0, 0, 0)
end
function serialData (A, B, C, D)
redstone.setOutput ("bottom", true)
if A == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if B == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if C == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
if D == 1 then
redstone.setOutput ("bottom", true)
else
redstone.setOutput ("bottom", false)
end
sleep (0.2)
end
end
Every time I run it, I get the 'attempted to call nil' message after pressing '1' and therefore written '1' to Door.
Does anyone know what I've done wrong?









