Posted 24 November 2012 - 08:51 AM
Multinet
Lets cut to the chase, functions:
Now here are the server functions:
variables:
Now here are the user functions:
variables:
Download:
Example:
Lets cut to the chase, functions:
Spoiler
createServer(name, id)
-creates and returns a server with that name using that computer id (just use os.computerID())
createUser(user_name, server_name, user_id, server_id)
-creates and returns a user for that server (along with id) using that username and that user_id (just use of.computerID())
getServers()
-returns a list of all multinet servers in format: [servername] = id
Now here are the server functions:
Spoiler
server:getPlayerList()
-returns a normal table (1 to length) containing all player names
server:sendPlayerList(playername)
-sends the playerlist to that user
server:getUsers()
-returns a table containing [playername] = id
server:removePlayer(playername)
-removes a player from the server's playerlist
server:addPlayer(playername, playerid, data)
-adds a player with that playername, playerid and data (data is a table)
server:removePlayer(playername)
-removes a player with that playername
server:addSData(name, info)
-adds some data to the server ([name] = info)
server:getSData()
-returns the server data formated.
server:getPlayer(id)
-returns the playername matching that id
server:getID(player)
-returns the id matching that playername
server:setData(player, data)
-sets the players data to that data (is a table)
server:getData(player, data)
-returns the players data unformated.
server:pingUsers(info)
-sends that string (info) to all of the users
server:waitForCommand()
-waits until it receives a command over rednet, returns the type of command
-Types:
nil = an error happened, this shouldn't happen
"INVALID" = invalid command or command went wrong
1 = player joined
2 = player leaved
3 = sent user data to user
4 = sent player list to user
5 = sent the name of the server
6 = sent server data to player
7 = user set server data
8 = user set user data, 11 if failed
variables:
server.name
-the servers name
server.id
-the servers id
server.users
-the servers user ([playername] = id)
server.data
-the servers data (any)
Now here are the user functions:
Spoiler
user:joinServer()
-joins the server
user:leaveServer()
-leaves the server
user:getPlayerList()
-returns the playerlist
user:getData()
-returns the user's data
user:setData()
-sets the user's data
user:getSData()
-returns the server's data
user:setSData(name, piece)
-sets that server data
user:waitForPing()
-waits for a rednet message, returns message if it was from the server or nil if it wasn't
user:isFromServer(id)
-returns true if id matches the server's id, false if it doesn't
variables:
user.name
-returns the user's name
user.id
-returns the user's id
user.server_name
-returns the server's name
user.server_id
-returns the server's id
Download:
Spoiler
http://pastebin.com/WGCM34TPExample: