LÖVE
Last updated
Last updated
The LÖVE SDK integrates our multiplayer platform with LÖVE. The library provides methods and variables to use within your game client code - these communicate changes in state from your server side simulation to the game client itself.
If you are new here, we recommend starting with the .
LÖVE v11.0+
The LÖVE SDK can be installed by cloning the latest version from our into your a folder called sdk
within your LÖVE game directory.
You can then import the SDK like so:
The SDK object (the imported SDK) can be used to call a variety of functions. These allow you to connect to and pull information from the game server.
Establish a connection
Our LÖVE SDK only supports anonymous authentication at present, so you do not need supply a username and password.
Join with a player
Receive server messages
Send messages to the server
Below are reference tables of the API available within LÖVE 's environment.
The SDK exposes various public methods which can be accessed within scripts by importing the SDK like so:
To connect to the server and join with the player, for example:
entities
entities: table({
id: string
entity: table
)}
List of entities the client can see.
chunks
table: table({
id: string
chunk: table
)}
List of chunks the client can see.
uuid
string
UUID of the player associated with this client.
init
game_id: int
Called to connect to the Planetary Processing servers.
join
None
Spawn into the world.
update
None
Call this method inside love.update
.
message
msg: table
Send a message to the player entity on the server.
leave
None
Disconnect the player from the world.
quit
None
Sever the connection to the game.
Fields
EntityID
string
UUID of the entity.
X
float
X coordinate in world units.
Y
float
Y coordinate in world units.
Data
table
Data of the entity.
Type
string
Type of the entity.
ID
string
UUID of the chunk.
X
float
X coordinate in chunk units.
Y
float
Y coordinate in chunk units.
Data
table
Data of the chunk.
The first thing you need to do when your game starts is initialise the SDK. To do this, run the function within love.load
. This function takes the game_id
parameter. The Game ID of your game can be found on the .
After a connection has been established by , the function will spawn the player into the game world.
The function should be called within love.update
. It will pass data about entities and chunks from the server to the client, then save it in the SDK object's variables.
You can call the function to send a message to the server. This message will be received by the player.lua
file's function on the server.
Game worlds are made up of , which represent objects and creatures, and to represent the world space.
Data about is passed to the LÖVE client using . You can access all the entities within (which can be iterated over) and draw them based each entity's data.
Entities have used to categorise their behaviour on the server side backend. They can be used to access groups of entities. Individual entities can be accessed using the field.
The of the player entity associated with this client is also stored in . This makes it easier to access the player entity directly with sdk.entities[sdk.uuid].
Data about is passed to the LÖVE client using . You can access all the chunk data within sdk.chunks
(which can be iterated over).