Posted 04 March 2015 - 12:19 AM
Turtle Extended API - Extended identification, Dig/Place Blacklist, Position Awareness, Extra Movement, Small Additions v0.2
Turtle Extended API is something i am working on and off for my turtles. It contains few things i always need from turtle no matter what program i am making so why not make it an API?
This is still Work In Progress however #Tag system , blacklist and other additions are working and finalized so i decided to post it for other people to play with.
Download Here: http://pastebin.com/X8NEcEVy
Or ingame using command:
Features List:
exturtle.turtle=oldturtle –acces to basic turtle in case i overwrite basic turtle with this api useing os.loadAPI("turtle")
exturtle.version="TurtleExtended By Wojbie"
–# Taglist functions
–There are special tags that are not removeable from api
–#All is given to all blocks always
–#Modname - where Modname is name of mod adding block - for easy itendification. #minecraft is for all minecraft blocks, #ComputerCraft for all computercraft block ect
–Also on load 6 Tags are created
–#DigBlacklist –used by dig functions
–#DigWhitelist –used by dig functions
–#PlaceBlacklist –used by place functions
–#PlaceWhitelist –used by place functions
–#Blacklist –Child of both blacklist tags from up - for blacklisting place and dig at same time
–#Whitelist –Like blacklist but with whitelist
–This version contains some tag definitions that are in the progress of finalizing like #tree or #liquidSourceBlock
–There are planned patchfiles for mods that will add moditems to definition lists. Will make them only for mods i play with sorry.
exturtle.addTag(Tag) –Creates tag for use in Tag system
exturtle.removeTag(Tag) –Deletes tag and all its contents
exturtle.addBlockToTag(Tag,Block,Meta) –Adds Block to Tag Definition. if Meta if not specified any meta is valid
exturtle.addChildToTag(Tag,Child) –Adds Child tags to Tag Definition. Any blocks tagged with Child will get tagged with This TAG too.
exturtle.listTag(Tag) – Lists all lines from Tag Definition
exturtle.delTag(Tag,num) –Removes line from Tag Definition, removing Block or tag defined there
exturtle.saveTag(A) –Saves All tags into file A, if A not specified saves to /tag.log
exturtle.loadTag(A) –Saves All tags from file A and removes all currently set tags. if A not specified loads from /tag.log
–# POSITIONING
–turtle position is saved as table with keys
pos = {x=0,y=0,z=0,xd=1,zd=0,f=?}
–x,y,z are coords of turtle
–xd,zd are direction its facing
–f is minecraft facing direction divined from xd,za
exturtle.savePos(A) –Saves postion into file A, if A not specified saves to /gps.log
exturtle.loadPos(A) –Loads postion from file A and sets turtle pos to that value, if A not specified loads from /gps.log
exturtle.loadPoint(A) –Loads postion from file A and returns it as table., if A not specified loads from /gps.log
exturtle.setPos(x,y,z,xd,zd) –set position to provided parameters
exturtle.getPos() –get static table with current position
exturtle.getDynamicPos() –get table that always contains current position. Warning - messing with this table can cause turtle to go Bonkers..
–# basic movement
– all fucntion make sure to update current position after beaing called.
exturtle.turnRight()
exturtle.turnLeft()
exturtle.up()
exturtle.down()
exturtle.forward()
exturtle.back()
–# getting position
exturtle.gpsPos(A) –gets pos from GPS – will get lost in process sometimes.
–# /POSITIONING
–# ENTHANCMENTS
–# Inspection
–Adds key "tags" that containg lookup table full of tags. per example table.tags["#ComputerCraft"] will be true for all computercraft blocks and items
exturtle.inspect()
exturtle.inspectUp()
exturtle.inspectDown()
exturtle.getItemDetail(A)
–# Comparing utility
– allows to easly compare with item from slot by accepting slow value, if value not added it will compare selected slot like normal.
exturtle.compare(slot)
exturtle.compareUp(slot)
exturtle.compareDown(slot)
–# Fuel information
exturtle.getFuelLevel() –if turtles dont need fuel on the server it returns getFuelLimit value. Never "unlimited"
exturtle.getFuelLimit() –How mutch turtle will be able to refuel to
exturtle.getFuelPercent() –number from 0-1 where 0 is empty and 1 - full
exturtle.getFuelSpace() –how mutch space for fuel is left.
–# Smart Refuel
exturtle.refuel(A) –limit aware refuel - will never overfuel even if ordered to.
–# /ENTHANCMENTS
–# BLACKLIST AND WHITELIST IMPLEMENTATION
–All dig functions look for tags #DigWhitelist and #DigBlacklist
–iF block is whitelisted blacklist is not considered
–if block is blacklisted it will not be mined
–On loadAPI all computercraft block (using tag "#ComputerCraft") and monster_stawners anre blacklisted.
exturtle.dig() return di("") end
exturtle.digUp() return di("Up") end
exturtle.digDown() return di("Down") end
–All place functions look for tags #PlaceWhitelist and #PlaceBlacklist
–iF block is whitelisted blacklist is not considered
–if block is blacklisted it will not be placed
–On loadAPI Bedrock anre blacklisted.
exturtle.place(A) return pi("",A) end
exturtle.placeUp() return pi("Up") end
exturtle.placeDown() return pi("Down") end
–# /BLACKLIST AND WHITELIST IMPLEMENTATION
–# GOTO –direct with no pathfinding
exturtle.face(A, B)/>/> –makes turtle face ditection A,B - they are directions xd znd zd from point definition.
exturtle.fromTo(…) –Distance between 2 points. If given more than 2 points it will claculate minimal fuel to go from first to last in order given
exturtle.goto(A) –turtle attempts to take most direct route to the point. No pathfinging included just goed from where he is to point A.
–# /GOTO
–# UNIMPLEMENTED
–PATHFINGING1 –blind turtle stumble
exturtle.upP()
exturtle.downP()
exturtle.forwardP()
exturtle.backP()
–/PATHFINGING1
–PATHFINGING2 –map based - to add later
–/PATHFINGING2
Notes:
Turtle Extended API is something i am working on and off for my turtles. It contains few things i always need from turtle no matter what program i am making so why not make it an API?
This is still Work In Progress however #Tag system , blacklist and other additions are working and finalized so i decided to post it for other people to play with.
Download Here: http://pastebin.com/X8NEcEVy
Or ingame using command:
pastebin get X8NEcEVy exturtle
Features List:
- Extended block and item identification by use of #Tag system
- Blacklist for placement/digging
- Positional awareness and tracking of its own position
- Enchantments to many turtle functions
- Basic Goto implementation
- Pathfinding
Spoiler
–# Basic onesexturtle.turtle=oldturtle –acces to basic turtle in case i overwrite basic turtle with this api useing os.loadAPI("turtle")
exturtle.version="TurtleExtended By Wojbie"
–# Taglist functions
–There are special tags that are not removeable from api
–#All is given to all blocks always
–#Modname - where Modname is name of mod adding block - for easy itendification. #minecraft is for all minecraft blocks, #ComputerCraft for all computercraft block ect
–Also on load 6 Tags are created
–#DigBlacklist –used by dig functions
–#DigWhitelist –used by dig functions
–#PlaceBlacklist –used by place functions
–#PlaceWhitelist –used by place functions
–#Blacklist –Child of both blacklist tags from up - for blacklisting place and dig at same time
–#Whitelist –Like blacklist but with whitelist
–This version contains some tag definitions that are in the progress of finalizing like #tree or #liquidSourceBlock
–There are planned patchfiles for mods that will add moditems to definition lists. Will make them only for mods i play with sorry.
exturtle.addTag(Tag) –Creates tag for use in Tag system
exturtle.removeTag(Tag) –Deletes tag and all its contents
exturtle.addBlockToTag(Tag,Block,Meta) –Adds Block to Tag Definition. if Meta if not specified any meta is valid
exturtle.addChildToTag(Tag,Child) –Adds Child tags to Tag Definition. Any blocks tagged with Child will get tagged with This TAG too.
exturtle.listTag(Tag) – Lists all lines from Tag Definition
exturtle.delTag(Tag,num) –Removes line from Tag Definition, removing Block or tag defined there
exturtle.saveTag(A) –Saves All tags into file A, if A not specified saves to /tag.log
exturtle.loadTag(A) –Saves All tags from file A and removes all currently set tags. if A not specified loads from /tag.log
–# POSITIONING
–turtle position is saved as table with keys
pos = {x=0,y=0,z=0,xd=1,zd=0,f=?}
–x,y,z are coords of turtle
–xd,zd are direction its facing
–f is minecraft facing direction divined from xd,za
exturtle.savePos(A) –Saves postion into file A, if A not specified saves to /gps.log
exturtle.loadPos(A) –Loads postion from file A and sets turtle pos to that value, if A not specified loads from /gps.log
exturtle.loadPoint(A) –Loads postion from file A and returns it as table., if A not specified loads from /gps.log
exturtle.setPos(x,y,z,xd,zd) –set position to provided parameters
exturtle.getPos() –get static table with current position
exturtle.getDynamicPos() –get table that always contains current position. Warning - messing with this table can cause turtle to go Bonkers..
–# basic movement
– all fucntion make sure to update current position after beaing called.
exturtle.turnRight()
exturtle.turnLeft()
exturtle.up()
exturtle.down()
exturtle.forward()
exturtle.back()
–# getting position
exturtle.gpsPos(A) –gets pos from GPS – will get lost in process sometimes.
–# /POSITIONING
–# ENTHANCMENTS
–# Inspection
–Adds key "tags" that containg lookup table full of tags. per example table.tags["#ComputerCraft"] will be true for all computercraft blocks and items
exturtle.inspect()
exturtle.inspectUp()
exturtle.inspectDown()
exturtle.getItemDetail(A)
–# Comparing utility
– allows to easly compare with item from slot by accepting slow value, if value not added it will compare selected slot like normal.
exturtle.compare(slot)
exturtle.compareUp(slot)
exturtle.compareDown(slot)
–# Fuel information
exturtle.getFuelLevel() –if turtles dont need fuel on the server it returns getFuelLimit value. Never "unlimited"
exturtle.getFuelLimit() –How mutch turtle will be able to refuel to
exturtle.getFuelPercent() –number from 0-1 where 0 is empty and 1 - full
exturtle.getFuelSpace() –how mutch space for fuel is left.
–# Smart Refuel
exturtle.refuel(A) –limit aware refuel - will never overfuel even if ordered to.
–# /ENTHANCMENTS
–# BLACKLIST AND WHITELIST IMPLEMENTATION
–All dig functions look for tags #DigWhitelist and #DigBlacklist
–iF block is whitelisted blacklist is not considered
–if block is blacklisted it will not be mined
–On loadAPI all computercraft block (using tag "#ComputerCraft") and monster_stawners anre blacklisted.
exturtle.dig() return di("") end
exturtle.digUp() return di("Up") end
exturtle.digDown() return di("Down") end
–All place functions look for tags #PlaceWhitelist and #PlaceBlacklist
–iF block is whitelisted blacklist is not considered
–if block is blacklisted it will not be placed
–On loadAPI Bedrock anre blacklisted.
exturtle.place(A) return pi("",A) end
exturtle.placeUp() return pi("Up") end
exturtle.placeDown() return pi("Down") end
–# /BLACKLIST AND WHITELIST IMPLEMENTATION
–# GOTO –direct with no pathfinding
exturtle.face(A, B)/>/> –makes turtle face ditection A,B - they are directions xd znd zd from point definition.
exturtle.fromTo(…) –Distance between 2 points. If given more than 2 points it will claculate minimal fuel to go from first to last in order given
exturtle.goto(A) –turtle attempts to take most direct route to the point. No pathfinging included just goed from where he is to point A.
–# /GOTO
–# UNIMPLEMENTED
–PATHFINGING1 –blind turtle stumble
exturtle.upP()
exturtle.downP()
exturtle.forwardP()
exturtle.backP()
–/PATHFINGING1
–PATHFINGING2 –map based - to add later
–/PATHFINGING2
Notes:
- Api is written in the way that allows replacement of basic turtle api. Simplay save it as turtle file and use os.loadAPI("turtle") to make that happen. This will cause all programs on turtle to use my API. Functions not modified by api are copied direclty from old turtle api.
- This is work in progress api. Many sanity checks are missing. Please still reports errors you see if you see them.
- This is by Slow Burn project. I am working on it when i get idea or run out ideas for other ones. Updates will be far between.
- Everything is a subject to change and documentation my sometimes be wrong. This is still active project.
Edited on 03 March 2015 - 11:24 PM