SixL client API / world-entities / TextLabelMpPool

Interface: TextLabelMpPool

The pool of text labels: mp.labels. It holds the labels the server has sent to this client, and the ones a script made.

Example

mp.labels.forEach((label) => mp.console.logInfo(label.text));

Constructors

Constructor

new TextLabelMpPool(text, position, options?): TextLabelMp

Makes a text label, drawn by the overlay until it is destroyed.

Parameters

text

string

The text.

position

Vector3

Where it floats, metres.

options?

color ([r, g, b, a], white by default), drawDistance (metres, 20 by default), font, los (false by default) and dimension.

color?

Array4d

dimension?

number

drawDistance?

number

font?

number

los?

boolean

Returns

TextLabelMp

The new label.

Remarks

It is not streamed: no stream-in event is raised for it.

Example

const label = mp.labels.new('Shop', new mp.Vector3(10, 20, 32), { drawDistance: 30 });

Properties

length

readonly length: number

The number of labels the client holds now.

Example

const count = mp.labels.length;

Methods

at()

at(id): TextLabelMp

The label with this client id, or undefined.

Parameters

id

number

The client's own number for the label (from 1, reused after a label is removed). It is not the server's id.

Returns

TextLabelMp

The label, or undefined when there is none with that id.

Example

const label = mp.labels.at(1);

exists()

exists(entity): boolean

Whether a label is still held by this client.

Parameters

entity

number | TextLabelMp

A label, or the client id of one (the id of TextLabelMpPool.at).

Returns

boolean

True while the label is held; false once the server has removed it from this client, or a script has destroyed it.

Example

if (mp.labels.exists(label)) { }

forEach()

forEach(callingFunction): void

Calls a function for every label held by this client.

Parameters

callingFunction

(entity) => void

Called with each label.

Returns

void

Example

mp.labels.forEach((label) => mp.console.logInfo(label.text));

toArray()

toArray(): TextLabelMp[]

The labels held by this client, as an array.

Returns

TextLabelMp[]

A new array of the labels at the time of the call.

Example

const all = mp.labels.toArray();