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

[cc1.5.x][build 16] Gps Tower Builder

Started by Cozzimoto, 07 November 2013 - 07:47 AM
Cozzimoto #1
Posted 07 November 2013 - 08:47 AM
GPS Tower Builder

Easily Construct and (WIP: Deconstruct) GPS Clusters

Current Build is #16 (November 10, 2013)



Hello nerds, i have not really seen much on GPS clusters out there and ive seen a few programs that use GPS so why not deliver a way to get your satellites up in the sky without you having to do so. May i present my GPS Tower Builder. This program combines my old two GPS tower creator scripts into one where it can run and find coordinates off of a current GPS cluster or enter them in manually to start out. Also in my old program you had to create a separate startup file to get the GPS computers to run, not anymore this program creates a file on disk to run that creates the file to be saved on the computer with the correct coordinates so you do not have to. As for the clusters themselves they will always be constructed in the same orientation no matter what the turtle's orientation.

!! Important: include your 'debug.txt' file in post for bugs and errors !!

Usage:
  • for entering orientation you can use actual inworld facings (0,1,2,3) or you can enter in "North" or just the letter for a shorthand "N", "n" it is not case sensitive
  • to update program simply pass in -u argument
    <FILENAME> -u
  • to enable debugging info and log to file pass in argument "-d"
    <FILENAME> -d
  • if you are having errors updating pass in the debug argument after your update argument
    <PROGRAMNAME> -u -d
Features:
  • Creates a install file for activating gps clusters
  • Predicts fuel consumption/usage with details on how much coal or wood you need
  • Orientation smart
  • Cluster is constructed in same orientation
  • Simple &amp; easy GUI interface
  • Inline Program updates (download once)
  • Save cluster locations on the turtle in a ".pos" file
  • Predicts next locations for cluster to expand coverage
  • Debugging
Planned features:
  • consolidate different file types into one package
  • "-r" argument to disassemble a GPS cluster
Ideas to implement:
  • goto next cluster position if user wants
  • intergrate option for a turtleAI API
Bugs and/or things to fix:
  • none at the moment
In Conclusion i would love feedback. use it, try and break it (within reason) as i have been working on this program the past few days and I have tested this to the best of my ability. There is still some things i want to add but for those of you that use it and think i missed something LET ME KNOW =D

Screenshots
SpoilerGPS Cluster Orientation is the top main computers face North/South axis and the Secondary Computers are on the East/West axis



Nice to show some Statistics of your Creaton as well as save the data after the Program finishes

How The Next Cluster Prediction Works
Spoiler
Based off of several different tests that i did on a simple ping program i made to ping two computers together and output the distance, i made this graph that shows how rednet range affects distance at different Y axis levels on a map height GPS Cluster of 255.

I've noticed that the higher you go up in the air on the Y-Axis the larger the coverage is for rednet from the GPS cluster location. so i decided a good round number for my implementation is 325. i have gone with this number by the results i got from the GPS Cluster at sea level, [Y 64].

So with that being said how do i expand my coverage area? Since 325 is the Radius the coverage area of one GPS Cluster is a circle. I have taken the horizontal Diameter of the first circle and touch the Veritcal Diameter of the second circle as a tangent so that the circle centers are being laid out diagonally. The Segments that overlap are from the chords of the horizontal and verital Diameters.

## Changelog ##
SpoilerBuild 15-16 (November 10th changes)
  • 15: + debugging information "debug.txt"
  • 15: + error handling for turtles without pickaxes
  • 16: fixed error on debugging a function erroring out
Build 10-14 (November 9th changes)
  • 10: Fix program not starting from the update check
  • 11: + more specific error handling
  • 11: condensed some lines to save space
  • 11: keep materials within the first 8 slots
  • 11: reworked gps location sequence
  • 12: + ".pos" GPS cluster position file
  • 12: + logging of stats on each cluster built
  • 12: Prepared for determining the next cluster locations
  • 13: + next GPS Cluster Locations [Saves them in "nextCluster.pos" file]
  • 13: Fixed error on entering incorrect data for manual gps location, now loops until correct data types are given
  • 13: Fixed bug turtle getting stuck if building cluster from East/West Axis and user decided to build the center column
  • 14: Lowered Coverage area from 325 to 284 for coverage all the way down to bedrock
Build 7-9 (November 8th changes) Initial Release
  • 7: Initial Release
  • 7: All-in-one Program
  • 8: + Option to construct center column
  • 9: + '-u' argument to update program inline
  • 9: Fix crash when program is ran on a computer instead of turtle
Build 1-6 (Beta)
  • old GPS Tower Program (discontinued)
  • Individual Files and seperate startup file
Edited on 12 January 2014 - 01:04 PM
Wojbie #2
Posted 07 November 2013 - 08:54 AM
For getting rid of ".0" you could use string.format.

