Log inGet started
Package

Sensors.module

README.md

Sensors (module)

The runtime half of sensorBlocks: it puts a sensor look (thermal camera, night vision, x-ray, sonar...) on screen, sends the sonar pings and bright flashes every player shares, and every frame tells the sensor blocks what they need (this machine's goggles state, the live pings, and the players, enemies and pickups near the camera with their roles). Game scripts and sensorGoggles call it.

local Sensors = require("~sensorBlocks.Sensors")

Sensors.use("militaryThermal")                      -- a whole look, your own view only
Sensors.use("thermalIronbow")                       -- or a single block
Sensors.use("gen3NightVision", { shared = true })   -- every player, kept with the scene
Sensors.use("militaryThermal", { settings = { noise = 0.1 } })
Sensors.tune({ palette = 0 })                       -- change settings, keep the look
Sensors.off()                                       -- back to the scene's own look

Sensors.ping(player.position, { range = 40 })       -- a sonar ring, shared
Sensors.flash(grenade.position, 1)                  -- blinds night vision, shared

What it gives

CallWhat it does
Sensors.use(what, opts)what is a look id, a block id or a list of stack entries. Local to this machine by default (styleKit local entries); shared = true puts it on the scene's synced stack, keeping the scene's non-sensor blocks. settings lays settings over every entry.
Sensors.off(opts)Takes this machine's look off; shared = true also takes sensor blocks off the synced stack.
Sensors.tune(settings) / Sensors.current()Change settings of the look on now / which look is on.
Sensors.ping(origin, opts)A ring that ripples out and reveals the world as it passes. opts: speed (30 m/s), range (60 m), kind (0 sonar, 1 echolocation), strength.
Sensors.flash(pos, strength)A muzzle flash, flashbang, flare or lightning. Night vision facing it washes out, never more than 3 full-screen washes a second.
Sensors.setLocal(state) / Sensors.localState()This machine's power, powerStyle, illuminator and gain (sensorGoggles drives these).
Sensors.blocks() / Sensors.looks()Every installed block or look tagged sensor.
Sensors.status() / Sensors.pulses()What it drew last frame / the live pings.
Sensors.ROLE_NUMBERS / Sensors.CONTACT_RULESRoles blocks mark, and the name words used when a game gave none.

Who reads as what

Contacts come from, in order: the scene's players (you, and everyone else as an ally), roles a game gave with StyleRoles.give or StyleKit.give, then entity names (guard, soldier, zombie, monster read as enemy; pickup, loot, ammo, coin, key, medkit as pickup; hazard, mine, trap, laser, camera as hazard; objective, exit, goal as objective).

Known limits

  • At most 32 contacts and 8 pings are drawn, nearest first.
  • Pings and flashes sent before a player joined are not replayed to them.
  • Contact shapes are boxes fitted to bounds when first seen.