Log inGet started
Package

arrest.module

README.md

arrest

Being caught, as a staged sequence with hooks, and its bill as an itemised list.

The stages are data (cfg.arrest.stages), each with a name, a duration and what the suspect may do in it:
  breakable + breakHold   the suspect can get free by holding the break input that long, if it has a charge
  skippableAfter          the stage can be ended early by the skip input after that many seconds
  control                 a name for the host's input layer ("break", "skip", "none")
The sequence moves nobody and draws nothing. It calls hooks at every boundary so animation, camera and UI stay
in step with it:

  local Arrest = require("~.modules.arrest")
  local seq = Arrest.new(cfg.arrest, {
      onStage = function(stage, ctx) end,          -- a stage begins: play the animation, cut the camera, show UI
      onStageEnd = function(stage, ctx) end,
      onBreak = function(ctx) end,                 -- the suspect got free
      onDone = function(ctx) end,                  -- the last stage ended
  })
  seq:begin({ charges = 1, by = "w3", level = 2, bill = bill })     -- ctx is passed to every hook
  local status = seq:tick(dt, { breakHeld = false, skip = false })  -- "running" | "broke" | "done" | "idle"
  seq:view()   -- { stage, index, count, time, duration, progress, breakable, breakProgress, canSkip, charges }

The bill is computed by a pure function from rules the game supplies, so the UI shows exactly what is taken:

  local bill = Arrest.bill({
      fine = { base = 40, perLevel = 35, walletShare = 0.5 },   -- min(wallet * share, base + perLevel * level)
      confiscate = { carried = true, vehicle = true, vehicleWithin = 30 },
      strikes = 1, maxStrikes = 3, hours = 2,
  }, { wallet = 180, level = 2, carried = 9, vehicleStock = 40, vehicleDistance = 12, vehicleProtected = false,
       strikes = 0, work = "fish-market wall" })
  -- { lines = { { key = "fine", amount = 90 }, { key = "carried", amount = 9 }, { key = "vehicle", amount = 40 },
  --             { key = "work", name = "fish-market wall" }, { key = "strike", amount = 1, total = 1 },
  --             { key = "hours", amount = 2 } },
  --   fine = 90, carried = 9, vehicle = 40, strikes = 1, hours = 2, work = "fish-market wall" }

The interface is documented in the header of init.luau; this file repeats it for the asset browser.