Posted 02 April 2013 - 04:13 AM
The mind.API is here!
This api was developed by myself (IGN: mindfulhacker) with the help of the following people:
- TheOriginalBit
- SuicidalSTDz
Download With The Following Code:
pastebin get YjCcWu5h mind
Here is the code:
--[[
This is the mind.api
Created by Mindfulhacker (appleeater)
Table Of Contents
-----------------
1. Commands
2. Tributes
Commands:
1. mind.DeadLock() - Deadlocks The PC disabling CTRL+T.
2. mind.unDeadLock() - Disables mind.DeadLock() , Enabling CTRL+T.
3. mind.getRSinputs() - Gets all of the available sides and puts them into a table.
3. mind.printRSinputs() - Prints the status of the inputs from mind.getRSinputs().
4. mind.Lock(password) - Locks the terminal, disabling CTRL+T. Replace password with your desired password.
5. mind.doorLock(side, password) - Locks a door. Replace side with the side your output is. Replace password with your desired password.
6. mind.getModems() - Gets all of the available modems. Places them in a table.
7. mind.openAllModems() - Opens all of the available modems found from mind.getModems()
8. mind.broadcastModems(message) - Broadcasts a message on all open modems. Use mind.openAllModems() first. Replace message with your desired meaage.
9. mind.sendModems(id, message) - Sends a message to a computer using any open modems using mind.openAllModems.
Replace ID with the desired computer ID. Replace message with desired message.
10. mind.reciveModem(timeout) - Recives a message from computers sending messages. Replace timeout with the time to wait before quiting.
Tributes:
The following people have helped me with creating this API:
TheOriginalBit
SuicidalSTDz
]]--
print("This is a API! Load it using:")
print("os.loadApi(mind)")
local RSinputs = {}
local oldpull = os.pullEvent
local m = {}
function DeadLock() --Deadlocks the console disabling CTRL+T Syntax: mind.DeadLock()
os.pullEvent = os.pullEventRaw
end
function unDeadLock() --Resets the os.pullEvent back to its original state Syntax: mind.unDeadLock()
os.pullEvent = oldpull
end
function getRSinputs() --Gets all of the availale sides Syntax: mind.getRSinputs()
for _,side in pairs(rs.getSides()) do
RSinputs[side] = rs.getInput(side)
end
end
function printRSinputs() --Prints redstone inputs from getRSinputs Syntax: mind.getRSinputs()
for side, active in pairs(RSinputs) do
write('The '..side..' redstone input is '..(active and 'on' or 'off'))
end
end
function Lock( password ) --locks the terminal Syntax: mind.lock(password)
DeadLock()
while true do
term.clear()
print("This Terminal Has Been Locked!")
print("Enter Your Password: ")
if read("*") == password then
print("Succsessfully Authenticated!")
unDeadLock()
break
else
print("Password Invalid!")
print("Authentication Failed!")
term.clear()
end
end
end
function doorLock( side, password ) -- Locks doors Syntax: mind.doorLock(side, password)
Deadlock()
term.clear()
print("Enter Your Password:")
if read("*") == password then
rs.setOutput( side.. , true)
sleep(3)
rs.setOutput(side.., false)
unDeadLock()
term.clear()
else
print("Password Authentication Failed!")
term.clear()
end
end
function getModems()
local m = {}
for _, side in pairs(rs.getSides()) do
if peripheral.getType( side ) == 'modem' then
table.insert( m, side )
end
end
return m
end
function openAllModems()
for _, side in pairs( getModems() ) do
rednet.open( side )
end
end
function broadcastModems( message )
for _, side in pairs( getModems() ) do
rednet.broadcast( message )
end
end
function sendModems( id, message, status )
for _, side in pairs( getModems() ) do
rednet.send( id, message, status )
end
end
function reciveModem( timeout )
local senderId, message, distance = rednet.receive( timeout )
term.write(message)
end