Posted 18 April 2012 - 10:57 AM
The updated turtle API.
Fixing (to an extent) a deficiency in current native API implementation.
Allows automatic calibration and arbitrary course setting, rotation using specific angle, and keeps internal track of position and course changes.
Changes to existing methods:
Internal changes to all movement methods for course/location tracking.
New properties:
turtle.directions[indent=1]a dictionary table to translate numeric directions into verbal form. State-dependent.[/indent]
turtle.location() read-only[indent=1]Returns current turtle location, in order: x, y, z as returned by GPS API, bearing (0-3 clockwise, 0 being East/Forward), inertial navigation flag (true if using inertial navigation).
Usage example:
turtle.version() read-only[indent=1]Returns API internal version.[/indent]
New methods:
turtle:calibrate( boolean verbose )[indent=1]Attempts a short calibration sequence and return turtle to the starting position. Working GPS network and an opened modem on turtle is required in order for it to work.
verbose - allows printing of progress information.
Returns true, if calibration was successful, othervise false.
Note the ":" - this function call is required to be self-referenced.[/indent]
turtle.rotate( int angle )[indent=1]Performs a rotation arbitrary number of times into given direction. Negative number will cause turtle to rotate counter-clockwise.
Due to turtle being heavily armoured and overall aimed to achieve a result rather performing a process, only necessary amount of maneuvering will be executed at a time.[/indent]
turtle.setCourse( int course )[indent=1]Attempt to point a turtle into specific direction (0-3 clockwise, with 0 being East/Forward)
Negative course allowed.
Returns true if succesful, or false othervise.[/indent]
Installation
Dump archive contents into minecraft/mods folder.
Reports and suggestions are welcome.
UPD 20120504-1: Sneaky edit
+ Added version properly. You can check for correct API installation by addressing turtle.version(). If it works, then you have it all proper. If not, you probably screwed something.
UPD 20120504:
+ Full inertial navigation.
* Rewritten and better state reporting.
UPD 20120424:
! Finally made it's way to my Subversion repo. No more code loss due to power outages.
* Fixed directions tables.
* A few preparations for inertial navigation.
UPD 20120423:
* More stupid error fixes.
* More consistency fixes.
UPD 20120422:
* Fixed some stupid errors in course handling.
* Split native call in two parts for easier code reuse.
Fixing (to an extent) a deficiency in current native API implementation.
Allows automatic calibration and arbitrary course setting, rotation using specific angle, and keeps internal track of position and course changes.
Changes to existing methods:
Internal changes to all movement methods for course/location tracking.
New properties:
turtle.directions[indent=1]a dictionary table to translate numeric directions into verbal form. State-dependent.[/indent]
turtle.location() read-only[indent=1]Returns current turtle location, in order: x, y, z as returned by GPS API, bearing (0-3 clockwise, 0 being East/Forward), inertial navigation flag (true if using inertial navigation).
Usage example:
local x, y, z, b, i = turtle.location()
io.write("Unit " .. (os.getComputerLabel() or os.getComputerID()) ..
" at (" .. x .. "," .. y .. "), altitude " .. z ..
", facing " .. turtle.directions[b])
if i then
print(", using inertial navigation.")
else
print(".")
end
[/indent]turtle.version() read-only[indent=1]Returns API internal version.[/indent]
New methods:
turtle:calibrate( boolean verbose )[indent=1]Attempts a short calibration sequence and return turtle to the starting position. Working GPS network and an opened modem on turtle is required in order for it to work.
verbose - allows printing of progress information.
Returns true, if calibration was successful, othervise false.
Note the ":" - this function call is required to be self-referenced.[/indent]
turtle.rotate( int angle )[indent=1]Performs a rotation arbitrary number of times into given direction. Negative number will cause turtle to rotate counter-clockwise.
Due to turtle being heavily armoured and overall aimed to achieve a result rather performing a process, only necessary amount of maneuvering will be executed at a time.[/indent]
turtle.setCourse( int course )[indent=1]Attempt to point a turtle into specific direction (0-3 clockwise, with 0 being East/Forward)
Negative course allowed.
Returns true if succesful, or false othervise.[/indent]
Installation
Dump archive contents into minecraft/mods folder.
Reports and suggestions are welcome.
UPD 20120504-1: Sneaky edit
+ Added version properly. You can check for correct API installation by addressing turtle.version(). If it works, then you have it all proper. If not, you probably screwed something.
UPD 20120504:
+ Full inertial navigation.
* Rewritten and better state reporting.
UPD 20120424:
! Finally made it's way to my Subversion repo. No more code loss due to power outages.
* Fixed directions tables.
* A few preparations for inertial navigation.
UPD 20120423:
* More stupid error fixes.
* More consistency fixes.
UPD 20120422:
* Fixed some stupid errors in course handling.
* Split native call in two parts for easier code reuse.
Edited on 04 May 2012 - 04:31 AM