Steamworks for Lua/FFI

This is a cross-platform LuaJIT/FFI wrapper for Steamworks v1.51. The library provides easy and simple Steamworks integration, using the original redistributable binaries provided by Valve.
https://bitbucket.org/itraykov/sworks-ffi

steam

This is the main module used to interact with Steamworks.
steam.activateOverlay(page, user)Opens the Steam overlay if available to a specific dialog or page.
steam.getAchievements()Retrives all available achievements for the current game.
steam.getAppId()Gets the current game's AppID.
steam.getBoard(name, func)Requests an existing leaderboard based on name. This is an asynchronous request so the returned Board object cannot be used right away. Please provide a callback function or wait for Board:onFind before making additional requests.
steam.getClan(id)Finds a specific clan based on ID.
steam.getClans()Retrieves clans which the owner has previously joined.
steam.getCountry()Gets the owner's geographic location based on IP.
steam.getFriends()Retrieves the owner's friends.
steam.getLanguage()Gets the selected language code for the current game or the client.
steam.getLobby(id)Retrieves an existing lobby based on ID.
steam.getPlayedWith()Retrieves other users the owner has recently played with.
steam.getSocket(channel, kind)Creates or requests an existing socket via its channel number.
steam.getSubscribedUGC(offset1, offset2)Retrives all subscribed user-generated items.
steam.getUGC(id, appid)Finds an existing user-generated content item based on ID.
steam.getUser(id)Finds a specific user based on ID. Returns the owner if no id is specified.
steam.init()Initializes the Steam client interface. This function will fail if the Steam client is not running or you don't have a valid AppID. Your AppID must be saved as "steam_appid.txt" and placed in your base directory. You will also need to include the correct version of the Steamworks binaries provided by Valve.
steam.isBigPicture()Checks if the client is running in "Big Picture" mode.
steam.isConnected()Checks if the owner is connected to Steam.
steam.isRunning()Checks if your Steam client is initialized and running.
steam.newBoard(name, sort, display, func)Creates or requests an existing leaderboard based on name. This is an asynchronous request so the returned Board object cannot be used right away. Please provide a callback function or wait for Board:onCreate before making additional requests.
steam.newLobby(kind, limit, func)Creates a new lobby. This is an asynchronous request so the returned Lobby object cannot be used right away. Please provide a callback function or wait for Lobby:onCreate before making additional requests.
steam.newUGC(kind, appid, func)Creates a new user-generated content item. This is an asynchronous request so the returned UGC object cannot be used right away. Please provide a callback function or wait for UGC:onCreate before making additional requests.
steam.queryLobbies(what, limit, func)Searches for existing lobbies for the current game. This is an asynchronous request so please provide a callback function to receive the results.
steam.queryUGC(what, offset1, offset2, func, list)Searches for user-generated content by a specific user or by filter. This is an asynchronous request so please provide a callback function to receive the results.
steam.request(url, post, func)Makes a new HTTP or HTTPS request. This is an asynchronous request so please provide a callback function to receive the results.
steam.restart(appid)Checks if your executable was launched through Steam. Returns true and re-launches your game through Steam if it was not. Returns false when "steam_appid.txt" is present.
steam.setNotificationPosition(string, number, number)Sets the position and offset of the notification pop-up.
steam.shutdown()Shuts down the Steam client interface.
steam.update()This function triggers any asynchronous callbacks. You must call steam.update regularly to ensure that your requests are processed.

steam.activateOverlay(page, user)

Opens the Steam overlay if available to a specific dialog or page.
stringpage ("friends")
Dialog, AppID or URL address. Possible dialog values: "friends", "community", "players", "settings", "officialgamegroup", "stats" or "achievements"
Useruser (optional)
User object

steam.getAchievements()

Retrives all available achievements for the current game.
Returns
table Table of achievement names

steam.getAppId()

Gets the current game's AppID.
Returns
number AppID of the current game

steam.getBoard(name, func)

Requests an existing leaderboard based on name. This is an asynchronous request so the returned Board object cannot be used right away. Please provide a callback function or wait for Board:onFind before making additional requests.
stringname
Name of an existing leaderboard
functionfunc (optional)
Callback function triggered when the board is found
Returns
Board Board object

steam.getClan(id)

Finds a specific clan based on ID.
valueid
Clan ID
Returns
Clan Clan object

steam.getClans()

Retrieves clans which the owner has previously joined.
Returns
table Table of Clan objects

steam.getCountry()

Gets the owner's geographic location based on IP.
Returns
string Country code

steam.getFriends()

Retrieves the owner's friends.
Returns
table Table of User objects

steam.getLanguage()

Gets the selected language code for the current game or the client.
Returns
string Language code

steam.getLobby(id)

Retrieves an existing lobby based on ID.
stringid
ID of an existing lobby
Returns
Lobby Lobby object

steam.getPlayedWith()

Retrieves other users the owner has recently played with.
Returns
table Table of User objects

steam.getSocket(channel, kind)

Creates or requests an existing socket via its channel number.
numberchannel (0)
Channel number
stringkind ("unreliable")
Kind of socket: "unreliable", "nodelay", "reliable" or "buffered"
Returns
Socket Socket object

steam.getSubscribedUGC(offset1, offset2)

Retrives all subscribed user-generated items.
numberoffset1
Starting offset used for pagination
numberoffset2
Ending offset used for pagination
Returns
table Table of UGC objects

steam.getUGC(id, appid)

