Posted 22 June 2014 - 11:40 AM
I was giving out free programs lately to some friends and I was suprised when most of them wanted data servers for something like a bank or a mail system, and I really didn't want to type 16,000 If's and Elseif's, so I coded this simple API for ease of use when making advanced rednet systems!
Functions :
– redtools.waitForMsg(sMessage, nTimeout, nSender) –
If "sMessage" is received from "nSender (optional) " in "nTimeout" seconds, I will return true, if not, then return false.
Example :
– redtools.autoReply(sReply, nSender( optional )) –
If a message is received from "nSender" then reply with "sReply."
Example:
1: Hi
0: Hello
– redtools.forward(sMessage, nSender, sReply, nReplyID) –
If "sMessage" is received from "nSender", then tell "nReplyID": "sReply."
– redtools.waitForReply(sMessage, nID) –
Tell "nID" "sMessage" and wait for "nID" to respond then return reply from "nID."
How to install :
1. Type "pastebin get EX2knsd5 redtools"
2. Run "redtools"
3. Use the API as much as you like!
I hope you enjoy my API, and all suggestions and feedback are welcome!
Functions :
– redtools.waitForMsg(sMessage, nTimeout, nSender) –
If "sMessage" is received from "nSender (optional) " in "nTimeout" seconds, I will return true, if not, then return false.
Example :
--===Client===--
rednet.send(0, "LagTest")
--===Server===---
a = redtools.waitForMsg("LagTest", 3, nil) -- nil = No Exact ID
if a then
print("No Lag")
else
print("Lag")
end
– redtools.autoReply(sReply, nSender( optional )) –
If a message is received from "nSender" then reply with "sReply."
Example:
--===Client===--
rednet.send(0, "Hi")
id, msg = rednet.receive()
print(id.." replied : "..msg)
--===Server===--
redtools.autoReply("Hello", 1)
Output :1: Hi
0: Hello
– redtools.forward(sMessage, nSender, sReply, nReplyID) –
If "sMessage" is received from "nSender", then tell "nReplyID": "sReply."
– redtools.waitForReply(sMessage, nID) –
Tell "nID" "sMessage" and wait for "nID" to respond then return reply from "nID."
How to install :
1. Type "pastebin get EX2knsd5 redtools"
2. Run "redtools"
3. Use the API as much as you like!
I hope you enjoy my API, and all suggestions and feedback are welcome!