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

Improved Turtle API

Started by Astrophylite, 23 July 2015 - 10:15 AM
Astrophylite #1
Posted 23 July 2015 - 12:15 PM
Hi!

So, after some work, I have finally got to the stage where I can publish my Improved Turtle API.
It still uses the same functions, but instead of repeating the functions you put the amount of times you want to complete the actions in the brackets. (e.g: turtle.forward(5), turtle.back(5), etc)

Download the file from Pastebin: http://pastebin.com/w7DnM2Rt.

Do you like this API? Want to keep updated with all the new versions/updates?
Edit the turtle's startup file and put the following code at the top of the code:


local response = http and http.get("http://pastebin.com/raw.php?i=w7DnM2Rt")
if response then
  if fs.exists("/apis/turtle")
    fs.delete("/apis/turtle")
  end
  local handle = fs.open("/apis/turtle","w")
  handle.write(response.readAll())
  handle.close()
  response.close()
end
os.loadAPI("/apis/turtle")

Got any suggestions? Found any bugs? Comment below and I shall read them when I can.


- ZiR

EDIT: Added the file to Pastebin and created an auto-updater.
Edited on 25 July 2015 - 02:29 PM
H4X0RZ #2
Posted 23 July 2015 - 12:52 PM
Why this download program? Can't you just upload the script to pastebin?
PokeAcer #3
Posted 23 July 2015 - 03:53 PM
Here's it on pastebin because f*ck downloading it via a remote downloader that literally requires you to give it the URL:
http://pastebin.com/NdAt0uak
Astrophylite #4
Posted 23 July 2015 - 04:01 PM
Those of you who have downloaded it from PokeAcer's link, you will not be able to stay updated because PokeAcer will have to keep updating the Pastebin file, which, might not happen :)/>
Those of you who have downloaded it using my method (the downloader), will always have the latest version and it will stay updated.

EDIT: My reasons for not uploading to Pastebin:
1. I have to paste the whole code back onto Pastebin, making it harder if I code it on a server
2. I have to update this post with the new link if I use the pastebin program (which I will probably forget to do)
Edited on 23 July 2015 - 02:06 PM
jerimo #5
Posted 23 July 2015 - 04:04 PM
Those of you who have downloaded it from PokeAcer's link, you will not be able to stay updated because PokeAcer will have to keep updating the Pastebin file, which, might not happen :)/>/>
Those of you who have downloaded it using my method (the downloader), will always have the latest version and it will stay updated.
You could also simply add an autoupdater so whichever method you use to obtain it the first time you stay up to date
Astrophylite #6
Posted 23 July 2015 - 04:11 PM
Look at the first post @jerimo

Here's it on pastebin because f*ck downloading it via a remote downloader that literally requires you to give it the URL:
http://pastebin.com/NdAt0uak
Just to say, if you have file access to the server, you can download the SP file then drop it into the location. Using the downloader is only for MP when you don't have access to the server.

Why this download program? Can't you just upload the script to pastebin?
No, I can't, because then I will have to post here that there has been an update and you all have to download it again, when, just by using the simple script I provided, you can keep up to date with the API without having to look at the post.
H4X0RZ #7
Posted 23 July 2015 - 05:36 PM
Look at the first post @jerimo

Here's it on pastebin because f*ck downloading it via a remote downloader that literally requires you to give it the URL:
http://pastebin.com/NdAt0uak
Just to say, if you have file access to the server, you can download the SP file then drop it into the location. Using the downloader is only for MP when you don't have access to the server.

Why this download program? Can't you just upload the script to pastebin?
No, I can't, because then I will have to post here that there has been an update and you all have to download it again, when, just by using the simple script I provided, you can keep up to date with the API without having to look at the post.