Finds an existing user-generated content item based on ID.
stringid
ID of an existing user-generated item
valueappid (optional)
AppID if different from the base game
Returns
UGC User-generated item

steam.getUser(id)

Finds a specific user based on ID. Returns the owner if no id is specified.
stringid (optional)
User ID in decimal format
Returns
User User object

steam.init()

Initializes the Steam client interface. This function will fail if the Steam client is not running or you don't have a valid AppID. Your AppID must be saved as "steam_appid.txt" and placed in your base directory. You will also need to include the correct version of the Steamworks binaries provided by Valve.
Returns
boolean True if the interface is initialized

steam.isBigPicture()

Checks if the client is running in "Big Picture" mode.
Returns
boolean True if "Big Picture" mode is enabled

steam.isConnected()

Checks if the owner is connected to Steam.
Returns
boolean True if connected or false when offline

steam.isRunning()

Checks if your Steam client is initialized and running.
Returns
boolean True if already running

steam.newBoard(name, sort, display, func)

Creates or requests an existing leaderboard based on name. This is an asynchronous request so the returned Board object cannot be used right away. Please provide a callback function or wait for Board:onCreate before making additional requests.
stringname
Leaderboard name
stringsort ("desc")
Sorting method: "asc" or "desc"
stringdisplay ("numeric")
Display style: "none", "numeric", "seconds" or "milliseconds"
functionfunc (optional)
Callback function triggered when the board is created
Returns
Board Board object

steam.newLobby(kind, limit, func)

Creates a new lobby. This is an asynchronous request so the returned Lobby object cannot be used right away. Please provide a callback function or wait for Lobby:onCreate before making additional requests.
stringkind (public)
Kind of lobby: "private", "friends", "public" or "invisible"
numberlimit (250)
Maximum number of users allowed to join the lobby.
functionfunc (optional)
Callback function triggered when the lobby is created

steam.newUGC(kind, appid, func)

Creates a new user-generated content item. This is an asynchronous request so the returned UGC object cannot be used right away. Please provide a callback function or wait for UGC:onCreate before making additional requests.
stringkind ("community")
Type of object: "community", "micro", "collection", "art", "video", "screenshot", "game", "software", "concept", "webguide", "guide", "merch", "binding", "accessinvite", "steamvideo" or "managed".
valueappid (optional)
AppID if different from the base game
functionfunc (optional)
Callback function triggered when the item is created
Returns
UGC User-generated item

steam.queryLobbies(what, limit, func)

Searches for existing lobbies for the current game. This is an asynchronous request so please provide a callback function to receive the results.
tablewhat (optional)
Table with numerical or string filters
numberlimit (optional)
Maximum number of results
functionfunc
Callback function triggered when the search results are ready

steam.queryUGC(what, offset1, offset2, func, list)

Searches for user-generated content by a specific user or by filter. This is an asynchronous request so please provide a callback function to receive the results.
valuewhat
User object or filter: "popular", "recent", "friends" or "unrated"
numberoffset1
Starting offset used for pagination
numberoffset2
Ending offset used for pagination
functionfunc
Callback function triggered when the search results are ready
tablelist (optional)
Table of UGC objects

steam.request(url, post, func)

Makes a new HTTP or HTTPS request. This is an asynchronous request so please provide a callback function to receive the results.
stringurl
URL address
stringpost (optional)
Raw post body
functionfunc
Callback function triggered once the request if completed
Returns
boolean True if the request parameters are valid

steam.restart(appid)

Checks if your executable was launched through Steam. Returns true and re-launches your game through Steam if it was not. Returns false when "steam_appid.txt" is present.
valueappid (optional)
AppID
Returns
boolean True if restarting the game is necessary

steam.setNotificationPosition(string, number, number)

Sets the position and offset of the notification pop-up.
valuestring
pos Target corner: "topleft", "topright", "bottomleft" or "bottomright"
valuenumber (optional)
ox Inset from the corner
valuenumber (optional)
oy Inset from the corner

steam.shutdown()

Shuts down the Steam client interface.

steam.update()

This function triggers any asynchronous callbacks. You must call steam.update regularly to ensure that your requests are processed.


Handle

Base class for all Steamworks objects.
Handle:callback(func, result, ...)This is an internal function.
Handle:destroy()This is an internal function.
Handle:getId()Returns the unique Steam ID as a string.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.

Handle:callback(func, result, ...)

This is an internal function.
valuefunc
Name or function
numberresult
Result status
value...
Variable arguments

Handle:destroy()

This is an internal function.

Handle:getId()

Returns the unique Steam ID as a string.
Returns
string Steam ID

Handle:new()

This is an internal function.

Handle:onError(message)

This callback is triggered when any requests fails.
stringmessage
Error message

Handle:setId(handle)

This is an internal function.
valuehandle
Steam ID



Board

