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

Coaster3000's Programs [Latest: Turtle Complete (Api)]

Started by coaster3000, 27 May 2013 - 05:38 PM
coaster3000 #1
Posted 27 May 2013 - 07:38 PM
Coaster3000's Programs

This post is masterfully constructed from raw bbcode. Blame rte for unstable editing :P/>
See problem with post. Please inform me so I can fix it. [/joke]

NOTICE: I have gone inactive and I do not plan on updating any programs. I may release new ones in the future.


NOTICE:I may not be active for a bit due to server work that I work on. As I have said before. I usually make this stuff while playing FTB in survival. Not much free time with school and server work put together now..



New Github Repo Made Here

It will contain mostly stable programs. However there will be branches of how stable it is. 3 major branches will be master, beta, bleeding edge.


Apis

Spoiler
Turtle Complete

Status: Semi Stable Dev Build (Beta built being promoted soon.)
Turtle complete is a complete api for minecraft turtle's. All functions of the turtle exist in this api as a wrapper to it. The API is designed for convenience.

Planned features:
  • Open for suggestions
Currently this api is only released under dev builds.
Downloads
Dev Build: rawget turtle http://goo.gl/EpOcf

Test Program: Test Program To Be Made

Downloads:
Stable Builds: pastebin get ….. turtle
Beta Builds: pastebin get j7dBUpLZ turtle - Currently broken

[indent=1]
rawget turtle http://bit.ly/14Mn9oM[/indent]

Documentation
Documentation is based off developer builds from dropbox.
SpoilerTurtle Changes


refuel(Amount)

[indent=1]
Refueling will refuel to fuel level of specified amount

Native refuel functionality is obtained by doing
refuel(num, false)

The extra parameter false not to use advanced refueling[/indent]

Movement functions
All movement functions remain the same. They are wrapped to keep track of the navigation api.

forward, back, up, down

[indent=1]
Additional parameter of count to move multiple times.
Changes from this are as follows

Instead of true or false if it successfully moved that many times.
It will return how many successful movements it has made.

Native functionality exists by not specifying any parameters.
[/index]

dig, digUp
Functions have been wrapped so that they will continue to dig until whatever is in spot appearing there.
This is for falling objects more specifically but can be if you are placing the object to mess with the turtle.

Native functionality is default. Use true as parameter for safe dig and digUp (Anti gravel / sand or block falling)


select
Function is wrapped to get data for the getSlot() function



Additional API


Positional Data
getX()[/indent]
[indent=1]
returns tracked position on x axis.
Note this position is relative to when the api is first loaded.
the first direction the turtle is. Is the x axis.
[/indent]

getY()

[indent=1]
returns the height that is being tracked.
Note this position is relative to the api load time.[/indent]

getZ()


[indent=1]
returns tracked position on z axis
Note this position is relative to when the api is first loaded.
the first direction the turtle is. Is the x axis.
[/indent]

getDirection()


[indent=1]
returns a numeral direction of 0 - 3

0 is in a sense north relative to start of api

Note this data is relative
[/indent]

Retry system


getMaxAttempts()

returns maximum movement attempts for certain functions.



setMaxAttempts(count)
Set the max attempt count

value of -1 will use infinite attempts.


[indent=1]
Parameter 1 (number) max attempt count to set.[/indent]

Movement and rotation


turnAround(useLeft)


[indent=1]
Parameter 1 (boolean) use left turns instead

Turn around in a sense of turn 2 times.
[/indent]

spin(count, useLeft)


[indent=1]
Parameter 1 (number) number of spinning
Parameter 2 (boolean) turn left instead

spins the turtle 360 degrees
[/indent]

shakeNo(alternate)
Say no something


[indent=1]
Parameter 1 (boolean) shake with opposite default rotations.

Will go turn right then turn left 2 times then turn right.

Will do opposite directions if true for use alternate
[/indent]

orient(param1)