You can stay "up-to-date" with pastebin too. When you have an account on pastebin, you can edit your pastes, so the updated code still has the same pastebin id. Also you could add an auto-update function to the api, which checks for updates and then downloads the new script.
Lyqyd #8
Posted 23 July 2015 - 10:30 PM
Shortened links removed. Please use non-redirecting URLs.
Astrophylite #9
Posted 24 July 2015 - 11:34 AM
You can stay "up-to-date" with pastebin too. When you have an account on pastebin, you can edit your pastes, so the updated code still has the same pastebin id. Also you could add an auto-update function to the api, which checks for updates and then downloads the new script.

What if I don't upload it from the game? Because, to make this clear, I will not code in the game, to then have to type it back up into Pastebin, yes, I code this API on multiplayer. And no, do not argue saying "Oooh, but you put your code on Dropbox though." That is because I have a put function in my download program (the put function isn't public yet, because it is not always reliable) to upload it to Dropbox. Oh yeah, the link doesn't change when uploading it from the game…

Shortened links removed. Please use non-redirecting URLs.

Dealt with. Thanks Lyqyd!
Edited on 24 July 2015 - 09:36 AM
PokeAcer #10
Posted 24 July 2015 - 12:06 PM
Listen dude…
If you're gonna do this, make it have an update function built in, do it like kristwallet - use github to host the version number, and make it check. if vnumber locally is < what is from the github, then it'll download the latest/the number you set it to (if you wanna keep old versions)
I added it to pastebin because *everybody* uses pastebin. Heck, even if you make an updater that you dl from pastebin, which then does all the sh*t above, it'd help :P/>
Astrophylite #11
Posted 25 July 2015 - 02:15 PM
Listen dude…
If you're gonna do this, make it have an update function built in, do it like kristwallet - use github to host the version number, and make it check. if vnumber locally is < what is from the github, then it'll download the latest/the number you set it to (if you wanna keep old versions)
I added it to pastebin because *everybody* uses pastebin. Heck, even if you make an updater that you dl from pastebin, which then does all the sh*t above, it'd help :P/>
Okay, so this is the first API I have coded. And from all the sh*t I have got from the "community" here on the forums makes me not want to post/share any of my work again. I'm fed up of this, I might just request for the thread to be closed. And PokeAcer, if you are up for looking through the code, finding updates weekly, monthly, I don't care, then you can edit it on Pastebin. Right now, I am using my downloader because I worked really hard on it with some help from the Ask A Pro section and friends and I wanted other people to see it.

End of arguments. I just wanted to share something I did, that I feel dan200 should add in to the mod to make it even more better.


EDIT: I didn't read your reply fully PokeAcer. Sorry.
Edited on 25 July 2015 - 12:59 PM
PokeAcer #12
Posted 25 July 2015 - 02:29 PM
And PokeAcer, if you are up for looking through the code, finding updates weekly, monthly, I don't care, then you can edit it on Pastebin.
Either that or I delete my pastebin post :P/>
Astrophylite #13
Posted 25 July 2015 - 02:38 PM
@PokeAcer, sorry I didn't fully read and understand your post. I will work on an updater now :D/>
Finally, thanks for some constructive feedback ^_^/>
Astrophylite #14
Posted 25 July 2015 - 03:13 PM
NEW SCRIPT IN MAIN POST! AUTO-UPDATER FOR PASTEBIN
PokeAcer #15
Posted 26 July 2015 - 03:51 AM
Awesome :P/>
Thankfully, pastebin has no issue with edits.
HPWebcamAble #16
Posted 28 July 2015 - 03:35 AM
Unfortunately, I don't see the point of this, but if you had fun, and like it, then good.

Also…

function getSelectedSlot()
  oldTurtle.getSelectedSlot()
end
That won't work, you need to return the old result

function getSelectedSlot()
  return oldTurtle.getSelectedSlot()
end
Astrophylite #17
Posted 28 July 2015 - 05:19 PM
Unfortunately, I don't see the point of this, but if you had fun, and like it, then good.

Also…

function getSelectedSlot()
  oldTurtle.getSelectedSlot()
end
That won't work, you need to return the old result

function getSelectedSlot()
  return oldTurtle.getSelectedSlot()
end

Thank you for looking. I have updated it on Pastebin. :)/>