Steam supports persistent leaderboards with automatically ordered entries. These leaderboards can be used to display global and friend leaderboards in your game and on your community webpage. Each Steamworks title can create up to 10,000 leaderboards, and each leaderboard can be retrieved immediately after a player's score has been inserted. For each leaderboard, a player can have one entry. There is no limit on the number of players per leaderboard.
Handle
Handle:callback(func, result, ...)This is an internal function.
Handle:getId()Returns the unique Steam ID as a string.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.
Board
Board:attach(ugc, func)Attaches an existing user-generated item (such as a replay) to the owner's leaderboard entry. This is an asynchronous request that triggers the Board:onAttach callback.
Board:create(name, sort, display, func)This is an internal function. Please use steam.newBoard instead.
Board:destroy()Invalidates the board so that any subsequent requests will fail.
Board:download(what, index1, index2, func)Downloads entries from the loaderboard based on a filter or for a specific user. This is an asynchronous request that triggers the Board:onDownload callback.
Board:getEntryCount()Returns the total number of entries in the leaderboard.
Board:getName()Returns the name of the board.
Board:init(name, func)This is an internal function. Please use steam.getBoard instead.
Board:onAttach(ugc)Callback triggered after a user-generated item is attached to the leaderboard.
Board:onCreate()Callback triggered after the new leaderboard is created.
Board:onDownload(entries, count)Callback triggered after entries are downloaded from the leaderboard.
Board:onFind()Callback triggered after the requested leaderboard is found.
Board:onUpload(changed)Callback triggered after a score is uploaded to the leaderboard.
Board:upload(score, method, func)Uploads a new entry on the leaderboard. Uploading scores to Steam is rate limited to 10 uploads per 10 minutes and you may only have one outstanding call to this function at a time. This is an asynchronous request that triggers the Board:onUpload callback.

Board:attach(ugc, func)

Attaches an existing user-generated item (such as a replay) to the owner's leaderboard entry. This is an asynchronous request that triggers the Board:onAttach callback.
UGCugc
User-generated item
functionfunc
Callback function triggered when the UGC is attached

Board:create(name, sort, display, func)

This is an internal function. Please use steam.newBoard instead.
stringname
Leaderboard name
stringsort ("desc")
Sorting method: "asc" or "desc"
stringdisplay ("numeric")
Display style: "none", "numeric", "seconds" or "milliseconds"
functionfunc (optional)
Callback function triggered when the board is created

Board:destroy()

Invalidates the board so that any subsequent requests will fail.

Board:download(what, index1, index2, func)

Downloads entries from the loaderboard based on a filter or for a specific user. This is an asynchronous request that triggers the Board:onDownload callback.
valuewhat ("global")
User object or filter: "global", "user" or "friends"
numberindex1 (1)
Starting offset used for pagination
numberindex2 (optional)
Ending offset used for pagination
functionfunc (optional)
Callback function triggered when the entries are downloaded

Board:getEntryCount()

Returns the total number of entries in the leaderboard.
Returns
number Number of entries

Board:getName()

Returns the name of the board.
Returns
string Board name

Board:init(name, func)

This is an internal function. Please use steam.getBoard instead.
stringname
Name of an existing leaderboard
functionfunc (optional)
Callback function triggered when the board is found

Board:onAttach(ugc)

Callback triggered after a user-generated item is attached to the leaderboard.
UGCugc
User-generated item

Board:onCreate()

Callback triggered after the new leaderboard is created.

Board:onDownload(entries, count)

Callback triggered after entries are downloaded from the leaderboard.
tableentries
Table of leaderboard entries
numbercount
Total number of entries

Board:onFind()

Callback triggered after the requested leaderboard is found.

Board:onUpload(changed)

Callback triggered after a score is uploaded to the leaderboard.
booleanchanged
True if the the leaderboard has changed

Board:upload(score, method, func)

Uploads a new entry on the leaderboard. Uploading scores to Steam is rate limited to 10 uploads per 10 minutes and you may only have one outstanding call to this function at a time. This is an asynchronous request that triggers the Board:onUpload callback.
numberscore
Score to upload
stringmethod ("best")
The upload method determines if we want to keep the best scores or the latest. Possible values: "none", "best" or "latest"
functionfunc (optional)
Callback function triggered when the entry is uploaded



Clan

Clans are basically Steam groups.
Handle
Handle:callback(func, result, ...)This is an internal function.
Handle:destroy()This is an internal function.
Handle:getId()Returns the unique Steam ID as a string.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.
Clan
Clan:getActivity()Gets the most recent information we have about what the users in a Steam Group are doing.
Clan:getChatMembers()Returns a list of all of the members present in the Steam group chat.
Clan:getChatMessage(index)Gets message from the Steam group chat room. Chat messages are indexed by number.
Clan:getChatMessageCount()Gets the total number of messages in the Steam group chat room.
Clan:getName()Gets the display name for the specified Steam group; if the local client knows about it.
Clan:getOfficers()Gets a list of the officers of the Steam group.
Clan:getOwner()Gets the owner of a Steam Group.
Clan:init(id)This is an internal function. Please use steam.getClan instead.
Clan:isOfficial()Checks if the Steam group is an official game group/community hub.
Clan:isPublic()Checks if the Steam group is public.
Clan:joinChat(func)Allows the user to join Steam group (clan) chats right within the game. The behavior is somewhat complicated, because the user may or may not be already in the group chat from outside the game or in the overlay. You can activate the Steam client overlay to open the in-game version of the chat. This is an asynchronous request so please use Clan:onJoinChat or provide a callback function to receive the results.
Clan:leaveChat()Leaves a Steam group chat that the user has previously entered with Clan:joinChat.
Clan:onJoinChat()Callback triggered after joining the chat.
Clan:onReceiveActivity()Callback triggered when the activity stats are downloaded.
Clan:onReceiveOfficers()Callback triggered when the list of officers is downloaded.
Clan:requestActivity(func)Refresh the Steam Group activity data or get the data from groups other than one that the current user is a member. This is an asynchronous request so please use Clan:onReceiveActivity or provide a callback function to receive the results.
Clan:requestOfficers(func)Requests information about Steam group officers (administrators and moderators). You can only ask about Steam groups that a user is a member of. This will NOT download avatars for the officers automatically. This is an asynchronous request so please use Clan:onReceiveOfficers or provide a callback function to receive the results.
Clan:sendChatMessage(msg)Sends a chat message to the Steam group chat room.

