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

Problem with table ?

Started by Fiixii52, 25 June 2016 - 06:11 PM
Fiixii52 #1
Posted 25 June 2016 - 08:11 PM
Hello,

I'm trying to write my own first big turtle program. It consists of a quarry program, with modulable dimensions and enderchests to take fuel and send ores.
I wrote a table (Called MiningSave) where the turtle can determine if it has reached the limit of the zone it has to dig.
In other words, when having dug a full line, the turtle is supposed to turn and change the line to continue digging.
I used arguments to type variables into the program (With Arguments = {…})

The problem is that after many testing, the turtle won't stop digging forward instead or restricting himself in the zone.

Here is a pastebin link to the program : http://pastebin.com/nYGg1eCV

I tried many things to localise the problem's source, and I think it occurs in line 272 and further. But I have absolutely no idea what it can be because, to my eyes, I don't see any errors (Correct me if I'm wrong though, I'm what you could call a Lua newbie lol).

Any help please ?

Fiixii52
KingofGamesYami #2
Posted 25 June 2016 - 08:15 PM
First thing I noticed that was weird is these lines:

                           MiningSave[1] = MiningSave[2]
                           MiningSave[2] = (Perimeter-2*MiningSave[1])/2 -- Calculates the new width with the perimeter which stays the same. If we would have typed MiningSave[2] = MiningSave[1], it would have taken the new value of MiningSave[1].

While this might work, I would do this:

                           local temp = MiningSave[ 1 ]
                           MiningSave[1] = MiningSave[2]
                           MiningSave[2] = temp
MKlegoman357 #3
Posted 25 June 2016 - 08:18 PM
Common, this is Lua:


MiningSave[1], MiningSave[2] = MiningSave[2], MiningSave[1]