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

[ERROR] simple logging program help

Started by hunter239833, 20 May 2013 - 02:42 PM
hunter239833 #1
Posted 20 May 2013 - 04:42 PM
i could use some help setting up the basics of a logging program, i have created a program and am having trouble with the debugging. i know it is very basic and an absolute mess, but i want to do this without looking at someone else's program as i wanted to do this of my own accord, any sudgestions?
here is the program:

while true do
  turtle.select(1)
  turtle.place()
  turtle.select(2)
  if turtle.compare()==true then
	turtle.dig()
	turtle.forward()
	if turtle.compareUp()==true then
	  turtle.digUp()
	  turtle.up()
	  "t"="t" + 1
	  end
	else
	  turtle.turnLeft(2)
	  turtle.down("t")
	  turtle.forward()
	  turtle.turnLeft(2)
	  end
end
while true do
  turtle.select(1)
  turtle.place()
  turtle.select(2)
  if turtle.compare()==true then
	turtle.dig()
	turtle.forward()
	if turtle.compareUp()==true then
	  turtle.digUp()
	  turtle.up()
	  "t"="t" + 1
	  end
	else
	  turtle.turnLeft(2)
	  turtle.down("t")
	  turtle.forward()
	  turtle.turnLeft(2)
	  end
end
thanks
Lyqyd #2
Posted 21 May 2013 - 02:47 PM
Split into new topic.
W00dyR #3
Posted 21 May 2013 - 03:30 PM
I think you copy-pasted your code twice in a row first of all, but thats fine :P/>

You assign the variable "t" = "t" + 1, but you never told what the starting value was, so it will error there, best way to fix is to put on the first line of your script

t = 0 -- I put 0 here, but it can be 1 as well, or whatever number you want.
If you want this number to be reset every time it repeats your loop, put it on the second line, after the "while true do"

Also, instead of having "t" = "t" + 1, make it

t = t + 1
This means that when reading it, you have to make it read t and not "t", so in turtle.down("t") use turtle.down(t)

Another tip, saves some typing, but not really required:

if turtle.compareUp()==true then
You compare it with true, but you don't have to compare it :)/>

if turtle.compareUp() then
Works exactly the same because turtle.compareUp() gives you a boolean value, either true of false. The code will read it as "if true then", which means he will do it, because its true. If its false, meaning the compareUp() does not compare, then it will not do it.

EDIT: Edited out the last part, read it wrong in your code :)/>