Jump to content




[Turtle][CraftOS]Liraal's Stuff: Keycard Lock; magicTurtle API v. 1.252

turtle api

105 replies to this topic

#1 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 24 February 2012 - 09:21 PM

Turtle-Locating API, auto builder, tunnel bore and a staircase maker too!

Does basically what the name says. Enter the starting position by magicTurtle.setPos(x, y, z) make it to face North (f=2 on F3 screen) and type magicTurtle.setNorth(). Then move it around by the use of magicTurtle.up() etc. There's a special function magicTurtle.goToPos(x,y,z,mode) which moves the turtle to the given coords. Set mode to true if you want it to break blocks that come its way, otherwise set to false.

functions:
setPos(x,y,z)
getPos()
goToPos(x,y,z)
turnLeft()
turnRight()
forward(n)
back(n)
up()
down()
tunnel(w,h,l)
staircase(w,h,l)
build(blueprint)
sketch()
mine(mode,l) --modes are diamond/regular
autoUpdate() --runs an autoupdate/remote control function in the background
setUpdateID() --sets the ID of remote control terminal
sendCommand(id, side, command) --sends remote command
road() --follow a road of redtorches
wander() --wanders aimlessly around
wanderer(func) --the above but while doing a function func
jack(sap) --plants, watches and cuts down a single tree (param is the slot with saplings)
treefarm(sap) --the same but on full auto (param as above)
landmine(slot, net) --turtle buries itself in the ground and places TNT that is triggered when someone walks on top of it. Can be armed/disarmed by rednet if net is set to true. (slot is the slot containing TNT)
patch(slot, l, w) --patches holes in the ground (slot is the slot for filling material, like dirt/gravel, l is length and w is width)
guardArea(exec, w, l) --patrols an area, if detects a hole/obstacle triggers function exec
remoteArm(id) --arms the mine of the ID given (the arming terminal must be tuned with the mine, see below setMineID())
remoteDisarm(id) -- disarms the mien
remoteSleep(id, t) -- disarms, waits 't' time and arms again
setMineID(arming, disarming) -- sets mine arming/disarming IDs (these are separate and can differ from each other)
savePos() --saves turtle pos to a file
getPosF() --gets turtle pos from file
mineGrid(slot) --makes a grid of TNT placed 1 block beneath surface
camoMine(slot) --same as above but a single TNT
digSlot(slot) --digs the given slot, if wrong material dug, drops to the ground
quarry(width,length) -- BETA quarry function
architect(width, height, length) --destroys a building to make a blueprint of it
path(facing) --experimental pathfinder to find a way when facing is clear. moves in 3d
stf(blueprint, filename) --saves a blueprint to a file filename EXPERIMENTAL
tff(filename) --returns a blueprint from file filename EXPERIMENTAL

You may use this code for your own APIs for public use for as long as you either attribute this to me or distribute unaltered. You're free to do with it whatever you want for your personal use.

Download

Attached File  magicTurtle1.31.txt   15.02K   3067 downloads --newest
Attached File  magicTurtle1.3.txt   13.3K   477 downloads
Attached File  magicTurtle1.252.txt   10.98K   270 downloads
Attached File  magicTurtle1.251.txt   10.97K   222 downloads --bugged isSpace
Attached File  magicTurtle1.25.txt   10.43K   214 downloads --bug in mine() command
Attached File  magicTurtle1.24.txt   8.04K   267 downloads
Attached File  magicTurtleUpdate1.23.zip   2.37K   266 downloads
Attached File  magicTurtle1.22.txt   5.97K   274 downloads
Attached File  magicTurtle.txt   3.96K   345 downloads

TEAM:
  • Liraal (me)
  • EatenAlive3

Keycard lock

A small side-project, a keycard lock with random passwords and multi-user support. Has an admin system with control panel. Adjustable by variables within the program. Try it!

Download

Attached File  lock.txt   5.06K   1197 downloads --version 1.0 (newest)

#2 Dirkus7

  • Members
  • 148 posts
  • Locationthe Netherlands

Posted 24 February 2012 - 11:41 PM

Thats a great idea! I will download this tomorrow and see how this works;)

#3 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 25 February 2012 - 02:21 PM

Updated to v1.1 of the API, new utilities are:
magicTurtle.tunnel(width, height, lenght)
magicTurtle.staircase(width, height, lenght) --cuts out a staircase in a material
magicTurtle.build(blueprint) --builds stuff
blueprint must be like:
bleuprint={layer1, layer2, etc}
layers are vertical and like so:
layer1={row1, row2, etc}
row1={block1, block2, etc}
block1, block2 are slot numbers for placed blocks or 0 for no block


#4 Dirkus7

  • Members
  • 148 posts
  • Locationthe Netherlands

Posted 25 February 2012 - 08:56 PM

It's a very nice API, good work! :(/>

#5 ThePH

  • Members
  • 31 posts

Posted 26 February 2012 - 01:33 AM

GG nice work. I like the build from blueprint :)/>

#6 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 26 February 2012 - 07:10 PM

Okay, new update! Now features a sketch() function to draw blueprints. Usage:
local a=magicTurtle.sketch()
magicTurtle.build(a)

