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

[Question] [Error] What do the error codes mean?

Started by Pokechu22, 03 July 2012 - 07:43 PM
Pokechu22 #1
Posted 03 July 2012 - 09:43 PM
I wrote a program that was supposed to work with Redpower as an automated tree farm using frames. (The inputs are: back cable: white: go down; orange: extend pistons to push tree; magenta: go up; on right cable: input: white - tree grown; orange: ignore white signal.) The code is:


function go_down() --Output of 1 = go down
redstone.setBundledOutput('back', 1)
sleep(1)
redstone.setBundledOutput('back', 0)
end
function push() --Output of 2 = Pistons extend
redstone.setBundledOutput('back', 2)
sleep(1)
redstone.setBundledOutput('back', 0)
end
function go_up() --Output of 4 = go up
redstone.setBundledOutput('back', 4)
sleep(1)
redstone.setBundledOutput('back', 0)
end
function move_series()
redstone.setBundledOutput('right',2)
while i > 7 do
go_down()
push()
i = i + 1
end
i = 1
while i > 7 do
go_up()
i = i + 1
end
redstone.setBundledOutput('right',0)
end
function plant()
rs.setBundledOutput('right',4)
sleep(1)
rs.setBundledOutput('right',0)
end
function main()
if (colors.test(redstone.getBundledInput("back"), colors.white) == true then
move_series()
else
main()
end
main()
end
main()
But when I run it, all I get is the message "178"

What does that message mean?
MysticT #2
Posted 03 July 2012 - 09:50 PM
I'm not sure if it means anything. You should get an error message, with a description of the error and the line.
For some reason this happens sometimes after a crash in the computer (mostly with infinite loops that don't yield and recursive functions that overflow the stack).
Normally a restart of the computer is enough and you get an error message. If that doesn't work, try restarting minecraft.
You might want to remove the recursive function and make a real loop there, cause that crashes the computer.
Try removing the "main" function and using a loop like:

while true do
  os.pullEvent("redstone") -- wait for a change in redstone
  if rs.testBundledInput("back", colors.white) then
	move_series()
  end
end
Pokechu22 #3
Posted 03 July 2012 - 10:42 PM
Whenever this program ends(user termination or finished, it will say 178. I still don't know why. But thanks for the fix, now it is not crashing