Jump to content




[APIs][Programs][Utilities]Mad's Programs

api lua utility

  • You cannot reply to this topic
17 replies to this topic

#1 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 04 April 2012 - 07:21 AM

Mad's Programs

Index

____________________________________________________________________________________________________________________________________________________________________

____________________________________________________________________________________________________________________________________________________________________



fLib - Extended file handling

fLib is an API, that makes file handling a breeze. Write, append, even replace lines in a file with one line of code.
This is a must have for file-based programs. Also, this API can be used both inside CC, and outside.

Functions
flib.exists(path) --Returns true if path exists, and is a file
flib.getTable(path) --Returns a table with all the lines
flib.getLine(path, n) --Returns the Nth line
flib.getText(path) --Returns all the text in the file
flib.fwrite(path, text) --Writes text in a file
flib.fappend(path, text) --Appends text to a file
flib.fwriteAtStart(path, text) --Writes text at the start of a file
flib.fwriteFromTable(path, table) --Writes each field in table as a line in the file
flib.fappendFromTable(path, table) --Appends to a file with each field in table as a line
flib.fwriteAtStartFromTable(path, table) --Writes at the start of a file with each field in table as a line
flib.fwriteFromLine(path, n, text) --Writes text from Nth line, and keeps everything beneath the Nth line
flib.fwriteFromLineFromTable(path, line, table) --Writes from Nth line with each field in table> as a line, and keeps everything beneath the Nth line
flib.replaceLine(path, line, text) --Replaces the Nth line in a file with text
flib.getName(path) --Returns the name of the file, without the path
flib.getPath(path) --Returns the path of the file, without the name
flib.fremove(path) --Removes a file

Usage
You use this API as any other API. Install it, and you will be able to use every function like this:
flib.function(args)

Installation
  • Download the file
  • Navigate to your .minecraftmodsComputerCraftluarom folder
  • put the file in the apis folder
  • Start Minecraft
  • Handle some files!

Download
You can download the API here



Ovar - Persistant variables

This API makes storing variables something anyone can do. Create new variables, change them as you wan't to, save them and load them. Very useful for login systems and/or e.g. game highscores. It is very easy to use, and doesn't require much skill to master.


Functions
ovar.new(name, value) --Creates a new variable, that can now be loaded
ovar.load(name) --Returns an old value, asuming that it exists


Usage
Example 1: Creating a variable, and printing the value
local x = ovar.new("test", 10) --We create a the variable
x:save() --We save the value, so it can be used later
print(x.value) --We print the value
x:unload() --We unload the variable

------------------------------------------------
Output:
10


Example 2: Changing the value(Using the variable from before)
local x = ovar.load("test")
x.value = {"Hello ", "World!"} --We set the value of x to a table
x:save()
print(x.value[1] .. x.value[2]) --We print the two fields in the table

------------------------------------------------
Output:
Hello World!

Programs using this API
Installation
  • Download the file
  • Navigate to your .minecraftmodsComputerCraftluarom folder
  • Put the file in the apis folder
  • Start Minecraft
  • Make some variables!

Download
You can download the API here




Modifications

Modified BIOS - os.remove() and custom read()

This BIOS adds one function, and replaces another one. It adds os.remove(), and replaces read() with a function I made.

Installation:
  • Download the file
  • Navigate to your .minecraftmodsComputerCraftlua folder
  • Put the file in there
  • Start Minecraft
  • Read some text!

Download
You can download the BIOS here



Layout Classes/Modules

Textfield - Create editable textfields

This class allows you to create textfield, that can be edited, you can set the value, get the value, and all sorts of stuff. Useful for making GUIs.

Functions
Textfield.new(name, x, y) --Creates a new textfield at (x, y), and returns it
Textfield:draw() --Draws the textfield on the screen
Textfield:setText(text) --Sets the value teh the instance to text
Textfield:edit() --Puts the cursor inside the textfield, and lets you edit the text
Textfield:setVisible(:)/>/> --Will the the visiblility to b
Textfield:getText() --Returns the value
Textfield:getMaxLenght() --Returns the max lenght allowed
Textfield:isVisible() --Returns true if the instance is visible
Textfield:setMaxLenght(lenght) --Sets the max lenght to lenght
]Textfield:setX(x) --Sets the instance's x position to x
Textfield:setY(y) --Sets the instance's y position to y
Textfield:getX() --Returns the instance's x position
Textfield:getY() --Returns the instance's y position


Usage
This class is very simple to use.

Example 1: Creating a textfield, setting the value and drawing it
local tf = Textfield.new("tf", 10, 2, 30) --We create the textfield
tf:setText("Hello World!") --We set the text
tf:draw() --We draw the textfield

Example 2: Editing the textfield, and drawing it(Using the textfield from before)
tf:edit() --We go in edit mode
tf:draw() --When the user is done editing, we draw the textfield

You get the point. It is very simple, and right on.

Installation
  • Download the file
  • Navigate to your .minecraftmodsComputerCraftluarom folder
  • Put the file in the apis folder
  • Start Minecraft
  • Make some textfields!

Download
You can download the API here



Button - Create clickable buttons

