LÖVE
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 Quickstart Guide.
Installation
The LÖVE SDK can be installed by cloning the latest version from our GitHub into your a folder called sdk
within your LÖVE game directory.
You can then import the SDK like so:
SDK Object
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
The first thing you need to do when your game starts is initialise the SDK. To do this, run the sdk.init
function within love.load
. This function takes the game_id
parameter. The Game ID of your game can be found on the web panel.
Our LÖVE SDK only supports anonymous authentication at present, so you do not need supply a username and password.
Join with a player
After a connection has been established by sdk.init
, the function sdk.join
will spawn the player into the game world.
Receive server messages
The sdk.update
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.
Send messages to the server
You can call the sdk.message
function to send a message to the server. This message will be received by the player.lua
file's message
function on the server.
Game World Objects
Game worlds are made up of entities, which represent objects and creatures, and chunks to represent the world space.
Entity Object
Data about entities is passed to the LÖVE client using sdk.update
. You can access all the entities within sdk.entities
(which can be iterated over) and draw them based each entity's data.
Entities have types 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 EntityID
field.
The EntityID
of the player entity associated with this client is also stored in sdk.uuid
. This makes it easier to access the player entity directly with sdk.entities[sdk.uuid].
Chunk Object
Data about chunks is passed to the LÖVE client using sdk.update
. You can access all the chunk data within sdk.chunks
(which can be iterated over).
API
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:
SDK Object
Variables
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.
Methods
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.
Entity Object
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.
Chunk Object
Fields
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.
Last updated