Possible next spot to place a gps cluster to stay in coverage sounds like great idea!.

I Love UI in this program. Looks nice and functional. Can't test it right now but i will :)/>.
Edited on 07 November 2013 - 08:01 AM
Cozzimoto #3
Posted 07 November 2013 - 08:58 AM
Spoiler
For getting rid of ".0" you could use string.format.

Possible next spot to place a gps cluster to stay in coverage sounds like great idea!.

I Love UI in this program. Looks nice and functional. Can't test it right now but i will :)/>.

ok thanks for the ".0", Once i find out a way to update the program with a simple argument ill add that fix in.
Wojbie #4
Posted 07 November 2013 - 09:06 AM
You could download paste and compare it to contents of program. If there is a difference save pastebin version onto program and quit.
Something like (Danger pseudocode!)
Spoiler

paste=get from pastebin
program=open shell.getRunningProgram()
if paste~= program then
save paste in shell.getRunningProgram()
print("updated")
return true
end
Thats how i do it if i need to update. Or you could just download and overwrite anyways cause you need to download it anyways to see if it changed.

Is it possible to make it build just top part (cross on top) without long vertical column to ground??
Edited on 07 November 2013 - 08:07 AM
Cozzimoto #5
Posted 07 November 2013 - 09:10 AM
in my mind i put the column for a little sense of realism, but i think i can add an option for the user to decide if they would want the column built or not. i thought it would be cool to see where your GPS Clusters are
Cozzimoto #6
Posted 07 November 2013 - 09:33 AM
updated to Build 8

+ option to construct center column or not right before the start program command
Nujugi #7
Posted 07 November 2013 - 02:40 PM
Hi.

I tried to make my first GPS tower, but got this error:
302: attempt to perform arithmetic __sub on number and nil

The line is: meta.targHeight = math.ceil(254 - meta.yPos)

Anyone know why?

I'm using: GPS Tower Builder B:8 http://pastebin.com/xhyTFyZp
Edited on 07 November 2013 - 01:43 PM
Wojbie #8
Posted 07 November 2013 - 02:52 PM
Also got small suggestion.
Right now this program won't work on standard computer.
if you added

if not turtle then print("This program needs a turtle to work") return end
Then it would error in way people would understand why it don't work.
Always assume end user will do weird stuff.
Cozzimoto #9
Posted 07 November 2013 - 03:21 PM
yea good point, ive added that into the next build. i got a question for you wojbie. i got an idea for how ill do the update check within the program. so my question is if i create a startup file to run temporary is there a way to delete that startup file when the operation is complete?
Wojbie #10
Posted 07 November 2013 - 03:23 PM
When work is done but before ending program simply add
fs.delete("/startup")
And it wll get deleted.
Edited on 07 November 2013 - 02:23 PM
Cozzimoto #11
Posted 07 November 2013 - 03:28 PM
ok then yea i figure so but i was not sure if it would crash because i was attempting to delete a file while it was running, but yea here in a few hours i should have an auto updater for build #9
Nujugi #12
Posted 07 November 2013 - 03:59 PM
Hi Cozzimoto

Did you see my post? ;)/>


SpoilerHi.
I tried to make my first GPS tower, but got this error:
302: attempt to perform arithmetic __sub on number and nil
The line is: meta.targHeight = math.ceil(254 - meta.yPos)
Anyone know why?
I'm using: GPS Tower Builder B:8 http://pastebin.com/xhyTFyZp
Cozzimoto #13
Posted 07 November 2013 - 04:27 PM
Spoiler
Hi Cozzimoto

Did you see my post? ;)/>


SpoilerHi.
I tried to make my first GPS tower, but got this error:
302: attempt to perform arithmetic __sub on number and nil
The line is: meta.targHeight = math.ceil(254 - meta.yPos)
Anyone know why?
I'm using: GPS Tower Builder B:8 http://pastebin.com/xhyTFyZp

hmm that error shows that the Y Position was not entered in the setup part of the program, what was your step by step operation to re-create the crash?
Cozzimoto #14
Posted 07 November 2013 - 05:31 PM
updated to Build #9

+ '-u' argument to check for updates, to use <FILENAME> -u
+ Fix crash if program was ran on a computer/Advanced computer
Wojbie #15
Posted 07 November 2013 - 05:38 PM
Stupid question but why create startup file in order to update? Is it part of some long - term plan of some sort?
Cause same code run from program would do same action.

That would skip creating startup file / resetting / removing it.
Cozzimoto #16
Posted 07 November 2013 - 05:43 PM
well i didnt want to edit the file currently being in use. most updates on windows after they are installed they usually require a reboot.

so what i did is i download the update create a startup file to run that reads and checks the file versions and if the downloaded version is newer it deletes the current one and replace it with the downloaded one. and after the startup is finished it deletes the startup file.
Wojbie #17
Posted 07 November 2013 - 05:45 PM
Oh i see what are you making here :D/> Never mind then.
Edited on 07 November 2013 - 04:45 PM
Cozzimoto #18
Posted 07 November 2013 - 05:58 PM
Updated Build 10

its a little hard to test this but i just found an issue when trying to run the program without checking the -u argument so i pushed a quick fix on build 10
Nujugi #19
Posted 07 November 2013 - 06:35 PM
Nothing happend befor the error :(/>
The was the first thing it show after i run the program.

Thanks for fast reply

Spoiler
Hi Cozzimoto

Did you see my post? ;)/>


SpoilerHi.
I tried to make my first GPS tower, but got this error:
302: attempt to perform arithmetic __sub on number and nil
The line is: meta.targHeight = math.ceil(254 - meta.yPos)
Anyone know why?
I'm using: GPS Tower Builder B:8 http://pastebin.com/xhyTFyZp

hmm that error shows that the Y Position was not entered in the setup part of the program, what was your step by step operation to re-create the crash?
Cozzimoto #20
Posted 07 November 2013 - 06:48 PM
Spoiler
Nothing happend befor the error :(/>
The was the first thing it show after i run the program.

Thanks for fast reply

Spoiler
Hi Cozzimoto

Did you see my post? ;)/>


SpoilerHi.
I tried to make my first GPS tower, but got this error:
302: attempt to perform arithmetic __sub on number and nil
The line is: meta.targHeight = math.ceil(254 - meta.yPos)
Anyone know why?
I'm using: GPS Tower Builder B:8 http://pastebin.com/xhyTFyZp

hmm that error shows that the Y Position was not entered in the setup part of the program, what was your step by step operation to re-create the crash?

hmm interesting, well ive done a few changes and updated the version on the program, if you can try the new update and if the error happens again let me know.
Nujugi #21
Posted 08 November 2013 - 04:29 AM
Thanks.

I have tesed it, but it failed on the 2nd computer.
It did not pick up the disk on fist computer.
And lost the disk some where.

Got this error on the 2nd computer: 101: attempt to index ? (a nil value)

BW. I runing it om FTB unleashed. So it's CC 1.53. Single player.
Nujugi #22
Posted 08 November 2013 - 05:05 AM
I tested it in MC with only Forge and CC 1.57 now.

It didn't work, it only placed the first computer.
No error.
Cozzimoto #23
Posted 08 November 2013 - 05:31 AM
on line 101 in the current build #11 is f.writeLine("local f = fs.open('startup','w')")

which is apart of the function that creates the install file to be run on the gps computer once the turtle boots it up. are you using an older version?
Nujugi #24
Posted 08 November 2013 - 01:53 PM
I worked fine on the first computer.
The problem was that it did not pick up the disk drive befor it moved on to computer 2.



And version: I runing it om FTB unleashed. So it's CC 1.53. Single player.
Nujugi #25
Posted 08 November 2013 - 02:05 PM
I tested it on the ground now and same thing happend.
It dont bring the disk drive to computer 2.

See the picture, it just puts the disk on the ground sins there no disk drive there ;)/>

Wojbie #26
Posted 08 November 2013 - 02:20 PM
Turtle has no pick on picture? So it can't break blocks with no pickaxe.
Cozzimoto #27
Posted 08 November 2013 - 03:27 PM
hmm this is bothering me because i went into Multi MC for minecraft version 1.5.2 computercraft Version 1.5.3 in single player and watch my test turtle run and it had no problems

EDIT::
and i didnt even see that the turtle lacks a pickaxe, yes the turtle needs a pickaxe for it to bring the diskdrive over to the second computer (thanks for noticing that wojbie)
Edited on 08 November 2013 - 02:28 PM
Nujugi #28
Posted 09 November 2013 - 11:50 AM
LOL

I didn't think about that :P/>
Stupid me :P/>

Thx for great support ;)/>
Cozzimoto #29
Posted 09 November 2013 - 02:12 PM
Spoiler
LOL

I didn't think about that :P/>
Stupid me :P/>

Thx for great support ;)/>
No problem, feel free if you think im missing something that i havent already listed and id love feedback if you give it.
Cozzimoto #30
Posted 09 November 2013 - 06:39 PM
Hello everyone, did alot of testing today and i finally got an implemtation of expanding GPS coverage. ill have a pic and some iinfo explaning it in more detail. In my travels ive also found a few bugs so for those who have my program already please update to Build 13
Wojbie #31
Posted 09 November 2013 - 07:06 PM
This should help you a bit in planning - i love how clearly it shows coverage

http://imgur.com/sz43kFC
Edited on 09 November 2013 - 06:07 PM
Cozzimoto #32
Posted 09 November 2013 - 07:28 PM
Spoiler
This should help you a bit in planning - i love how clearly it shows coverage