[indent=1]
Parameter 1 (String or number) Direction to orient to
Valid values are 0 - 3 or north south east west and origin

Will orient turtle in said direction. Turtle turns left to meet requirements. And will error if it encounters a bizarre error such as invalid direction state.
[/indent]

turn(direction)


[indent=1]
Parameter 1 (String) Direction to turn
Valid values are: right, left, back, turnaround, forward, straight.
All others will error with ('<DIRECTION> is not a valid direction. See documentation.')
[/indent]

tillBlock(direction)


[indent=1]
Parameter1 (String) Direction to go
Valid values are exact as turn(direction)
[/indent]

Tunneling Functions


tunnelUp(count, fuelCheck)


[indent=1]
Parameter 1 (number) how far
Parameter 2 (boolean) check fuel before starting. Will error if not enough fuel

Will tunnel straight up for set ammount of blocks.
[/indent]

tunnelDown(count, refuelCheck)


[indent=1]
Parameter 1 (number) how far
Parameter 2 (boolean) check fuel before starting. Will error if not enough fuel

Will tunnel straight down for set ammount of blocks.
[/indent]

tunnel(count, height, refuelCheck)


[indent=1]
Parameter 1 (number) how far
Parameter 2 (number) how tall
Valid values are 1 - 3 any higher will result as 3 and any lower will error
Parameter 3 (boolean) check fuel before start

Tunnels a (height) tall tunnel for (count) amount of blocks.
[/indent]



Inventory Manipulation


dropAllSame(slot)
[index=1]
Parameter 1 (Slot Number) What slot to compare items with

This will drop all items that match the slot specified. But will not drop the items in the specified slot.



dropDownAllSame(slot)
[index=1]
Parameter 1 (Slot Number) What slot to compare items with

This will drop all items that match the slot specified. But will not drop the items in the specified slot.

Variant - Will drop down instead of regular drop call

[/indent]

dropUpAllSame(slot)
[index=1]
Parameter 1 (Slot Number) What slot to compare items with

This will drop all items that match the slot specified. But will not drop the items in the specified slot.

Variant - Will drop up instead of regular drop call
[/indent]

countAllItems()
Counts all items in inventory space. Does not matter what type they are.

swapTransfer(slot)


[indent=1]
Parameter 1 - The slot to transfer items to

Warning: This function relies on an empty inventory slot. Will fail if there is none.

Trades items with current slot with the specified slot.
[/indent]


