Posted 15 February 2012 - 12:27 AM
The API can send and receive messages via a php script on the web.
New features:
com.send(receiverid, message) where the receiver id is the computers id.
com.number() this wil get the number of messages waiting, if none it returns 0 (only the ones sent to this id) (returns int)
com.get() this will get a single message (returns string)
com.announce(channel) call this method with a channel string such as "channel1" and this computer will be added to the mailing list for "channel1"
com.hide(channel) used as above but to remove from a channel
com.onchannels() returns the channels that the computer is registered to
com.broadcast(channel, message) used to broadcast a message channel being something like "channel1" then just a message string
Usage for tUtil:
tUtil.replaceAll(text, bytefind, bytereplace)
tUtil.toBinary(byte)
tUtil.toHex(byte)
tUtil.urlencode(input)
Installation instructions:
Webserver
(1)Copy the contents of web to a server accessible to your minecraft client (ssp) or server (smp)
(2) Make sure that the directory is writable.
Extra: (All configurations at the top of webmessage.php)
Change databases directory
(3) In the web script replace $prefix = ""; with something like $prefix = "db/"; to place them into the folder db
(4) Make sure this directory is writable
Enable multi-server
(5) Change $multiserver = false; to $multiserver = true;
(6) Perform client config (below)
Enable password
(7) Change $password = ""; to $password = "yourpasswordhere";
(8) Perform client config (below)
Minecraft
(1)Place the contents of the api folder in mods/ComputerCraft/lua/rom/apis
(2)Edit the first configurable option in com to point to your webmessage.php
Enable multi-server
(3) Uncomment the local server = "server1" line in com
(4) Change server1 to anything that is only alphanumeric
Enable password
(5) Uncomment the local password = "pass1" line
(6) Change pass1 to your alphanumeric password
Using my server:
I have setup a webmessage.php script
These are the config options the client needs.
local url = "http://users.aber.ac.uk/tis4/computercraft/index.php"
local server = "server1"
Replace server1 with any alphanumeric string.
Notes:
Encryption
Passworded script (web)
Broadcast
Examples:
Receive all
Using StrUtil for encrypted messages:
Send an encrypted message to ID13
Files are attached but alternative download here: http://users.aber.ac.../webmessage.zip
New features:
- Uses URL encoding (0.21)
- Added tUtil api (0.21)
- Broadcast system using channels (0.2)
- Web script now supports multiple databases/servers (0.2)
- Web script now supports password (0.2)
com.send(receiverid, message) where the receiver id is the computers id.
com.number() this wil get the number of messages waiting, if none it returns 0 (only the ones sent to this id) (returns int)
com.get() this will get a single message (returns string)
com.announce(channel) call this method with a channel string such as "channel1" and this computer will be added to the mailing list for "channel1"
com.hide(channel) used as above but to remove from a channel
com.onchannels() returns the channels that the computer is registered to
com.broadcast(channel, message) used to broadcast a message channel being something like "channel1" then just a message string
Usage for tUtil:
tUtil.replaceAll(text, bytefind, bytereplace)
tUtil.toBinary(byte)
tUtil.toHex(byte)
tUtil.urlencode(input)
Installation instructions:
Webserver
(1)Copy the contents of web to a server accessible to your minecraft client (ssp) or server (smp)
(2) Make sure that the directory is writable.
Extra: (All configurations at the top of webmessage.php)
Change databases directory
(3) In the web script replace $prefix = ""; with something like $prefix = "db/"; to place them into the folder db
(4) Make sure this directory is writable
Enable multi-server
(5) Change $multiserver = false; to $multiserver = true;
(6) Perform client config (below)
Enable password
(7) Change $password = ""; to $password = "yourpasswordhere";
(8) Perform client config (below)
Minecraft
(1)Place the contents of the api folder in mods/ComputerCraft/lua/rom/apis
(2)Edit the first configurable option in com to point to your webmessage.php
Enable multi-server
(3) Uncomment the local server = "server1" line in com
(4) Change server1 to anything that is only alphanumeric
Enable password
(5) Uncomment the local password = "pass1" line
(6) Change pass1 to your alphanumeric password
Using my server:
I have setup a webmessage.php script
These are the config options the client needs.
local url = "http://users.aber.ac.uk/tis4/computercraft/index.php"
local server = "server1"
Replace server1 with any alphanumeric string.
Notes:
- The included PHP script creates an sqlite database, so your webserver will need to support that.
- This is obviously not very secure as this application doesn't really require it (who wants to hack your in-game computers?)
- Feel free to improve and redistribute
- Remember I'm new to LUA
Examples:
Receive all
if com.number()>0 then
while com.number()>0 do
print(com.get())
end
else
print("no messages")
end
Send "hello there" to computer with id 13
message="hello there"
print(com.send("13", message))
Add to channel mailing list "channel1"
com.announce("channel1")
Remove from channel "channel1"
com.hide("channel1")
Broadcast to all announced computers in a channel "channel1"
message="hello channel1"
com.broadcast("channel1", message)
Check which channels you're in
print(com.onchannels())
Using StrUtil for encrypted messages:
Send an encrypted message to ID13
key="1234"
message="secret hello"
message=StrUtil.encrypt(message, key)
com.send("13", message)
Receive an encrypted message
key="1234"
message=com.get()
message=StrUtil.decrypt(message, key)
print(message)
Files are attached but alternative download here: http://users.aber.ac.../webmessage.zip