oh nice, thats really neat. i actually jsut put up my explanation on how i did it, it was more of a horizontal plane i was working with. your picture shows a vertical plane on the subject and thats really neat. at the bottom of the my OP there is a spoiler where i stuck all my test data and information on it if you want to check it out.
Wojbie #33
Posted 09 November 2013 - 07:43 PM
Spoiler
This should help you a bit in planning - i love how clearly it shows coverage

oh nice, thats really neat. i actually jsut put up my explanation on how i did it, it was more of a horizontal plane i was working with. your picture shows a vertical plane on the subject and thats really neat. at the bottom of the my OP there is a spoiler where i stuck all my test data and information on it if you want to check it out.
Hmm if i may make a suggestion? lover Radius from 325 to 284 range so there will be full coverage all way down to bedrock. That way it will be foolproof.
Cozzimoto #34
Posted 09 November 2013 - 07:47 PM
hmm interesting, yea i made my graph based on a selected Y axis area of where most people are between, but there is no harm in lowering the radius down to fool proof the concept, thanks for the suggestion wojbie
HeffeD #35
Posted 10 November 2013 - 03:36 PM
ComputerCraft 1.53, Minecraft 1.5.7.

The turtle goes up to Y254 and just sits there. No error, no attempts to do anything… :huh:/>

Any sort of verbose or debug mode I could enable to give you more info?
Cozzimoto #36
Posted 10 November 2013 - 03:42 PM
the target Y coordinate should be 253, i had an error with this in a previous version because the turtle cannot go higher than the map height. and i had it originally set to 254 but the turtle could not move to 255 itself, im gunna try and add one debug item in the next build to see how much farther he has to move
Cozzimoto #37
Posted 10 November 2013 - 04:15 PM
UPDATED: Build 15

added debug information
Usage
<PROGRAMNAME> -d

fix another check for turtles without pickaxes
HeffeD #38
Posted 10 November 2013 - 04:56 PM
Thanks for the quick response! :)/>

It's strange though, because I updated the script and set the debug argument, and it worked flawlessly… :unsure:/> I'll try to get it stuck again and let you know what I find.
Cozzimoto #39
Posted 10 November 2013 - 05:14 PM
ok well let me know for anymore issues as ill be glad to help and if you think i forgot something and want to make a suggestion, they are welcome here.

ill keep you posted
Kotawolf #40
Posted 12 December 2013 - 10:30 PM
Looks very interesting… question…. I've never used the wireless so I have no idea on the potential. I use AustinKK's mining program. Will it report back to a central computer (if were to set one up) and say.. This is where I'm at.. this is what level I'm on?

In other words, what use is the wireless? I don't want to sit there and remote control the turtles.
Cozzimoto #41
Posted 14 December 2013 - 12:57 PM
-snip-
yea you can get a program to do what you want but as for implementing it in an already existing program can be difficult, because reading 1000s of lines of code can be time consuming, and everyone has their own way of writing code, its kind of like an art. I suggest you read on the APIs and build one from scratch so you can have a mining program that can report back to the central computer/server. i have this great timestamp program that you can look into because this program displays messages sent to it and shows how old the message is. IE like FB chat.

APIs Link
My Timestamp Program
Video on my Timestamp Program

Hope this helps
xXLeNinjaXx #42
Posted 10 January 2014 - 09:22 PM
Any Pictures on how to put material in the turtle greatly appreciated :I


EDIT: Figured it out did not understand it at first
Edited on 10 January 2014 - 08:36 PM
xXLeNinjaXx #43
Posted 11 January 2014 - 04:54 PM
BUG: it Finds Its cords But Cant Find Orientation? then it breaks the whole script ??
Cozzimoto #44
Posted 12 January 2014 - 02:02 PM
BUG: it Finds Its cords But Cant Find Orientation? then it breaks the whole script ??

do you have your log file? if i can see it i can probably find the error easier. Are you playing on a server? which version of minecraft are you playing on?
Vast #45
Posted 10 August 2015 - 09:05 AM
Hi Cozzimoto

I tried your program but receive the following error when starting it up. There is already a GPS tower up and running.

-u argumnt passed
HTTP passed
HTTP get success
creating install file
rebooting
turtle has wireless modem
GPS Found
detecting Orientation via GPS
ERROR: couldnt determine orientation

I`m using CC1.73
Minecraft 1.7.10
Playing single player
HPWebcamAble #46
Posted 10 August 2015 - 10:44 PM
Looks like Cozzimoto hasn't been around since march, maybe I can help.

Could you put a screenshot of the existing tower on imgur and put a link here?
http://imgur.com/


You could also try manually inputting the coordinates into the program, instead of using an existing GPS tower.