> ## Documentation Index
> Fetch the complete documentation index at: https://lua.starline.one/llms.txt
> Use this file to discover all available pages before exploring further.

# Panorama

> Run JavaScript and interact with panels in the CS2 Panorama UI.

Runs JavaScript in the game's Panorama UI.

```lua theme={"dark"}
panorama.RunScript('$.DispatchEvent("MatchAssistedAccept");')
```

| Function                  | Returns                        |                                                                      |
| ------------------------- | ------------------------------ | -------------------------------------------------------------------- |
| `RunScript(js [, panel])` | nothing                        | `panel` defaults to the main menu panel                              |
| `FindPanel(id [, root])`  | [`Pointer`](/pointer) or `nil` | recursive search by panel id; `root` defaults to the main menu panel |
| `GetMainMenuPanel()`      | [`Pointer`](/pointer) or `nil` | `nil` before the menu exists                                         |
| `GetEngine()`             | [`Pointer`](/pointer) or `nil` | `CUIEngineSource2*`, for whatever you want to do with it yourself    |

## Panels

A panel is a `Pointer` to `CUIPanel`. You may also resolve one with FFI:

```lua theme={"dark"}
local p = panorama.FindPanel('CSGOMainMenu')
if p then
    panorama.RunScript('$.Msg("hello");', p)
end
```

Panel addresses are validated before use:

```
panorama: not a valid panel
```

`RunScript` and `FindPanel` also raise when the UI engine is not up yet (`panorama: UI engine not available yet`) and when there is no main menu panel to default to. Wrap them in `pcall` if you call them early.

## Notes

Scripts run in the target panel's JavaScript context. JavaScript errors appear in the Panorama console, not Lua.

Calls made on the game thread run immediately. Calls from other threads are queued for the game thread.
