Posted 21 August 2013 - 06:41 PM
Billy!
I was bored, so made this. Something that I, personally, think I am actually going to get use out of, which makes a change.
Please excuse the name, it was temporary at first but then I used it to much…
Usage:
you run the program, so "billy", followed by the name of the billy-program you want to run and and parameters you want to run it with, for example:
Documentation:
if you have any suggestions on anything I can add, I'll be happy to add it
Example:
Download:
http://pastebin.com/MxjneLTR
Thanks :)/>
I was bored, so made this. Something that I, personally, think I am actually going to get use out of, which makes a change.
Please excuse the name, it was temporary at first but then I used it to much…
Usage:
you run the program, so "billy", followed by the name of the billy-program you want to run and and parameters you want to run it with, for example:
billy example 15 10
And that's it.Documentation:
Spoiler
NOTE: further details on each function can be found in the code, above the function, in a comment.if you have any suggestions on anything I can add, I'll be happy to add it
Billy documentation;
Functions and run down of billy table:
billy - main table, global
billy.dump - a table used to store your own variables, to stop cluttering of _G
billy.time - the current game-clock time
billy.load() - function to override, called at the start of the program
billy.update() - function to override, called every 0.05 seconds
billy.draw() - function to override, called every 0.05 seconds, return true if you wish to render that frame
billy.event(event, p1, p2, p3) - function to override, called every time an event occurs that isn't overridden by billy
billy.quit() - function to override, called when the program is exited
billy.keys - a table configuration for the keys used in billy
billy.keys.used - a table containing all the key-codes used by billy
billy.keys.used[29] - 29 (left Ctrl) is the only button used by billy currently
billy.keys.quit = 29 - the button used to quit
billy.misc - a table containing random functions
billy.misc.flipTable(table) - function that returns a table containing the input table's numerical index and values in reverse order
billy.misc.split(string, pattern) - returns a table of the string split up by the pattern
billy.graphics - the billy graphics library
billy.graphics.LOCAL_DATA - contains all the data used to draw graphics objects
billy.graphics.LOCAL_DATA.background - the background colour of the object
billy.graphics.LOCAL_DATA.text - the background colour of the object
billy.graphics.LOCAL_DATA.size - the size of the shape, irrelevant currently
billy.graphics.LOCAL_DATA.char - the character used to draw the object
billy.graphics.setBackgroundColor(color) - sets the background colour
billy.graphics.setBackgroundColour(colour) - sets the background colour
billy.graphics.setTextColor(color) - sets the text colour
billy.graphics.setTextColour(colour) - sets the text colour
billy.graphics.setSize(size) - sets the size
billy.graphics.setChar(character) - sets the char
billy.graphics.drawLine(x1, y1, x2, y2) - draws a line
billy.graphics.createShape(poly) - creates a shape/polygon
billy.graphics.drawShape(shape) - draws a shape
billy.graphics.createTriangle(p1, p2, p3) - creates a triangle, different to createShape
billy.graphics.fillTriangle(tri) - fills in a triangle table returned from createTriangle, returns in shape format
billy.graphics.fillQuad(p1, p2, p3, p4) - creates and returns a quadrilateral shape filled in
billy.graphics.createCircle(centre, radius, fill) - creates a circle in shape format
billy.IO - the billy IO library
billy.IO.getLines(dir) - gets the lines of a file
billy.IO.writeLines(dir, lines) - overrides or creates a file and writes the given lines in the file
billy.IO.addLines(dir, lines) - adds lines in to a file
billy.image - the billy image library
billy.image.createImageTable(dir) - creates an image-table table out of a file
billy.image.getImage(imagetable, name) - gets an image with a certain name out of an imagetable
billy.bufferAPI - the billy buffer API (I would ignore this part)
billy.bufferAPI.curCols - a table containing information for the buffer.
billy.bufferAPI.buffer_details - a table containing buffer details
billy.bufferAPI.getColorTab(char, background, text) - a function for use in the buffer
billy.bufferAPI.addColorTab(col) - a function for use in the buffer
billy.bufferAPI.createColor(char, background, text) - a function for use in the buffer
billy.bufferAPI.createPixel(x, y, col) - a function for use in the buffer
billy.bufferAPI.createBuffer() - creates and returns a buffer
billy.buffer - the billy buffer, recommended instead of term API, can override term API
billy.buffer.width - the width of the screen
billy.buffer.height - the height of the screen
billy.buffer.changes - a table for use in the buffer
billy.buffer.changed - a table for use in the buffer
billy.buffer.term - the standard term table, so that it's safe to override
billy.buffer.ps - the current changes of pixels per frame
billy.buffer[x][y] - returns a "pixel" table
billy.buffer:get(x, y) - returns the pixel at x,y or nil if there is none
billy.buffer:check(x, y) - returns true/false if that pixel has changed or not
billy.buffer:set(x, y, col) - sets the pixel at x,y to that colour
billy.buffer:render() - renders the buffer, automatically done when returning true on billy.draw()
billy.buffer:setBuffer() - sets the current in-use buffer to this, as long as you are only using 1 buffer don't worry about this
billy.buffer.setCursorPos(x, y) - sets the cursor position to x, y
billy.buffer.setBackgroundColor(col) - sets the background colour to col
billy.buffer.setTextColor(col) - sets the text colour to col
billy.buffer.getSize() - returns width,height of the screen
billy.buffer.writeChar(char, ox, oy) - writes a single character "char" with the offset ox,oy
billy.buffer.write(string) - writes a string
billy.buffer.clear() - clears the screen, setting it all to the current background colour
billy.buffer:reset() - does the same as billy.buffer.clear()
Example:
Spoiler
at a 0.25 second interval it makes a randomly sized pink circle in a random place on the screen, as standard for billy Left Ctrl is quit
billy.load = function()
billy.dump.OLD_TERM = term
term = billy.buffer
term.setBackgroundColor(colors.black)
billy.graphics.setBackgroundColor(colors.pink)
term.clear()
end
billy.dump.lastTime = billy.time
billy.draw = function()
if billy.time-billy.dump.lastTime >= 5 then
local pos = {math.random(term.width), math.random(term.height)}
term.setBackgroundColor(colors.black)
term.clear()
local circle = billy.graphics.createCircle(pos, math.random(3, 5), true)
billy.graphics.drawShape(circle)
billy.dump.lastTime = billy.time
return true
end
end
billy.quit = function()
term = billy.dump.OLD_TERM
end
Download:
http://pastebin.com/MxjneLTR
Thanks :)/>