Efficient API

I wrote a simple API with some commands that could save you some writing.

I wrote it with my basic ComputerCraft skills.


What can it do?

It is mostly rednet functions, but also has some other basic things like

[center]function clear()
[center]term.clear()
[center]term.setCursorPos(1, 1)


Term functions
SpoilerThe clear function
eAPI.clear()
Clears the screen and sets the cursor position to 1, 1

No extra arguments needed

Password functions
SpoilerThe password function
eAPI.password(password, pullEvent)
creates a message and requires password to be entered.

password = the password you want to use, must be a string
pullEvent = wether you can use ctrl+t or not, must be a boolean
for example, eAPI.password("test", true)

The password door function
eAPI.passDoor(password, side, time, pullEvent)
Creates a message and requires password to open door

password= the password you want to use, must be a string
side= the side you want your redstone output to be, must be a string
time= how long you want the redstone signal to emit, must be a number
pullEvent= wether you can use ctrl+t or not, must be a boolean
for example, eAPI.passDoor("test", "right", 5, true)


Rednet functions
SpoilerThe detect modem function
eAPI.detectModem()
Detects all the modems that are attached to the computer

No extra arguments needed

The rednet display message function
eAPI.rednetChat(timeout)
Displays the message received and the sender it came from

timeout= the amount of time till the timeout, must be a number
for example, eAPI.rednetChat(5)
If no message received before timeout it will print: No message received

The rednet receive message function
eAPI.rednetReceive(timeout)
Receives the message and stores it in the variable message. Also stores the sender in the variable sender.

timeout= the amount of time till the timeout, must be a number
for example, eAPI.rednetReceive(5)
If no message received before timeout it will print: No message received

The file transmit function
eAPI.redSendFile(file)
Sends file to other computer using the broadcast function

file= name of the file, must be a string
for example, eAPI.redSendFile("test")

The file receive function
eAPI.redRecFile(timeout)
Receives the file send from another computer

timeout= the amount of time till the timeout, must be a number
for example, eAPI.redRecFile(timeout)
P.s you dont have to fill in a timeout. it is optional

Save and load functions
SpoilerThe variable save function
eAPI.save(var, name)
Saves a variable to the computer

var= Name of the variable, must be a variable
name= Name of the savefile, must be a string
for example, eAPI.save(input, "saveinput")

The variable load function
eAPI.load(var, name)
loads a variable from a file

var= what you want to call the variable, must be a variable
name= name of the savefile, must be a string
for example, eAPI.load("saveinput", output)

The table save function
eAPI.saveTable(table, name)
Saves a table to the computer

table= name of the table, must be a variable
name= name of the savefile, must be a string
for example, eAPI.saveTable(users, "db")

The table load function
eAPI.loadTable(table, name)
Loads a table from a file

table= what you want to call the table, must be a variable
name= name of the savefile, must be a string
for example, eAPI.loadTable(users, "db")




To install this API, simply run

 pastebin get nays2WZJ eAPI 

and load it into the file you want to use it with

 os.loadAPI("eAPI")