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

Gps Goto Program

Started by Bindre12, 19 December 2012 - 03:38 PM
Bindre12 #1
Posted 19 December 2012 - 04:38 PM
GPS Goto Program 1.3

Tell the Turtle where to go…




Before you Begin using this program, you need to set up a Gps array at the top of the world (see picture):




If you need help setting up go to this tutorial: [How to guide] GPS Global Position System

(I recommend using Real Coordinates (use f3 or Rei's Minimap) not Relative like in picture)


In Minecraft:

East, West = x axis

north, south = z axis

up, down = y axis


Once you have that you are ready to start using my program


This is my take on the goto program and hope you like it!

This program can be extended beyond a turtle to a frame quarry or similar for GPS accuracy!


- Must have a 1 block space in front or back of the Turtle and have a Fuel Level of 80 or higher or Unlimited to start the goto program -


- What you need: Wireless Mining Turtle, and a Gps Array

- Program use: goto X Z Y


Feel free to edit or use in other programs, Just provide credit and a link to this page


If you have suggestions on how I can make my code better, or have a bug, comment, I would like to hear it, and will try and fix it or add it in

And remember I'm new to Lua


Change Log:

Spoiler1.0 - Initial Release
1.1 - Put in debug code (ComputerCraft 1.47 sometimes durps and skips some commands, Might be fixed in 1.481)
1.2 - Added in comments, shortened the code up a little, removed debug code, and added a fuel level indicator (won't run unless fuel level is 80 or higher, or is unlimited)
1.3 - Added a check at the end of the program to see if the Turtle made it to the destination, and more comments to aid modifying


Code/Downloads:

SpoilerPastebin?
pastebin.com/BD3pJVBr

use: pastebin get BD3pJVBr goto
(Http config option must be enabled)

Enjoy!
grand_mind1 #2
Posted 21 December 2012 - 02:22 PM
Really nice job! You say you are new to Lua but this is awesome!
Tigsen #3
Posted 21 December 2012 - 03:42 PM
Error on line 298, and doesn't seem to do anything but move forward and back a single block then exit for me.
Bindre12 #4
Posted 22 December 2012 - 04:59 PM
grand_mind1 - thanks, this is only my second project so I'm still a noob :lol:/>

Tigsen - Does the Error happen all the time?, i think i know what causes it, but I don't think its a problem with my code, but with Computer Craft itself..
Bindre12 #5
Posted 22 December 2012 - 05:12 PM
I think I fixed that problem, instead of throwing and error, it will just print "nil" for any missing variable that Computer Craft derps on

Don't know if it was a failure to register a value to a variable, or something else
Tigsen #6
Posted 23 December 2012 - 06:10 AM
Still same thing for me forward then back and stops, I have some time this weekend so will toss some debug statments in it and take a look
Tigsen #7
Posted 23 December 2012 - 07:15 AM
well my gpsnet was part of the issue, checking it all out again
Bindre12 #8
Posted 24 December 2012 - 03:31 PM
Updated, ComputerCraft 1.47 sometimes durps and skips some commands during lag spikes or low FPS, so i put in a debug code for the 'Print' command
Might be fixed in 1.481, doing some Extensive testing to see…
doger doughnut #9
Posted 28 December 2012 - 06:07 PM
this is a cool program, keep getting lost when trying to read the code :mellow:/>
Bindre12 #10
Posted 30 December 2012 - 09:00 AM
yea there is a lot of variables, trying to see if i can get away with using less and shortening up my code
Ikkalyzte #11
Posted 30 December 2012 - 03:00 PM
I made a program similar to this, they are very useful. It looks fairly good, except for a couple minor things:
  • The initial declaration "local dir, disx, disy, disz = 0" will not work as I think is intended; 0 will be assigned to dir, but not the other variables. To do that you would have to do something similar to "local dir, disx, disy, disz = 0, 0, 0, 0"
  • So many if - elses! Not really an issue, but some use of "return" in your functions could help. Do you know how that works?
  • Finally, I agree: reading it is a little bit of a chore. I totally understand, as my programs can have the same issues. Maybe having variable names more descriptive than dnx, doz, mdirs, and the like? Also, comments on what the variables are (when you declare them) could help
Good luck in your bugfixing. It's always the most tedious part :P/>
Bindre12 #12
Posted 31 December 2012 - 09:08 AM
1) Oh i thought that would assign 0 to all of those variables, didn't want a whole block of decorations

2) Haven't played with the return function, still learning Lua, don't know how that works, if - elses was just easier to use :D/>

3) Yea working on that
Ikkalyzte #13
Posted 31 December 2012 - 10:23 AM
I figured because you knew functions, you could know return. What tutorial are you using?
Bindre12 #14
Posted 31 December 2012 - 11:01 AM
not using a tutorial, just Trial and error, and wingin it
Bindre12 #15
Posted 31 December 2012 - 11:12 AM
Made it easier to understand what all those variables are for and what they stand for, hope this helps
doger doughnut #16
Posted 03 January 2013 - 10:27 AM
ohh yea, easier to understand now