Clan:getActivity()

Gets the most recent information we have about what the users in a Steam Group are doing.
Returns
number Number of members that are online
number Number of members that are online and in-game
number Number of members in the group chat room

Clan:getChatMembers()

Returns a list of all of the members present in the Steam group chat.
Returns
table Table of User objects

Clan:getChatMessage(index)

Gets message from the Steam group chat room. Chat messages are indexed by number.
numberindex
Chat message index
Returns
string String message
User Message author

Clan:getChatMessageCount()

Gets the total number of messages in the Steam group chat room.
Returns
number Number of messages

Clan:getName()

Gets the display name for the specified Steam group; if the local client knows about it.
Returns
string Group name

Clan:getOfficers()

Gets a list of the officers of the Steam group.
Returns
table Table of User objects

Clan:getOwner()

Gets the owner of a Steam Group.
Returns
User The user who owns the group

Clan:init(id)

This is an internal function. Please use steam.getClan instead.
stringid
Clan ID

Clan:isOfficial()

Checks if the Steam group is an official game group/community hub.
Returns
boolean True if the group is official

Clan:isPublic()

Checks if the Steam group is public.
Returns
boolean True if the group is public

Clan:joinChat(func)

Allows the user to join Steam group (clan) chats right within the game. The behavior is somewhat complicated, because the user may or may not be already in the group chat from outside the game or in the overlay. You can activate the Steam client overlay to open the in-game version of the chat. This is an asynchronous request so please use Clan:onJoinChat or provide a callback function to receive the results.
functionfunc
Callback function triggered after joining the chat

Clan:leaveChat()

Leaves a Steam group chat that the user has previously entered with Clan:joinChat.
Returns
boolean True if successful

Clan:onJoinChat()

Callback triggered after joining the chat.

Clan:onReceiveActivity()

Callback triggered when the activity stats are downloaded.

Clan:onReceiveOfficers()

Callback triggered when the list of officers is downloaded.

Clan:requestActivity(func)

Refresh the Steam Group activity data or get the data from groups other than one that the current user is a member. This is an asynchronous request so please use Clan:onReceiveActivity or provide a callback function to receive the results.
functionfunc
Callback function triggered when the activity stats are downloaded

Clan:requestOfficers(func)

Requests information about Steam group officers (administrators and moderators). You can only ask about Steam groups that a user is a member of. This will NOT download avatars for the officers automatically. This is an asynchronous request so please use Clan:onReceiveOfficers or provide a callback function to receive the results.
functionfunc
Callback function triggered when the list of officers is downloaded

Clan:sendChatMessage(msg)

Sends a chat message to the Steam group chat room.
stringmsg
Message
Returns
boolean True if the message was successfully sent



Lobby

The lobby is an entity that lives on the Steam back-end servers that is a lot like a chat room. Users can create a new lobby; associate data with a lobby; search for lobbies based on that data; join lobbies; and share information with other users in the lobby. A single lobby can have up to 250 users in it, although typically most games have at most 2-16 players. Skill-based matchmaking is built on top of this system.
Handle
Handle:callback(func, result, ...)This is an internal function.
Handle:destroy()This is an internal function.
Handle:getId()Returns the unique Steam ID as a string.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.
Lobby
Lobby:create(kind, limit, func)This is an internal function. Please use steam.newLobby instead.
Lobby:deleteData(key)Removes lobby metadata.
Lobby:getChatMessage(index)Gets message from the lobby chat room. Chat messages are indexed by number.
Lobby:getChatMessageCount()Gets the total number of messages in the lobby chat room.
Lobby:getData(key, user)Get lobby metadata.
Lobby:getLimit()Get the current limit on the number of users who can join the lobby.
Lobby:getMembers()Returns a list of members who have joined the lobby. The current user must be in the lobby to retrieve the Steam IDs of other users in that lobby.
Lobby:getOwner()Returns the lobby owner
Lobby:init(id)This is an internal function. Please use steam.getLobby instead.
Lobby:invite(friend)Invite another user to the lobby. Shows a list of friends if no specific user is provided.
Lobby:join(func)Joins an existing lobby. This is an asynchronous request so please use Lobby:onJoin or provide a callback function.
Lobby:leave()Leave a lobby that the user is currently in; this will take effect immediately on the client side.
Lobby:onCreate()Callback triggered after creating a new lobby.
Lobby:onJoin()Callback triggered after joining a lobby.
Lobby:requestData()Refreshes all of the metadata for a lobby that you're not in right now. You will never do this for lobbies you're a member of, that data will always be up to date. You can use this to refresh lobbies that you have obtained from RequestLobbyList or that are available via friends.
Lobby:sendChatMessage(msg)Sends a chat message to the lobby chat room.
Lobby:setData(key, value)Set lobby metadata.
Lobby:setJoinable(joinable)Sets whether or not a lobby is joinable by other players. This always defaults to enabled for a new lobby. If joining is disabled, then no players can join, even if they are a friend or have been invited. Lobbies with joining disabled will not be returned from a lobby search.
Lobby:setLimit(Number)Set the maximum number of players that can join the lobby.
Lobby:setOwner(owner)Changes the lobby owner. This can only be set by the owner of the lobby.
Lobby:setType(kind)Updates the lobby type. "private" means that the only way to join the lobby is from an invite. "friends" means that the lobby is joinable by friends and invitees. "public" means that the lobby will show in search. "invisible" means that the lobby will show in search, but is not visible to other friends. This is useful if you want a user in two lobbies, for example matching groups together. A user can be in only one regular lobby, and up to two invisible lobbies.

Lobby:create(kind, limit, func)

This is an internal function. Please use steam.newLobby instead.
stringkind (public)
Kind of lobby: "private", "friends", "public" or "invisible"
numberlimit (250)
Maximum number of users allowed to join the lobby.
functionfunc (optional)
Callback function triggered when the lobby is created

Lobby:deleteData(key)

Removes lobby metadata.
stringkey
Key
Returns
boolean True if successful

Lobby:getChatMessage(index)

Gets message from the lobby chat room. Chat messages are indexed by number.
numberindex
Chat message index
Returns
string String message
User Message author

Lobby:getChatMessageCount()

Gets the total number of messages in the lobby chat room.
Returns
number Number of messages

Lobby:getData(key, user)

Get lobby metadata.
stringkey
Key
Useruser (optional)
User for member data
Returns
string Value

Lobby:getLimit()

Get the current limit on the number of users who can join the lobby.
Returns
number Number of users who can join the lobby

Lobby:getMembers()

Returns a list of members who have joined the lobby. The current user must be in the lobby to retrieve the Steam IDs of other users in that lobby.
Returns
table List of User objects

Lobby:getOwner()

Returns the lobby owner
Returns
User User object or nil if you aren"t a member of the lobby

Lobby:init(id)

This is an internal function. Please use steam.getLobby instead.
stringid
ID of an existing lobby

Lobby:invite(friend)

Invite another user to the lobby. Shows a list of friends if no specific user is provided.
Userfriend (optional)
The user who will be invited

Lobby:join(func)

Joins an existing lobby. This is an asynchronous request so please use Lobby:onJoin or provide a callback function.
functionfunc (optional)
Callback function triggered after subscribing

Lobby:leave()

Leave a lobby that the user is currently in; this will take effect immediately on the client side.

Lobby:onCreate()

Callback triggered after creating a new lobby.

Lobby:onJoin()

Callback triggered after joining a lobby.

Lobby:requestData()

Refreshes all of the metadata for a lobby that you're not in right now. You will never do this for lobbies you're a member of, that data will always be up to date. You can use this to refresh lobbies that you have obtained from RequestLobbyList or that are available via friends.
Returns
boolean True if successful

Lobby:sendChatMessage(msg)

Sends a chat message to the lobby chat room.
stringmsg
Message
Returns
boolean True if the message was successfully sent

Lobby:setData(key, value)

Set lobby metadata.
stringkey
Key
stringvalue
Value
Returns
boolean True if successful

Lobby:setJoinable(joinable)

Sets whether or not a lobby is joinable by other players. This always defaults to enabled for a new lobby. If joining is disabled, then no players can join, even if they are a friend or have been invited. Lobbies with joining disabled will not be returned from a lobby search.
booleanjoinable
Determines if the lobby can be joined
Returns
boolean True if successful

Lobby:setLimit(Number)

Set the maximum number of players that can join the lobby.
numberNumber
of users who can join the lobby
Returns
boolean True if successful

Lobby:setOwner(owner)

Changes the lobby owner. This can only be set by the owner of the lobby.
Userowner
The new lobby owner

Lobby:setType(kind)

Updates the lobby type. "private" means that the only way to join the lobby is from an invite. "friends" means that the lobby is joinable by friends and invitees. "public" means that the lobby will show in search. "invisible" means that the lobby will show in search, but is not visible to other friends. This is useful if you want a user in two lobbies, for example matching groups together. A user can be in only one regular lobby, and up to two invisible lobbies.
stringkind (public)
Kind of lobby: "private", "friends", "public" or "invisible"



Socket

The Socket object establishes peer-to-peer connections and sends data between clients.
Handle
Handle:callback(func, result, ...)This is an internal function.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.
Socket
Socket:destroy()Destroys the socket closing any open connections. All subsequent calls to this object will fail.
Socket:getAddress(peer)Finds the remote address of the peer. This is used for debugging purposes.
Socket:getId()Returns the channel number of the socket.
Socket:getPeer()Gets the peer associated this Socket object.
Socket:init(channel, kind)This is an internal function. Please use steam.getSocket instead.
Socket:isConnected(peer)Checks if there is an active and open connection with the peer.
Socket:receive()Receives data from the peer if available. This call is not blocking and will return nil if no data is available.
Socket:send(data, user)Sends data to the peer.
Socket:setPeer(peer)Sets the peer associated this Socket object. Both sides have to set each other as peers in order to establish a real P2P connection.
Socket:setProtocol(protocol)Sets the P2P protocol for the socket. "unreliable" is basic UDP where packets can be lost, or in rare cases arrive out of order. In case of connection problems, packet are batched until the connection is re-opened again. "nodelay" is the same as the previous, but if the underlying P2P connection isn't yet established the packet will be thrown away. "reliable" ensures that that the packets will always arrive in order. This is slower and allows sending larger messages efficiently. "buffered" is the same as the previous, but messages will accumulate and be send together in one packet. This is slower but allows you to send a set of smaller messages reliably.

Socket:destroy()

Destroys the socket closing any open connections. All subsequent calls to this object will fail.

Socket:getAddress(peer)

Finds the remote address of the peer. This is used for debugging purposes.
Userpeer (optional)
User, if different from the peer
Returns
string IP address of the peer (in IPv4 format)
number Port number
boolean True if using a Steam relay server

Socket:getId()

Returns the channel number of the socket.
Returns
number Channel number

Socket:getPeer()

Gets the peer associated this Socket object.
Returns
User Peer

Socket:init(channel, kind)

This is an internal function. Please use steam.getSocket instead.
numberchannel (0)
Channel number
stringkind ("unreliable")
Kind of socket: "unreliable", "nodelay", "reliable" or "buffered"
Returns
Socket Socket object

Socket:isConnected(peer)

Checks if there is an active and open connection with the peer.
Userpeer (optional)
User, if different from the peer
Returns
boolean True if connected

Socket:receive()

Receives data from the peer if available. This call is not blocking and will return nil if no data is available.
Returns
string Incoming message
User Sender, usually the same as the peer

Socket:send(data, user)

Sends data to the peer.
stringdata
Outgoing message
Useruser (optional)
Receiver, if different from the peer
Returns
boolean True if the message was sent

Socket:setPeer(peer)

Sets the peer associated this Socket object. Both sides have to set each other as peers in order to establish a real P2P connection.
Userpeer
User that we want to connect with

Socket:setProtocol(protocol)

Sets the P2P protocol for the socket. "unreliable" is basic UDP where packets can be lost, or in rare cases arrive out of order. In case of connection problems, packet are batched until the connection is re-opened again. "nodelay" is the same as the previous, but if the underlying P2P connection isn't yet established the packet will be thrown away. "reliable" ensures that that the packets will always arrive in order. This is slower and allows sending larger messages efficiently. "buffered" is the same as the previous, but messages will accumulate and be send together in one packet. This is slower but allows you to send a set of smaller messages reliably.
stringprotocol
Protocol kind: "unreliable", "nodelay", "reliable" or "buffered"



UGC

The Steam Workshop is designed as a place for your fans and community members to participate in the creation of content for your game. The form of this creation by community members can vary depending on the nature of the game and what kind of control you wish to have over the content in your game.
Handle
Handle:callback(func, result, ...)This is an internal function.
Handle:destroy()This is an internal function.
Handle:getId()Returns the unique Steam ID as a string.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.
UGC
UGC:create(kind, appid, func)This is an internal function. Please use steam.newUGC instead.
UGC:delete(func)Deletes the item without prompting the user.
UGC:download()Requests a download or update for a workshop item. If the user is not subscribed to the item, the workshop item will be downloaded and cached temporarily.
UGC:fetch(func)Fetches metadata about a user-generated item. This is an asynchronous request so please use UGC:onFetch or provide a callback function to receive the results.
UGC:getDetails(query, index)This is an internal function. Please use UGC:fetch instead.
UGC:getDownloadInfo()Get info about the pending download of a workshop item.
UGC:getInstallInfo()Gets info about currently installed content on the disc for workshop items. Calling this sets the "used" flag on the workshop item for the current player and adds it to their "used or played" list.
UGC:init(id, appid)This is an internal function. Please use steam.getUGC instead.
UGC:isInstalled()Checks if this workshop item is downloaded and installed on the client.
UGC:onCreate()Callback triggered when the user-generated item is created.
UGC:onDelete()Callback triggered after deleting the item.
UGC:onFetch(data)Callback triggered after fetching the item's metadata.
UGC:onStartTracking()Callback triggered when starting to track the user-generated item.
UGC:onStopTracking()Callback triggered when stopping to track the user-generated item.
UGC:onSubscribe()Callback triggered after subscribing to the user-generated item.
UGC:onUpdate(agree)Callback triggered after updating the item.
UGC:startTracking(func)Start tracking playtime on a set of workshop items. When your app shuts down, playtime tracking will automatically stop.
UGC:stopTracking(func)Stops tracking playtime on a set of workshop items.
UGC:subscribe(func)Subscribe to a workshop item. This will also downloaded and install the item as soon as possible. This is an asynchronous request so please use UGC:onSubscribe or provide a callback function.
UGC:update(path, data, note, func)Uploads the changes made to an item to the Steam Workshop.

UGC:create(kind, appid, func)

This is an internal function. Please use steam.newUGC instead.
stringkind ("community")
Type of object: "community", "micro", "collection", "art", "video", "screenshot", "game", "software", "concept", "webguide", "guide", "merch", "binding", "accessinvite", "steamvideo" or "managed".
valueappid (optional)
AppID if different from the base game
functionfunc (optional)
Callback function triggered when the item is created

UGC:delete(func)

Deletes the item without prompting the user.
functionfunc (optional)
Callback function triggered after deleting the item

UGC:download()

Requests a download or update for a workshop item. If the user is not subscribed to the item, the workshop item will be downloaded and cached temporarily.
Returns
boolean True if the download was started

UGC:fetch(func)

Fetches metadata about a user-generated item. This is an asynchronous request so please use UGC:onFetch or provide a callback function to receive the results.
functionfunc (optional)
Callback triggered after fetching the item's metadata

UGC:getDetails(query, index)

This is an internal function. Please use UGC:fetch instead.
cdataquery
Query object
numberindex
Index number
Returns
table Metadata table

UGC:getDownloadInfo()

Get info about the pending download of a workshop item.
Returns
number Downloaded bytes
number Total bytes

UGC:getInstallInfo()

Gets info about currently installed content on the disc for workshop items. Calling this sets the "used" flag on the workshop item for the current player and adds it to their "used or played" list.
Returns
string Directory path to the installed content
number Size in bytes
number Timestamp of when it was installed

UGC:init(id, appid)

This is an internal function. Please use steam.getUGC instead.
stringid
ID of an existing user-generated item
valueappid (optional)
AppID if different from the base game

UGC:isInstalled()

Checks if this workshop item is downloaded and installed on the client.
Returns
boolean True if installed

UGC:onCreate()

Callback triggered when the user-generated item is created.

UGC:onDelete()

Callback triggered after deleting the item.

UGC:onFetch(data)

Callback triggered after fetching the item's metadata.
tabledata
Table of fetched metadata

UGC:onStartTracking()

Callback triggered when starting to track the user-generated item.

UGC:onStopTracking()

Callback triggered when stopping to track the user-generated item.

UGC:onSubscribe()

Callback triggered after subscribing to the user-generated item.

UGC:onUpdate(agree)

Callback triggered after updating the item.
booleanagree
True if the user needs to accept the workshop legal agreement

UGC:startTracking(func)

Start tracking playtime on a set of workshop items. When your app shuts down, playtime tracking will automatically stop.
functionfunc (optional)
Callback function triggered when starting to track time

UGC:stopTracking(func)

Stops tracking playtime on a set of workshop items.
functionfunc (optional)
Callback function triggered when stopping to track time

UGC:subscribe(func)

Subscribe to a workshop item. This will also downloaded and install the item as soon as possible. This is an asynchronous request so please use UGC:onSubscribe or provide a callback function.
functionfunc (optional)
Callback function triggered after subscribing

UGC:update(path, data, note, func)

Uploads the changes made to an item to the Steam Workshop.
stringpath
Directory path that will be uploaded
tabledata
Metadata associated with the item
stringnote (optional)
Update note
functionfunc (optional)
Callback triggered after updating the item



User

User objects handle avatars, stats, achievements and other personal data.
Handle
Handle:callback(func, result, ...)This is an internal function.
Handle:destroy()This is an internal function.
Handle:getId()Returns the unique Steam ID as a string.
Handle:new()This is an internal function.
Handle:onError(message)This callback is triggered when any requests fails.
Handle:setId(handle)This is an internal function.
User
User:activateOverlay(dialog)Opens the user's profile in the game overlay.
User:cancelAuthTicket(ticket)Cancels an auth ticket received from User:getAuthTicket. This should be called when no longer playing with the specified entity.
User:clearAchievement(stat)Resets the unlock status of an achievement. This is primarily only ever used for testing.
User:clearRichPresence()Clears all previously set Rich Presence keys.
User:getAchievement(ach)Gets the achievement status, and the time it was unlocked if unlocked. If the return value is true, but the unlock time is zero, that means it was unlocked before Steam began tracking achievement unlock times (December 2009). The time is provided in Unix epoch format, seconds since January 1, 1970 UTC.
User:getAuthTicket()Retrieve an authentication ticket to be sent to the entity who wishes to authenticate you.
User:getAvatar(size)Returns an avatar if it's cached. Avatars are usually cached for the owner and his friends, but you may need to call User:requestAvatar for other users.
User:getGamePlayed()Checks if the specified friend is in a game, and gets info about the game if they are.
User:getLevel()Gets the user's Steam level if available, otherwise it queues the Steam level for download.
User:getName()Returns the persona name of the user. The persona name can be changed and can contain UTF-8 characters.
User:getPlayedWith()Gets the app ID of the game that user played with someone on their recently-played-with list.
User:getRichPresence(key)Sets a Rich Presence value for a key.
User:getStat(stat)Gets the current value of the a stat for the specified user. You must have called User:requestCurrentStats and it needs to return successfully via its callback prior to calling this!
User:init(id)This is an internal function. Please use steam.getUser instead.
User:inviteToGame(msg)Invites a friend or clan member to the current game using a special invite string. If the target user accepts the invite then the invite string gets added to the command-line when launching the game.
User:isFriend()Checks the user is friends with the owner.
User:isOnline()Checks the user's status among friends.
User:isOwner()Checks if the user is the current owner.
User:onReceiveStats()Callback triggered when the user stats are received from the server.
User:requestAvatar()Requests the avatar for caching. It's a lot slower to download avatars and churns the local cache, so if you don't need avatars, don't request them.
User:requestCurrentStats()Asynchronously request the owner's current stats and achievements from the server. The equivalent function for other users is User:requestStats.
User:requestName()This is an internal function. Requests that the user's persona name is fetched and cached locally.
User:requestRichPresence()Requests the rich presence details for users who are not friends.
User:requestStats(func)Asynchronously request the user's stats and achievements from the server. This function triggers the User:onReceiveStats callback.
User:resetStats(ach)Resets all stats and achievements unlocked by the owner.
User:setAchievement(stat)Unlocks a specific attachment. You must have called User:requestCurrentStats and it needs to return successfully via its callback prior to calling this!
User:setName(name)Sets the persona name of the owner.
User:setPlayedWith()Mark a target user as 'played with'. The current user must be in game with the other player for the association to work.
User:setRichPresence(key, value)Sets a Rich Presence key/value for the current user that is automatically shared to all friends playing the same game. Each user can have up to 20 keys set.
User:setStat(stat, value)Sets or updates the value of a given stat for the current user. You must have called User:requestCurrentStats and it needs to return successfully via its callback prior to calling this!
User:storeStats()Stores the user's stats and achievements on the server.

