Log inGet started
Package

playingNow.package

Newest version

README.md

playingNow

"N playing now" for any world: how many people are in this world right now, as a number, an event and a ready chip widget. Every visitor of a world shares its presence roster (world.connectedUsers), so the count is everyone here, whatever screen they are on. Agents working in the world are left out.

local Now = require("playingNow.playingNow")

Now.count()                 -- 3 (people, never agents; at least 1 once you are here)
Now.onChange(function(n) print(n) end)   -- returns a handle with :Disconnect()
Now.text()                  -- i18n.text value: "3 playing now" / "3 jogando agora", "Only you right now" / "Só você agora"
Now.chip({ color = "#1f3a68", background = "#fff6e6", dot = "#2fa35a", fontSize = 15, id = "now" })  -- a widget node
  • Now.chip(opts) is a small rounded pill with a pulsing live dot and the text. It follows the language on screen by itself (i18n.text). Redraw your screen on onChange to update the number.
  • Words: locales/en/playingnow.json and locales/pt-BR/playingnow.json, with plural forms; a world restates any key under playingnow.<key> in its own catalogs to change it. pt-BR lines are drafts awaiting review (locales/pt-BR/playingnow.review.json).
  • Cost: the roster is read on onConnect / onDisconnect and every 5 s (from Now.tick(dt), which a game calls from its own update, or which the module drives from task.delay when no one ticks it). Nothing is built per frame.

Made for Ladrilho: Block Puzzle (world 70616641-b82e-4afa-b1a4-7c99bc16c554).