Jump to content




Updating turtle programs


2 replies to this topic

#1 Justinjah91

  • Members
  • 12 posts

Posted 10 October 2018 - 11:03 PM

Good afternoon!

So I keep all of my turtle programs on a single disk so I only have to edit the programs in one place. Any time I make changes to those programs, I update my turtles by running an update script that looks like this:

local programs = {"branch","dig","dump","loggerpro","move","obsidian","processgravel","room","safebranch","shaft","sort","sortwrapper"}

for i=1,#programs do
shell.run('delete',programs[i])
shell.run('copy','/disk/'..programs[i],programs[i])
end

print('All programs updated!')

As you can see, I manually enter the names of the programs into a table (or array, or matrix, or whatever they are called in LUA) to do this. I'm wondering if there is a way to automatically detect which programs a turtle already has installed and only attempt an update if the disk contains the same program. In other words, is there a way to avoid having to manually type in the names of all of the programs on the disk? It isn't a huge deal since there aren't very many programs here, I was just curious if it COULD be done.

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,043 posts
  • LocationTasmania (AU)

Posted 11 October 2018 - 12:07 AM

fs.list() gets you a table with all the contents of a given path. After pulling listings for both your turtle's drive and the floppy disk, you need only compare them and update any files found in both locations.

#3 campicus

  • Members
  • 164 posts

Posted 11 October 2018 - 01:01 AM

Not what you're looking for but your question has already been answered so... you might find this useful? Check out the program I made to automatically pull all the pastes from your pastebin. There's also a 'refresh' program I just added, which automatically updates all your programs when you place the comp/turtle next to the disk drive.
1. Run the update program on a computer above a disk drive (with a disk in it).
2. Place your turtle/computer next to the disk drive, open it
3. You'll be prompted to add a label (if it's not labelled) and set a startup program (leave blank to not set one)
4. Fully updated comp/turtle!

Update: https://pastebin.com/BB7dQGu2
Spoiler

Refresh: https://pastebin.com/9mTVTruQ
Spoiler

Edited by campicus, 11 October 2018 - 01:02 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users