SixL client API / browser / BrowserMpPool
Interface: BrowserMpPool
The browsers of this client: mp.browsers. The pool keeps every browser that is not destroyed.
Example
const hud = mp.browsers.new('package://ui/index.html');
Constructors
Constructor
new BrowserMpPool(url):BrowserMp
Creates a page over the game and loads the address in it. The page is shown at once (active is true).
Parameters
url
string
The address: a package:// path or an https:// address.
Returns
The new browser. Its browserCreated event is raised after this call returns.
Remarks
The page is drawn over the game with a transparent background. The address loads in the background.
Example
const menu = mp.browsers.new('package://ui/menu.html');
Properties
length
readonlylength:number
The number of live browsers.
Example
mp.console.logInfo('pages: ' + mp.browsers.length);
Methods
at()
at(id):BrowserMp
The browser with this id, or undefined if there is none (never created, or destroyed).
Parameters
id
number
The browser's id, 1 or more.
Returns
The browser, or undefined.
Example
const same = mp.browsers.at(1);
exists()
exists(browser):boolean
Whether the value is a browser of this pool that is not destroyed.
Parameters
browser
unknown
Any value.
Returns
boolean
true for a live browser of this client, false for anything else.
Example
if (mp.browsers.exists(hud)) hud.reload();
forEach()
forEach(callingFunction):void
Calls callingFunction for every live browser, in the order of creation.
Parameters
callingFunction
(entity) => void
Called with each browser. The calls go over the list taken before the first call, so a browser destroyed inside the loop is still passed.
Returns
void
Example
mp.browsers.forEach((page) => page.reload());
toArray()
toArray(): BrowserMp[]
The live browsers as a new array, in the order of creation.
Returns
A new array; changing it does not change the pool.
Example
const pages = mp.browsers.toArray();