2.5 External Functions
External functions are used to communicate with the underlying game instance.
2.5.1 Debug 2.5.2 Entities 2.5.3 Events 2.5.4 Players 2.5.5 World 2.5.6 Input 2.5.7 Config 2.5.8 UIRegDump
Implemented in Version a2.0
void RegDump();
RegDump is an external function for debugging purposes that outputs the content of all registers.
Break
Implemented in Version a2.0
void Break(int value);
Break stops the underlying interpreter and ouputs the exit value to the log.
An non-zero exit value usually indicates an inrecoverable error.
Breaking a client will set the player back to the main menu.
GetID
Implemented in Version a2.0
void GetID(unsigned long* id);
Outputs a random unique new entity ID into the variable pointed to by id.
AssignEntity
Implemented in Version a2.0
void AssignEntity(unsigned long id);
Creates a new entity in the world and passes the unique id from the parameter.
RemoveEntity
Implemented in Version a2.0
void RemoveEntity(unsigned long id);
Despawns the entity with the given id. The passed id is not recycled.
SendRequest
Implemented in Version a2.0
void SendRequest(enum Request request, int a, int b);
Sends a request determined by the first parameter, passing the second and third parameters to the server.
If a string was sent along by SendString, it will now be passed to the server.
A server sending a request is undefined behaviour and should not happen.
ReceiveRequest
Implemented in Version a2.0
void ReceiveRequest(int* request, int* client, int* a, int* b);
Outputs all received parameters from the client into the specified variables. The calling ClientID (not the Entity ID) is received here too.
Any previously received string which was not checked with FetchString will be discarded.
A client receiving a request is undefined behaviour and should not happen.
SendEvent
Implemented in Version a2.0
void SendEvent(enum Event event, int client, int a, int b);
Sends an event determined by the first parameter, passing the third and forth parameters to the client indicated by the second parameter.
If a string was sent along by SendString, it will now be passed to the client.
A client sending an event is undefined behaviour and should not happen.
SendEventExclude
Implemented in Version a2.0
void SendEventExclude(enum Event event, int client, int a, int b);
Sends an event determined by the first parameter, passing the third and forth parameters to all clients except the one indicated by the second parameter.
If a string was sent along by SendString, it will now be passed to the clients.
A client sending an event is undefined behaviour and should not happen.
SendEventEveryone
Implemented in Version a2.0
void SendEventEveryone(enum Event event, int client, int a, int b);
Sends an event determined by the first parameter, passing the third and forth parameters to all clients.
If a string was sent along by SendString, it will now be passed to the clients.
A client sending an event is undefined behaviour and should not happen.
ReceiveEvent
Implemented in Version a2.0
void ReceiveEvent(int* event, int* a, int* b);
Outputs all received parameters from the server into the specified variables.
Any previously received string which was not checked with FetchString will be discarded.
A server receiving an event is undefined behaviour and should not happen.
FetchString
Implemented in Version a2.0
void FetchString(char* out);
Allocates memory and outputs pointer for the string received with the current event/request.
SendString
Implemented in Version a2.0
void SendString(char* in);
Stores string to send with next event/request.
IsServer
Implemented in Version a2.0
void IsServer(bool* out);
Outputs true, if the current instance is the server. Otherwise the value will be false.
GetClientConnected
Implemented in Version a2.0
void GetClientConnected(bool* out, int client)
Outputs true, if the given client has already been marked as connected. Otherwise the value will be false.
ConnectClient
Implemented in Version a2.0
void ConnectClient(int client)
Marks a client as connected.
DisconnectClient
Implemented in Version a2.0
void DisconnectClient(int client, int reason)
Disconnects a client from the server, clearing the given clientID. Additionally a reason is passed.
Zero indicates a regular disconnect.
AssignClientID
Implemented in Version a2.0
void AssignClientID(int client, unsigned long id)
Binds a clientID to an entityID.
ResolveClientID
Implemented in Version a2.0
void ResolveClientID(unsigned long* out, int client)
Outputs the assigned entityID to the matching clientID.
A resolve of an invalid or unassigned client is undefined behaviour and should not happen.
LookupClientID
Implemented in Version a2.0
void LookupClientID(int* client, unsigned long id)
Outputs the assigned clientID to the matching entityID.
A lookup of an invalid or unassigned client is undefined behaviour and should not happen.
GetClientAmount
Implemented in Version a2.0
void GetClientAmount(int* out)
Outputs the amount of all clients on the server.
GetClientID
Implemented in Version a2.0
void GetClientAmount(int* out, int index)
Outputs the clientID from the internal list of all plugins at the given index.
An invalid or negative index is undefined behaviour and should not happen.
SetDisconnectionRequest
Implemented in Version a2.0
void SetDisconnectionRequest(enum Request request)
Sets the request that the server will automatically receive when a client disconnects.
GetPlayerAttribute
Implemented in Version a2.0
void GetPlayerAttribute(int* value, int client, int attribute)
Gets a special attribute from an internal client controller.
As of right now, no attributes are bound.
SetPlayerAttribute
Implemented in Version a2.0
void SetPlayerAttribute(int attribute, int client, int value)
Sets a special attribute from an internal client controller. Adjusts movement and camera.
As of right now, no attributes are bound.
GetPosition
Implemented in Version a2.0
void GetPosition(int* x, int* y, int* z, unsigned long id)
Gets an entity's or a special entity's coordinates.
SetPosition
Implemented in Version a2.0
void SetPosition(unsigned long id, int x, int y, int z)
Sets an entity's or a special entity's coordinates.
GetRotation
Implemented in Version a2.0
void GetRotation(int* x, int* y, int* z, unsigned long id)
Gets an entity's or a special entity's rotation.
SetRotation
Implemented in Version a2.0
void SetRotation(unsigned long id, int x, int y, int z)
Sets an entity's or a special entity's rotation.
AddModel
Implemented in Version a2.0
void AddModel(unsigned long* id, char const* path, unsigned long entityID, int index)
Adds a model to an entity, taking a path to the model (starting at the asset directory) and the entity's id.
Returns the id of the special model entity.
If an entity contains multiple models, the index can be incremented or to edit a model be kept the same.
Adding a model to an invalid or special entity or at an invalid index is undefined behaviour.
SetMaterial
Implemented in Version a2.0
void SetMaterial(unsigned long id, char const* path, int index)
Sets the material on a model at the given index to the material provided by the path.
Removing the material involves entering "null" as the path.
RemoveSpecial
Implemented in Version a2.0
void RemoveSpecial(unsigned long id)
Removes a special entity from another entity.
Models, Hitboxes and Rigidbodies can be removed through this way.
GetModel
Implemented in Version a2.0
void GetModel(unsigned long* id, unsigned long entityID, int index)
Returns a models ID at the given index on an entity if present.
Otherwise 0 is returned into the id field.
AddRigidbody
Implemented in Version a2.0
void AddRigidbody(unsigned long* id, unsigned long entityID, int index)
Adds a rigidbody at the given index on an entity returning its id.
A rigidbody enables gravity and movement on an entity.
AddHitbox
Implemented in Version a2.0
void AddHitbox(unsigned long* id, unsigned long entityID, int index)
Adds a hitbox at the given index on an entity returning its id.
A hitbox enables collision on an entity.
SetSize
Implemented in Version a2.0
void SetSize(unsigned long id, int x, int y, int z)
Sets size of an entity or special entity.
GetHitbox
Implemented in Version a2.0
void GetHitbox(unsigned long* id, unsigned long entityID, int index)
Gets an existing hitbox on an entity at the given index, returning the id.
Otherwise returns 0.
GetRigidbody
Implemented in Version a2.0
void GetRigidbody(unsigned long* id, unsigned long entityID, int index)
Gets an existing rigidbody on an entity at the given index, returning the id.
Otherwise returns 0.
PlayerRaycast
Implemented in Version a2.0
void PlayerRaycast(unsigned long* out, int client, int length)
Casts a ray from the given client's camera with the given length returning the id of the first hit regular entity.
Returns 0 if no entity was hit.
GetInputAmount
Implemented in Version a2.0
void GetInputAmount(int* out)
Outputs the amount of inputs present.
GetInput
Implemented in Version a2.0
void GetInput(int* out, int index)
Outputs the input type as an Input enum value at the given index.
OpenEntry
Implemented in Version a2.0
void OpenEntry(int index)
Sets entry read from, given an index in the open table.
LoadNumber
Implemented in Version a2.0
void LoadNumber(int* out, int index)
Reads and outputs number from given row in the open entry.
LoadString
Implemented in Version a2.0
void LoadString(char** out, int index)
Reads, allocates and outputs string from given row in the open entry.
Output may vary depending on the selected language.
GetEntryIndex
Implemented in Version a2.0
void GetEntryIndex(int* out, char const* entry)
Gets entry index from label name on entry.
SetUIProperty
Implemented in Version a2.0
void SetUIProperty(char* name, char const* property, int value)
Modifies a given ui property at a given property from loaded ui sheet.
CreateUIElement
Implemented in Version a2.0
void CreateUIElement(char* name, char const* type)
Creates a new ui element with the given type.
The parent of this element is set through the name in this method, so "hotbar/slot5" would create an element named "slot5" under "hotbar".
DeleteUIElement
Implemented in Version a2.0
void DeleteUIElement(char* name)
Deletes a UI element with the given name.
AnimateUIProperty
Implemented in Version a2.0
void AnimateUIProperty(char* name, char const* property, int value, int timeInMs, enum AnimationType type)
Smoothly transitions ui element's property from the current value to a new value in the given time.
Additionally, an AnimationType enum value is passed.