Skip to content

RegisterUiFallback

Gives a screen the mode has twice - a web frame and a client script’s own - one name to be sent events by.

A mode that wants a login screen for everybody has two: the web frame, for players whose game has the web layer, and a screen drawn by a client script for the rest. RegisterUiFallback("login", "loginbox") says that the screen’s events are named after the frame - login.open, login.error - and that the client script’s twin listens for the same names under the prefix loginbox. From then on SendClientEvent and SendClientEventToAll send "login.open" to a player whose web layer is starting or ready and whose interface has a frame login, and "loginbox.open" to everyone else. The names of the events that come back are not changed: the page’s arrive as login.* with the frame as their source, the twin’s as whatever it sends, with the source "lua".

The choice is made for each event, at the moment it is sent, so a player whose web layer fails while the screen is open is sent the twin’s events with no twin open: close the screen and open it again in OnPlayerWebStatus when the status is "failed".

The prefix may end in a dot, which is ignored. A reload of the mode empties the list of registered screens, so a mode registers them where it is made again, in OnGameModeInit. The answer is true, or false and the reason when the frame name is not lower-case letters, digits and -, or the prefix is empty.

RegisterUiFallback(frame, luaEventPrefix)
Parameter Type
frame string the frame’s name, as ui.toml gives it
luaEventPrefix string the prefix of the events the client script’s twin listens for

true, or false, reason - the reason as a person reads it

function OnGameModeInit()
RegisterUiFallback("login", "loginbox")
end
function OnPlayerConnect(pid)
SendClientEvent(pid, "login.open", { attempts = 3 }) -- the page, or the client script's box, whichever the player has
end

SendClientEvent · OnPlayerWebStatus · IsPlayerWebReady · the Web interface group of the index