Skip to Content

panorama

Run JavaScript in Panorama panels with panorama.loadstring and read Panorama globals from Lua.


Panorama is the game's JavaScript UI. Calls must run on the main game thread; calls from other threads return nil.

A panel argument is a panel ID, searched first in the HUD while in game, then in the main menu. Its default is "CSGOMainMenu".

panorama.loadstring

panorama.loadstring(js, panel?)

Compiles js as a function body. Call the returned object to execute it; use JavaScript return to produce a result.

Returns: a callable panorama.object, or nil, err when the body does not compile (nil alone off Panorama's main thread or when the panel is missing). Compilation errors are also printed in the Panorama console.

Calling the returned object answers the function's result, or nil, err when the JavaScript throws; the exception still goes to the Panorama console. err is the message, the position in js and V8's stack:

Error: boom (line 2, column 9)
Error: boom
    at cs2hk-js-14:3:9

Lines count from the first line of js. A thrown non-Error value has no position. Only functions loadstring returned report errors; any other JavaScript function called from Lua answers a bare nil when it throws.

local get_map, compile_error = panorama.loadstring('return GameStateAPI.GetMapBSPName();')
if get_map then
    local map, err = get_map()
    print(map or ('panorama: ' .. err))
else
    print('panorama: ' .. compile_error)
end

Each call of a loaded function is a fresh function call: a top-level var or function in js is local to that call. Keep state across calls on the panel context's global object:

local count = panorama.loadstring('globalThis.nixware_count = (globalThis.nixware_count || 0) + 1; return globalThis.nixware_count;')
print(count(), count()) -- 1  2

Panorama lookup

panorama.CSGOHud
panorama.GameStateAPI

If the name identifies a panel, returns its JavaScript global object. Otherwise reads the property from the main menu's global object and converts it to Lua.

Returns: a panorama.object, a converted Lua value, or nil.

On this page