Jump to content




Problem with table ?


2 replies to this topic

#1 Fiixii52

  • Members
  • 4 posts

Posted 25 June 2016 - 07: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

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 25 June 2016 - 07: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


#3 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 25 June 2016 - 07:18 PM

Common, this is Lua:

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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users