Zum Inhalt springen
Gothic Multiplayer
Gothic MP Wiki

Functions

Opening web pages of the server's ui folder over the game, checking support, the screen size in CSS pixels.

since 0.1.0-alpha

Web pages (HTML, CSS, JavaScript - plain or built with any framework) drawn over the game by Chromium (CEF). Start with the Web UI guide; a page is a Browser, its JavaScript side is window.gmp. To let the player click and type, show the cursor.

Web UI (CEF)

Web pages (HTML, CSS, JavaScript - plain or built with React, Vue, Angular, Svelte...) drawn over the game by Chromium. The pages are files of the server's ui folder; the players download them on joining. A page and the script talk through window.gmp in the page and the Browser object in Lua. The whole picture with examples is in the guide.

createBrowser

since 0.1.36-alpha
createBrowser(path, x, y, width, height)

Opens a page of the server's ui folder in a new browser drawn over the game. Position and size are in CSS pixels of a 1920x1080 screen (the page looks the same at every resolution - on a 4K screen it is rendered twice as sharp); getScreenSize gives the whole screen. The page's background is transparent unless the page paints one. The browser shows at once; the page is ready when it says so (gmp.trigger("ready") in its JavaScript).

local w, h = getScreenSize()
local hud = createBrowser("hud/index.html", 0, 0, w, h)          -- the whole screen
local shop = createBrowser("shop/index.html", 560, 240, 800, 600)  -- a window in the middle
ParameterTypeDescription
pathstringPath of the page file in the server's ui folder, e.g. "login/index.html".
xintegerLeft edge, CSS px.
yintegerTop edge, CSS px.
widthintegerWidth, CSS px (1-8192).
heightintegerHeight, CSS px (1-8192).

Returns: Browser | nil - nil when this player's game cannot show web pages (see isBrowserSupported).

isBrowserSupported

since 0.1.36-alpha
isBrowserSupported()

Whether this player's game can show web pages - the launcher downloads the Chromium component once; without it createBrowser returns nil. A script can then fall back to e.g. chat commands.

Returns: boolean

getScreenSize

since 0.1.36-alpha
getScreenSize()

Size of the whole screen in CSS pixels - the space for createBrowser. It is 1080 high from 1080p up (1920x1080 on 16:9 screens, 2560x1080 on 21:9), the real resolution below 1080p.

Returns:

ValueTypeDescription
widthinteger
heightinteger