Skip to content
ForgeCastDocs

Your PC

The PC's numbers, battery and temperature, whether you are away, the game you play and the music that is playing.

Functions

system.specs()

What the PC is: Windows, processor, memory, graphics cards and screens.

Returns PcSpecs

system.usage()

How busy the PC is now.

Returns PcUsage

system.app()

What ForgeCast itself uses: { memory_mb, cpu_percent, gpu_percent }.

Returns table

system.battery()

{ has_battery, percent, plugged_in }.

Returns table

system.temps()

{ cpu, gpu } in °C where Windows reports them (often only cpu, sometimes neither).

Returns table

system.keep_awake(on)

Keep the PC and its screen from sleeping (until false, or the plugin stops).

  • on: boolean

system.ping(target, callback)

How fast a well-known server answers: { target, best_ms, average_ms }. "youtube" is YouTube's ingest server (where your stream goes).

  • target: "youtube"|"twitch"|"cloudflare"|"google"
  • callback: fun(result: table?, error?: string)

system.watch(spec)

Watch the PC: Event.SystemBusy after seconds over a limit (percent), Event.SystemCalm after as many under them all.

  • spec: { cpu: number?, ram: number?, gpu: number?, seconds: integer? }

system.unwatch()

Stop watching.

system.on(event, fn)

Hear Event.SystemBusy or Event.SystemCalm (start watching with system.watch).

  • event: string
  • fn: fun(e: table)

Returns integer id

activity.idle_ms()

Milliseconds since the last key press or mouse move anywhere on the PC (only when, never what).

Returns integer?

activity.game()

The game being played (the one in front, or any known game running): { name, exe }, or nil.

Returns { name: string, exe: string }?

activity.away_after(seconds)

How long without a key press counts as away (120 s by default, at least 10).

  • seconds: integer

activity.on(event, fn)

Hear Event.Away, Event.Back or Event.GameChange.

  • event: string
  • fn: fun(e: table)

Returns integer id

media.now_playing()

What is playing on the PC (any player Windows' media controls know), or nil.

Returns NowPlaying?

media.on(event, fn)

Hear Event.SongChange: fn(song) (nil when the music stopped).

  • event: string
  • fn: fun(song: NowPlaying?)

Returns integer id

Types

Open a type to see its fields; type names above link here.

On this page