In order of creation (will start with messy, unprofessional code, sorry)
SCREEN BUFFER:
Spoiler
After running this program the term api is modified, as you write to the screen it records what has been written in a table. call term.getTextColor() and term.getBackgroundColor() to get the current colors and use term.getTextAt(x,y,[len]) to return whatever text is at those co-ordinates on the screen, it also returns the text color and the background color at x,yBACKGROUND REDNET:
Spoiler
After executing this program shell is re-launched and a rednet coroutine is run, you can then call myNet.send(message,id) to send a message to the specified ID, if ID is omitted it sends to all computers, use myNet.receive() to receive messages, while this is running all myNet messages will be automatically forwarded through computers and turtles running it so if you have 2 computers far away from eachother and a bunch of wireless turtles doing absolutely anything in between then it will forward through those turtles and get to the second computer. name the file startup and it will run startup2 after executionADVANCED COMPUTER UTILITIES:
Spoiler
A collection of functions I used in a few instances that I think may be useful. you can then call term.getBackgroundColor() and term.getTextColor() to recall the current color configuration, draw(x,y,colour) will colour the box at x,y the specified colour, then it has 2 functions for mouse listening, make a tablea={}
and use it in the first function which adds areas to the table, those areas will be used in the next function, call addArea(table,x1,y1,x2,y2,function) and it will write the area x1-x2; y1-y2 to your table to call function when it is selected, then call listen(table) to listen to the areas in that table, if someone clicks in one of those areas it will execute function with the parameters: (xCD,yCD,button) where xCD and yCD are the exact co-ordinates of the click and button is the mouse button used.EXAMPLE
myfunc=function(x,y,btn)
print("you pressed button "..btn.." at CDS: ["..x..", "..y.."]")
end
myT={}
addArea(myT,2,2,5,5,myfunc)
listen(myT)
then click at 2,3 and it will print "you pressed button 1 at CDS [2, 3]" but if you click outside of the area 2-5;2-5 it will do nothingTOP LEVEL COROUTINE EDIT:
Spoiler
After running this program the top level shell will be terminated, a new instance of shell, rednet and a messaging coroutine will then run, call addCo(function,ref) to add a function to the coroutine stack which will then be run with the others, each coroutine is assigned a reference which can be used to remove it, you can assign it with ref or it will assign you a numeric reference that will be returned by the addCo function, then call remCo(ref) to cancel a coroutine, a coroutine cannot cancel itself. if a coroutine ends you will be notified at the top right of the screen, call os.queueEvent("message",message) to show the message for 2 seconds at the top of the screen2D PATHFINDER:
Spoiler
An intelligent pathfinder function. pass it a table in the correct format and the co-ordinates you want to get to (you start at 1,1) and it will find the path to it and will print it in the form of a string. for example"lluurr"
means go left twice, up twice and right twice
this function was inspired by kylergs' post in Ask a Pro
3D PATHFINDER:
Spoiler
Exactly the same as the 2D version for a 3D map, once again thanks to kylergs for reminding me to build this and thanks to TheOriginalBIT for this post :D/>PATHFINDER API:
Spoiler
This is the API version of the 3D pathfinder, it includes 2 functions, a ever so slightly modified version of the path function (just variable renames) and an edit function which you can use to create compatible maps or edit maps already created with it. use the code
local mymap=apiname.edit()
to start the creator, use the arrow keys to navigate and press 0 to place an empty space, 1 to place a wall, + to move up a layer, - to move down a layer, delete to remove the current layer, insert to add a new layer. once the map is done press "s" to close the editor and the create function will return the map. call apiname.edit(mymap) to then modify that map. then use
apiname.path(mymap,targetx,targety,targetz)
to path through the map and search for a path to [targetx,targety,targetz] from [1,1,1]. it will return it in string form as described in the 2D pathfinder or it will return false if you cannot get to the targetthe visual display is disabled but still coded in this one. just remove the comments on line 219 and 220
if you are using this to pathfind your CC turtles you can use the included follow command to make your turtle follow the path. use
apiname.follow(path,[direction]) where path is the path returned by apiname.path and the direction is "u", "d", "l" or "r" (defaults to "d") and the turtle will follow the path given. please note that consecutive layers go DOWNWARDS not up
LAYER API:
Spoiler
run this file as a program and it changes the term API to be redirected to my layer rendering system. basically it behaves just like the screen logger (except less buggy and uses tables for the rows recording rather than strings) and then you can call term.newLayer(<index>,tParams) to create a new rendering layer at z-level <index>.tParams is a table of options, valid options are:
showscroll
scrolling
linked
showscroll renders a scroll-bar on the right hand side of the screenscrolling enables or disables layer.scroll()
linked links the layer to the term layer, all linked layers scroll together
each layer is like a separate term, it has its own cursor pos, record, text color etc. here is a usage example
local myLayer=term.newLayer(5,{linked=true})
myLayer.setCursorPos(5,5)
myLayer.write("hi")
and "hi" will appear at 5,5 however it is a layer on its own so term.scroll() will not scroll it up, it will remain there even if you write to its location etc. this way you can design GUIs with displays independant of eachother, you can clear layers rather than the whole screen etc. term.getTextAt still functions as it did in the screen logger, screenshot & loadscreen have been removed thoughit also adds term.newWindow(offsetX,offsetY,limX,limY,<index>) so you can create layers limited to the location [offsetX-limX,offsetY-limY], they literally think that their little window is the entire screen so window.getSize() returns the size of the window and window.setCursorPos(1,1) sets the position to the origin of the window, not actually [1,1].
layer.write now accepts an additional 2 parameters (both are booleans), the first is whether it automatically scrolls onto the next line rather than print over the edge of the page, the second is whether it should auto-indent and scroll to the same x co-ordinate it started at rather than x=1
it has since been updated to include a speed increase and a few more parameters present in the latest KaoShell
KaoShell: HAS BEEN MOVED TO A SEPARATE POST HERE