Flashlight

Gives the player a flashlight to switch on and off: a beam that lights what it points at, a battery that drains while it is on, batteries to find in the world and a flicker when it runs low.

Source: module-kits:kits/light_flashlight/usage/en.mdView Markdown source

Also read offline — CLI: grip-forge docs light-flashlightMCP tool: gripforge_docs { "topic": "light-flashlight" }

Flashlight (light.flashlight) #

What it is for #

Gives the player a flashlight to switch on and off: a beam that lights what it points at, a battery that drains while it is on, batteries to find in the world and a flicker when it runs low.

It needs input.actions, game.engine; installing it brings them in.

Turn it on #

Install the kit in a project, then change a setting (the values shown are its defaults):

gripforge_gamekit_install   { project_id: "gkp_…", id: "light.flashlight" }
gripforge_gamekit_configure { project_id: "gkp_…", id: "light.flashlight",
                              config: { "item": "", "batteryItem": "battery" } }

First example #

The kit has no dedicated test yet; this installs it and sets two of its settings to their defaults.

gripforge_gamekit_install   { project_id: "gkp_…", id: "light.flashlight" }
gripforge_gamekit_configure { project_id: "gkp_…", id: "light.flashlight",
                              config: { "item": "", "batteryItem": "battery" } }

Settings and defaults #

Descriptions come from the kit manifest and stay in English.

SettingTypeDefaultRange or valuesMeaning
itemstring""Item the player must hold to have the flashlight; empty: always carried.
batteryItemstring"battery"Item that recharges it (picked up in the world, used from the bag or swapped in when empty).
batterySecondsnumber1201–36000Seconds of light from a full battery.
batteryChargenumber10–1Charge one battery brings (added to what is left, capped at 1); 1: a battery refills it.
startChargenumber10–1
autoSwapbooleantrueWhen the battery dies and the bag holds a battery, it is swapped in at once.
lowAtnumber0.20–1Below this charge the light flickers, more and more.
rangenumber141–100
anglenumber285–85Half-angle of the beam (degrees).
intensitynumber30–5000
colorstring"#fff1d6"
glownumber0.60–1Light level on the player while it is lit: how visible a lit flashlight makes them.
beamnumber0.80–1Light level at the source of the beam, fading to 0 at its range.
heightnumber1.40–3Height of the lamp above the feet.

Services, events, variables #

  • Service light.flashlight: on(), lit() (on and not flickering out), toggle(on?) → boolean, charge() 0–1, setCharge(v), owned(), reload() → boolean (one battery item), batteries(), lightAt(point) → 0–1.
  • Events emitted:
    • flashlight.toggled (on)
    • flashlight.low (charge) — The charge fell under lowAt: it starts flickering.
    • flashlight.empty — The battery died with no battery to swap in: the light went out.
    • flashlight.recharged (charge, batteries, source) — A battery was put in.
    • flashlight.refused (on, reason) — A tap of the hook flashlight.toggle refused the switch (on: what was asked); the light stays as it was.
  • Events listened to: inventory.used
  • Variables:
    • flashlight.on (boolean) — Flashlight on
    • flashlight.battery (number) — Battery (%)
    • flashlight.batteries (number) — Spare batteries
    • flashlight.flicker (boolean) — Flickering out now
    • flashlight.owned (boolean) — Has the flashlight
  • Verbs of the scripting layer:
    • set_flashlight (action) — Switch the flashlight on or off.
    • charge_flashlight (action) — Set the battery charge (0–1).
    • flashlight_on (condition) — The flashlight is on.
  • Input actions: flashlight

Hooks and modding #

  • Hooks (a game or a mod can intercept them):
    • flashlight.toggle (cancellable) — The light is about to be switched on or off (on: the state asked) by the player (reason input), a set_flashlight action (action) or toggle() (service); charge is the battery (0–1), batteries the…
    • flashlight.recharge (fields a tap may change: amount; cancellable) — A battery is about to be put in: amount is the charge it brings (batteryCharge), added to charge and capped at 1; batteries counts the bag before the battery leaves it.
  • Moddable settings: item, batteryItem, batterySeconds, batteryCharge, startCharge, autoSwap, lowAt, range, angle, intensity, color, glow, beam, height

Engines #

Declared targets: web, rust. gripforge kit api light.flashlight lists the exact settings and services of your version.

Versions #

Kit version 1.1.0.