Functions
Button.new(name, x, y width, height) --Creates a new button, and returns it
Button:draw() --Draws the instance
Button:setText(text) --Sets the instance's text to text
Button:setVisible(:D/>/> --Will set the instance's visibility to b
Button:getText() --Returns the instance's text
Button:getWidth() --Returns the instance's width
Button:getHeight() --Returns the instance's height
Button:setAction(f) --Sets the action to f (MUST BE A FUNCTION)
Button:onClick() --Performs the instance's action
Button:setX(x) --Sets the instance's x position to x
Button:setY(y) --Sets the instance's y position to y
Button:getX() --Returns the instance's x position
Button:getY() --Returns the instance's y position
Button:getAction() --Returns the action
Button:setWidth(width) --Sets the instance's width to width
Button:setHeight(height) --Sets the instance's height to height


Usage
This class is very simple to use.

Example 1: Creating a button, setting the action, setting the text and drawing it
local f = function() --We create the action
	print("Hello World!")
end
local bu = Button.new("button1", 10, 2, 20, 5) --We make the button
bu:setAction(f) --We set the action
bu:setText("Click me!") --We set the text
bu:draw() --We draw the button


Example 2: Performing the action(Using the button from before)
bu:onClick()

Installation
  • Download the file
  • Navigate to your .minecraftmodsComputerCraftluarom folder
  • put the file in the apis folder
  • Start Minecraft
  • Click some buttons!

Download
You can download the API here



Batch Interpreter - Write batch programs and run them
This is my current project, so I currently don't have anything to show. It's supposed to be done in about 3 weeks, maybe even after.













Source code - Stay up to date



If you make any programs/APIs/utilities using some of this software, please post them in the comments! That would mean alot to me!


If you read just some of this, thank you alot. Please leave suggestions/requests/feedback in the comments!
-mad1231999

#2 Wolvan

  • New Members
  • 384 posts
  • LocationIn the TARDIS

Posted 04 April 2012 - 10:04 AM

Nice! Can you tell me a little bit more about the Custom BIOS? What is os.remove() used for example? Or what is the difference of read and custom read?

#3 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 04 April 2012 - 10:11 AM

View PostWolvan, on 04 April 2012 - 10:04 AM, said:

Nice! Can you tell me a little bit more about the Custom BIOS? What is os.remove() used for example? Or what is the difference of read and custom read?
os.remove() is an inbuilt function in Lua, that CC does not support. So I created it.
The read function has almost no difference, except the fact that my read function does not provide history compatiblity(Easy to add though)
And thanks!

#4 Wolvan

  • New Members
  • 384 posts
  • LocationIn the TARDIS

Posted 04 April 2012 - 10:26 AM

offtopic:
I made the Tomoyo Banners. You can add yours to the signature

#5 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 04 April 2012 - 11:50 AM

View PostWolvan, on 04 April 2012 - 10:26 AM, said:

offtopic:
I made the Tomoyo Banners. You can add yours to the signature
Thanks! I certainly will

#6 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 04 April 2012 - 11:51 AM

View PostWolvan, on 04 April 2012 - 10:26 AM, said:

offtopic:
I made the Tomoyo Banners. You can add yours to the signature
I haven't got any PM:(

#7 Wolvan

  • New Members
  • 384 posts
  • LocationIn the TARDIS

Posted 09 April 2012 - 10:07 PM

I wanted to ask if I could add your fLib API into 1 of my APIs

This is a secret bump

#8 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 10 April 2012 - 12:26 PM

You can! Just give credit :P/>

#9 Wolvan

  • New Members
  • 384 posts
  • LocationIn the TARDIS

Posted 10 April 2012 - 04:00 PM

OK I certainly will :D/>
And I didn't need to put your code in my file: I just looked at yours and used some elements of the file API :P/>
But thx anyway. If I need it someday I will credit you for sure

#10 Zer0t3ch

  • Members
  • 33 posts
  • LocationIllinois, USA

Posted 10 April 2012 - 04:15 PM

All of these look AWESOME! I will most definitely be trying this later. These will definitely make a lot of things easier.

Also, would you be okay with me possibly implementing some of this INTO my code so that people don't have to download your APIs as well, provided I give you full credit for your work on the post and in the program? This is all theoretical right now, but please shoot me a PM and lemme know what you think.

#11 Wolvan

  • New Members
  • 384 posts
  • LocationIn the TARDIS

Posted 10 April 2012 - 07:15 PM

I asked him that as well Zero :P/>

#12 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 11 April 2012 - 03:34 PM

View PostZer0t3ch, on 10 April 2012 - 04:15 PM, said:

All of these look AWESOME! I will most definitely be trying this later. These will definitely make a lot of things easier.

Also, would you be okay with me possibly implementing some of this INTO my code so that people don't have to download your APIs as well, provided I give you full credit for your work on the post and in the program? This is all theoretical right now, but please shoot me a PM and lemme know what you think.
You can!

#13 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 17 May 2012 - 06:43 PM

lol finnaly a batch inturpreter!, here i made yo a logo :3

Posted Image
EDIT: fixed lighting



#14 jojoxd

  • New Members
  • 2 posts

Posted 21 March 2013 - 12:06 PM

links are down :(

#15 zekesonxx

  • Signature Abuser
  • 263 posts
  • LocationWhere you aren't

Posted 21 March 2013 - 12:16 PM

Mad you screwed up Gitting something and deleted the repo. It needs to be fixed.

#16 Mads

  • Members
  • 604 posts
  • LocationCopenhagen, Denmark

Posted 21 March 2013 - 08:07 PM

I made this repo in March 2012. It's all gone now :(

#17 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 02 July 2013 - 03:14 AM

Can you fix it? Maybe put it on Pastebin instead of Github?

#18 viluon

  • Members
  • 183 posts
  • LocationCzech Republic

Posted 10 April 2014 - 08:21 AM

http://pastebin.com/6WYHCeeu
here ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users