Quantcast Map tracker - LoTROInterface
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO > Developer Discussions > Lua Programming Help (L)

Reply
Thread Tools Display Modes
  #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
  #2  
Unread 09-17-2013, 10:44 AM
Equendil Equendil is offline
The Undying
Interface Author - Click to view interfaces
 
Join Date: Apr 2011
Posts: 52
I have no idea what minecraft is about let alone how its scripting capabilities work but if that's a script that is called every so often by the game engine, what you are doing here is systematically create a new empty array you assign to 'map' every time the script is called, so naturally, it 'forgets' what you have done the last time it was called and you end up with 'nil' values.

You could either move the creation of the 'map' array to some initialization script if that's possible or failing that, make sure you only create the 'map' array once if it does not exist:

Code:
if map == nil then
map = {};
end
__________________
Author of LIP, Bootstrap and Baruk
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Map's Quest Tracker XML? artificeren XML modification help (L) 1 08-26-2011 06:50 PM
Access to the map Fido Lua Programming Help (L) 4 08-10-2011 12:58 PM
Creep Map help Madduck Lua Programming Help (L) 4 09-16-2010 10:33 PM
Mini-map felgrath Interface Help (L) 2 03-01-2008 02:02 PM
Map tralkar General Authoring Discussion (L) 1 07-30-2007 12:06 AM


All times are GMT -5. The time now is 02:47 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui