LanLobby - stingray.LanLobby object reference - Stingray Lua API Reference

stingray.LanLobby object reference

Description

Represents a lobby in a LAN game.

You can create a new lobby by calling Network.create_lan_lobby(), or join an existing one by calling Network.join_lan_lobby().

Functions

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

key :

string

A string key that describes the value.

Returns

string

The string stored for the key.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

string?

The peer ID of the host of the game session for the lobby, or nil if no game session host has been set.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

If a peer detects that a game session host has been set, it should typically first load the level map and then send a message to the game session host saying that it wants to drop into the session. Upon receiving that message, the game session host should call GameSession.add_peer() to add the peer to the game session.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

peer :

any(string, integer)

The string ID of the peer, or the zero-based index value of the peer within the list of peers in the lobby.

The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses.
Returns
This function does not return any values.

Only the lobby host can call this function.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

string

The ID of the peer hosting the lobby.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

string[]

A list of the peer IDs of all peers connected to the lobby.

The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown.
Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

peer_id :

string

The peer ID of the lobby member whose data you want to retrieve.

key :

string

The string key that describes the value you want to retrieve.

Returns

string

The string value stored for the specified key.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

key :

string

The string key that describes the value you want to retrieve.

Returns

string

The string value stored for the specified key.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

key :

string

A string key that describes the value.

value :

string

A string value to store for the key.

Returns
This function does not return any values.

Other peers will be able to access this value in the data table returned by LanLobbyBrowser.lobby(). You can use this mechanism to store descriptive information about the lobby, such as the name of the host, the name of the game, the name of the level or map that will be played, etc. Your game can then present this information to other prospective players, in order for those players to decide whether or not to join the lobby.

Any peer that has joined the lobby can access the value by calling data().

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

peer_id :

string?

The ID of the peer that should become the host of the game session, or nil to clear the game session host.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.

This is used by the lobby host in order to indicate to all connected peers that the game session has started.

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

key :

string

A string key that describes the value.

value :

string

A string value to store for the key.

Returns
This function does not return any values.

Other members of the lobby can access this data by calling member_data().

Parameters

self :

stingray.LanLobby

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

integer

An element from the State constants that indicates the current state of the lobby.

State constants

The constants in this section may be returned by LanLobby.state() in order to describe the current state of the lobby.

If the lobby is successfully created, the state will change to LanLobby.JOINED. If the creation fails, the state will be LanLobby.FAILED.

When this peer has been accepted, the state changes to LanLobby.JOINED. If this peer is not accepted, the state changes to LanLobby.FAILED.