User:activateOverlay(dialog)

Opens the user's profile in the game overlay.
stringdialog
Dialog options: "steamid", "chat", "jointrade", "stats", "achievements", "friendadd", "friendremove", "friendrequestaccept" or "friendrequestignore"

User:cancelAuthTicket(ticket)

Cancels an auth ticket received from User:getAuthTicket. This should be called when no longer playing with the specified entity.
stringticket
Authentication ticket

User:clearAchievement(stat)

Resets the unlock status of an achievement. This is primarily only ever used for testing.
stringstat
Achievement name
Returns
boolean True if successful

User:clearRichPresence()

Clears all previously set Rich Presence keys.

User:getAchievement(ach)

Gets the achievement status, and the time it was unlocked if unlocked. If the return value is true, but the unlock time is zero, that means it was unlocked before Steam began tracking achievement unlock times (December 2009). The time is provided in Unix epoch format, seconds since January 1, 1970 UTC.
stringach
Achievement name
Returns
boolean True if unlocked
number Timestamp of when it was unlocked

User:getAuthTicket()

Retrieve an authentication ticket to be sent to the entity who wishes to authenticate you.
Returns
string Authentication ticket

User:getAvatar(size)

Returns an avatar if it's cached. Avatars are usually cached for the owner and his friends, but you may need to call User:requestAvatar for other users.
stringsize ("medium")
Image size: "small", "medium" or "large"
Returns
string Encoded image data of the avatar or nil

User:getGamePlayed()

Checks if the specified friend is in a game, and gets info about the game if they are.
Returns
number AppID of the game your friend is playing
Lobby The lobby that your friend has joined, if available

User:getLevel()

Gets the user's Steam level if available, otherwise it queues the Steam level for download.
Returns
number Steam level or 0 if unavailable

User:getName()

Returns the persona name of the user. The persona name can be changed and can contain UTF-8 characters.
Returns
string Persona name

User:getPlayedWith()

Gets the app ID of the game that user played with someone on their recently-played-with list.
Returns
number AppID
number Amount of co-play time

User:getRichPresence(key)

Sets a Rich Presence value for a key.
stringkey
Key string
Returns
string value Value string

User:getStat(stat)

Gets the current value of the a stat for the specified user. You must have called User:requestCurrentStats and it needs to return successfully via its callback prior to calling this!
stringstat
Stat name
Returns
number Stat value

User:init(id)

This is an internal function. Please use steam.getUser instead.
stringid (optional)
User ID in decimal format

User:inviteToGame(msg)

Invites a friend or clan member to the current game using a special invite string. If the target user accepts the invite then the invite string gets added to the command-line when launching the game.
stringmsg
Invitation message
Returns
boolean True if the invite was successfully sent

User:isFriend()

Checks the user is friends with the owner.
Returns
boolean True if friends with the owner

User:isOnline()

Checks the user's status among friends.
Returns
boolean True if currently visible among friends

User:isOwner()

Checks if the user is the current owner.
Returns
boolean True if the user is the owner

User:onReceiveStats()

Callback triggered when the user stats are received from the server.

User:requestAvatar()

Requests the avatar for caching. It's a lot slower to download avatars and churns the local cache, so if you don't need avatars, don't request them.
Returns
boolean False if the avatar is already cached

User:requestCurrentStats()

Asynchronously request the owner's current stats and achievements from the server. The equivalent function for other users is User:requestStats.
Returns
boolean False if the avatar is already cached

User:requestName()

This is an internal function. Requests that the user's persona name is fetched and cached locally.
Returns
boolean False if the persona name is already cached

User:requestRichPresence()

Requests the rich presence details for users who are not friends.

User:requestStats(func)

Asynchronously request the user's stats and achievements from the server. This function triggers the User:onReceiveStats callback.
functionfunc
Callback function triggered when the stats are ready

User:resetStats(ach)

Resets all stats and achievements unlocked by the owner.
booleanach
Determines if achievement data should be wiped too
Returns
boolean True if successful

User:setAchievement(stat)

Unlocks a specific attachment. You must have called User:requestCurrentStats and it needs to return successfully via its callback prior to calling this!
stringstat
Achievement name
Returns
boolean True if successful

User:setName(name)

Sets the persona name of the owner.
stringname
New persona name

User:setPlayedWith()

Mark a target user as 'played with'. The current user must be in game with the other player for the association to work.

User:setRichPresence(key, value)

Sets a Rich Presence key/value for the current user that is automatically shared to all friends playing the same game. Each user can have up to 20 keys set.
stringkey
Key string (where "status", "connect", "steam_display", "steam_player_group", "steam_player_group_size" are reserved)
stringvalue
Value string
Returns
boolean True if successful

User:setStat(stat, value)

Sets or updates the value of a given stat for the current user. You must have called User:requestCurrentStats and it needs to return successfully via its callback prior to calling this!
stringstat
Stat name
numbervalue
Stat value
Returns
boolean True if successful

User:storeStats()

Stores the user's stats and achievements on the server.
Returns
boolean True if successful