I forgot. There's also a mining function:
diamondMine(length) --length is the length of the branches of the mine


#7 Zim

  • New Members
  • 3 posts

Posted 27 February 2012 - 12:00 PM

Any way to get the absolute coords. For example I want to drop a terminal, run code, and it will summon the nearest turtle. To do that I need the terminal to be aware of its coords and the turtle to be aware of its coords - without relying on initialising the turtle/terminal with arbitary 0,0,0 coords.

#8 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 27 February 2012 - 01:58 PM

wait, you don't need to use arbitrary coords

magicTurtle.setPos(x,y,z)

Also, there'll be an update coming up for remote controlling over modems/rednet and detecting floppy drives automatically

#9 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 27 February 2012 - 03:26 PM

Update 1.23 is here! Features: automining, background enviroment handling:
if you're using autoUpdate() and turtle passes next to a disk drive with folder magicTurtleUpdate, it'll execute update file that's in said folder. Also, allows for remote control using sendCommand() function.

Also, added a list of working functions.

#10 impatientplague

  • New Members
  • 2 posts

Posted 27 February 2012 - 06:44 PM

so ..how to i use this API , where do install it how do i run it etc..the wiki to be frank is empty almost zero doc's on this subject...that i can find

#11 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 27 February 2012 - 07:04 PM

save this as magicTurtle (without the '.txt' part) into your turtle's root folder (.minecraft/saves/savename/computer/computerID/).
then enter LUA prompt in-game. type 'os.loadAPI("magicTurtle")' then follow the instructions in the first post. then you can simply call the functions by using magicTurtle.functionname(params) (e.g. 'magicTurtle.tunnel(3,3,10)' )
the rest is up to you.

#12 Marv-inside

  • New Members
  • 6 posts

Posted 27 February 2012 - 09:25 PM

Does this work with Bukkit?
Can't get it to work...

#13 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 27 February 2012 - 09:27 PM

well, it should, but there were weird behaviors reported connected with bukkit. Are you sure you placed it in the correct folder? Also, if you get errors, can you post them here?

#14 panicmore

  • Members
  • 26 posts
  • LocationEssex, UK

Posted 27 February 2012 - 09:41 PM

Thanks for telling of bout this liraal great job can I use this if I credit it to you

#15 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 27 February 2012 - 09:43 PM

sure, go ahead

#16 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 28 February 2012 - 07:26 PM

Updated to 1.24, new feature: Roads of redstone torches. place them in a row (can go up and down, but in 2-blocks-long steps) and the turtle above the first one and use magicTurtle.road()

#17 Wired2coffee

  • Members
  • 46 posts
  • LocationThe Coffee Maker

Posted 29 February 2012 - 03:35 AM

I have a perfected version of the coordinate saver in my Tortoise API that will work with servers. http://pastebin.com/qURqLBp7

#18 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 29 February 2012 - 06:27 AM

my should handle SMP no problem, i dont see an issue. (i didnt test that, but code's code, right?)

EDIT: New version is coming along shortly. Upcoming features:
- Auto-treefarming
- Patching holes in the ground
- Patrolling an area
- Wandering around
- Saving to file
- Landmines (plain, or with fancy rednet control)

#19 suchipi

  • New Members
  • 1 posts

Posted 29 February 2012 - 05:03 PM

View PostLiraal, on 27 February 2012 - 07:04 PM, said:

save this as magicTurtle (without the '.txt' part) into your turtle's root folder (.minecraft/saves/savename/computer/computerID/).
then enter LUA prompt in-game. type 'os.loadAPI("magicTurtle")' then follow the instructions in the first post. then you can simply call the functions by using magicTurtle.functionname(params) (e.g. 'magicTurtle.tunnel(3,3,10)' )
the rest is up to you.
Alternatively put magicTurtle in .minecraft/mods/ComputerCraft/lua/rom/apis/turtle/ and it will be available to all turtles. You may need to reboot existing turtles for this to come into effect.

#20 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 29 February 2012 - 07:23 PM

Update 1.25 is live! New functions:


wander() --wanders aimlessly around
wanderer(func) --the above but while doing a function func
jack(sap) --plants, watches and cuts down a single tree (param is the slot with saplings)
treefarm(sap) --the same but on full auto (param as above)
landmine(slot, net) --turtle buries itself in the ground and places TNT that is triggered when someone walks on top of it. Can be armed/disarmed by rednet if net is set to true. (slot is the slot containing TNT)
patch(slot, l, w) --patches holes in the ground (slot is the slot for filling material, like dirt/gravel, l is length and w is width)
guardArea(exec, w, l) --patrols an area, if detects a hole/obstacle triggers function exec
remoteArm(id) --arms the mine of the ID given (the arming terminal must be tuned with the mine, see below setMineID())
remoteDisarm(id) -- disarms the mien
remoteSleep(id, t) -- disarms, waits 't' time and arms again
setMineID(arming, disarming) -- sets mine's arming/disarming IDs (these are separate and can differ from each other)
savePos() --saves turtle pos to a file
getPosF() --gets turtle pos from file

If you want a specific function to be added and it's not present yet, just write it in this thread.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users