Thread: Map tracker
View Single Post
  #1  
Unread 09-14-2013, 01:40 PM
crys17p crys17p is offline
The Wary
 
Join Date: Sep 2013
Posts: 1
Map tracker

Hello guys i am new to lua and i have a problem. I am making a kind of map tracker for a turtle bot in minecraft(yes i know they have forums specifically for that but i am not getting a response form them). The map tracker stores the last five moves made into an array. Afterwards if the robot has a certain level of fuel it retraces it's steps by doing the inverse of the five last steps.

The robot stores the steps correctly the problem is when it enters the condition with low fuel that the values of the array become all nil and none of the conditions match and hence does nothing. It is strange because if i don't use the if statements for checking fuel level and fuel item count it works. Thank you for your response in advance.


map = {}
j = 5
i = 5


if turtle.getFuelLevel() < 100 then

if turtle.getItemCount(1) == 0 then

for count = 1,j do

if map[i] == 1 then
turtle.back()
end

if map[i] == 2 then
turtle.forward()
end

if map[i] == 3 then
turtle.down()
end

if map[i] == 4 then
turtle.up()
end

if map[i] == 5 then
turtle.turnRight()
end

if map[i] == 6 then
turtle.turnLeft()
end
i = i - 1
end

else
turtle.select(1)
turtle.refuel()
end


else
i = 5
turtle.forward()
map[1] = 1

turtle.up()
map[2] = 3


turtle.forward()
map[3] = 1


turtle.up()
map[4] = 3


turtle.back()
map[5] = 2


end
Reply With Quote