Note: Changelogs with dev builds may skip builds. They are just a save number since it auto uploads on save (Dropbox does this)
Changelog:
Spoiler
  • V0.1
    • Wrapped turtle api's
    • Implemented: rotations
      • turnLeft
      • turnRight
      • turnAround
      • spin
      • turn
    • Implemented: Movement
      • forward
      • back
      • tillBlock
    • Added: Slot Tracking
    • Added: Advanced Refueling
    • Added: isFuel Function
    • *]Added: tillBlock function to move until it hits a block. [sup
    • Added: tunnelUp function
    • Added: tunnelDown function
    • Added: tunnel function
    • Implemented: Fuel checking on movements
    • If you specify multiple movements for example forward(10) it will not move if it does not have 10 fuel. It will error("Not Enough Fuel for '10' Moves")
  • V0.2 Beta
  • V0.2 Build 1
    • Implemented: height variable to tunnel()
    • Syntax: turtle.tunnel(length, refuel, height) Open for suggestion
  • V0.2 Build 4
    • Implemented: countAllItems functions
    • Implemented countSlotItems function
    • Added: Blank swapTransfer Function Will be functional later
    • Any usage will result in error.
    • Added: Blank sortInventory Function Will be functional later
    • Any usage will result in error.
  • V0.2 Build 6
    • Implemented: swapTransfer function
    • This function is not tested… Be Wary
  • V0.2 Build 12
    • Changed: dig and digUp to default to native function of dig.
    • For dig until block is gone (Gravel safe dig) use true as the parameter
    • Fixed: safety of isFuel function to include empty parameters (Default to current slot)
    • Fixed: Advanced refuel function calling nil (Possible nil value)
  • V0.2 Build 15
    • Fixed: tunnel functions -1 feature (Tunnel infinite)
    • Implemented: Failsafe of max attempts on tunnel features for inifinite tunneling (Hit bedrock?)
    • Implemented: calibrate function to change internal navigation position data.
  • V0.2 Build 36
    • Fixed: native turtle function overrides throwing errors.
    • Fixed: indexOutOfBounds Exceptions from above problems
    • *]Changed: Renamed all turtle calls to nativeturtle calls [sup
    • Fixed: refuel function (Advanced version)
    • Fixed: turtle.getFuelLevel()
    • Fixed: turning functions
    • Fixed: orient function


Programs


SpoilerStatus: Stable


RawGet

Description: This is just a quick small application to get anything at a link. Then write it to a file.

Note: bit.ly links already work natively due to how bit.ly works. Google for some reason uses actual pages that redirect after already downloading the webpage..

Code: pastebin get xivwA6hT rawget

Usage: rawget <file> <url>

Changelog:
  • V1:
    • Released Program
  • V1.1
    • Redirect Detection Implemented
      • goo.gl links now auto detected.
      • A good example is the dev builds of some of my listed items on this post.
  • V1.1b
    • Fixed: some missing information such as the name of the author for stringX and a new link to authors site.




[topic="12914"]Pastebin Login[/topic]


Usage: pastebin put <file> <username>

Instructions: After putting in username it will ask for a password if it is able to connect.
The password is masked.

Credit:
Majority of the code belongs to ComputerCraft. This is a edited version to allow usernames..

Code: pastebin get A3SbAi4i pastebin

Changelogs:
  • V1.0
    • Added: Login code to pastebin code
    • Error handling for bad api request's
  • V1.1
    • Changed: Changed password to be specified during connection
    • Added: Password Masking


Turtle Programs


Spoiler


TreeFarm Turtle


Status: Active Development

Description:
This program creates and manages a basic tree farm.

Note: This program is currently in development on a survival world. No release available yet. Must make it an easy setup for you to use first.

Planned Features:
  • Easy Setup
  • Easy setup for user as long as http is enabled it can download all libraries needed. So far this will only use 2 libraries.
  • Customization
    • Customize spacing
    • Customize Tree Count
  • X / Z arraying (No better name but it creates a farm in 2 dimensions instead of a line of trees)
  • Gather Saplings
  • Save states (Saves its state so it can resume on startup)
Currently completed features:
  • Basic Setup (Not easy just yet it should auto download or error if it can't)
ChangeLogs
  • V0.1 Ongoing
    • Implemented: Some basic setup code
    • Implemented: Go home code




3x3 Tunnel Turtle


Status: On Hold

Description:
This program creates a 3x3 tunnel for the length specified. Has a loop back function and displays how much materials mined when finished. Turtle will return back when done.

Usage: 3x3 (length) [x]

x = amount of blocks to move forward before starting.
length is how many blocks to mine after going to spot to mine.

You can either put in the argument or define it during runtime.


Code: pastebin get AjX2azCq 3x3

Planned Features:
  • Check for full inventory
  • Realtime display of data. (Console output while running)
Possible Planned Features:
  • RedNet Ready
  • Save state (Will save its session so that it can resume on restart)
Current Features:
  • 3x3 tunnel
  • Fuel checks before starting.
  • Any length of tunnel
  • Auto refuel
  • Loop function for if you want to continue the tunnel when completed
Changelogs:
  • First Release V1
    • Added: 3x3 tunnel system
    • Added: Auto Refuel
    • Added: Go Home Functions
    • Added: Minimalistice recreate of Internal Navigation api [topic="5009"]iNav[/topic] Modified Version and recreate
    • Added: Block Tracking (Counts how much has been mined)
    • Added: Loop back to continue where left off when finished
    • Added: Status display on completeion of job
  • V1.1
    • Fixed: Slow return speed due to constant refuel check
    • Changed: Refuel checks are done at start time.
    • Added: Check fuel for calculated approc fuel consumption
    • Added: Extra parameter to return to a manual spot See usage
  • V1.1b
    • Fixed: Missing refuel checks
    • Slight enhancements

If the post gets to big. I will start dividing the programs into seperate posts. With links to them from here… Hopefully I can manage without them for now.
Edited on 30 September 2015 - 04:37 PM
coaster3000 #2
Posted 08 June 2013 - 01:22 PM
Updated some stuff.

I have added a new mini program the rawget program. It will get the entire contents of a link and save it to the file specified.
This will be used to distribute my dev builds from dropbox.

A nifty feature of this is that it will detect google short urls.

goo.gl links and will redirect automatically to its content. More redirect detections will be implemented when I get my handes on some.
I will not be implementing redirect detection on links such as ad fly links. Those links should not be bypassed..

Have a redirect site? Give me some links. I will be happy to implement them. I need a sample of multiple site so i can make a generic detection to detect common redirect pages..


Other notes: The dev build of the Turtle API is not a table method. This one is a turtle replacement method. This one copies all turtle api into itself. Then wraps functions to use on its own. This api currently is missing many features.. The documentation is missing since i started over to use this kind of api.
svdragster #3
Posted 08 June 2013 - 04:04 PM
Nice job! I'm looking forward to new APIs from you.
theoriginalbit #4
Posted 08 June 2013 - 09:48 PM
Looking nice.

Another shortener, bit.ly.

And one last thing, can you please either have my name as `theoriginalbit` or `TheOriginalBIT` as the capitalisation does have meaning. Oh also new web address, http://cc.theoriginalbit.com
coaster3000 #5
Posted 09 June 2013 - 12:55 PM
Looking nice.

Another shortener, bit.ly.

And one last thing, can you please either have my name as `theoriginalbit` or `TheOriginalBIT` as the capitalisation does have meaning. Oh also new web address, http://cc.theoriginalbit.com

Sure thing. I forgot to put in the username I forgot it by accident. And i changed the link for you. Figured if i put more than the 2 functions I would include whole license. But I only use the assert and contains functions for this particular script.

I started using plain text editing and storing my post on my computer due to rich text editor screwing up the post badly.

Oh by the way. Need to check your non object string library. Some of the asserts are backwards and will ALWAYS error.. like

assert(type(str) == "nil", "Value expected but got nil") 
Should be

assert(type(str) ~= "nil", "Value expected but got nil")

Also I went to add the bit.ly stuff. It seems the redirects display the page content itself automatically. For some reason google gives you a redirect page that auto redirects in browsers. Which forces computercraft to see an html page..

bit.ly Already works natively :DHappy me.

Find any that does not work. Feel free to tell me :)/>
theoriginalbit #6
Posted 10 June 2013 - 02:29 AM
Sure thing. I forgot to put in the username I forgot it by accident. And i changed the link for you. Figured if i put more than the 2 functions I would include whole license. But I only use the assert and contains functions for this particular script.
Thanks

Oh by the way. Need to check your non object string library. Some of the asserts are backwards and will ALWAYS error…
Hmmm ok, what is the source you got it from?
coaster3000 #7
Posted 10 June 2013 - 02:36 PM
–Snip–
Hmmm ok, what is the source you got it from?

I got it from github.
theoriginalbit #8
Posted 10 June 2013 - 06:24 PM
I got it from github.
Ahh yeh, I was working on that version, then had to concentrate on uni so couldn't finish it. The better place to get my programs is my pastebin account as those are normally the release versions of my programs and have had most of the bugs fixed. StringX on pastebin.