Ladrilho: Block Puzzle
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 ononChangeto update the number.- Words:
locales/en/playingnow.jsonandlocales/pt-BR/playingnow.json, with plural forms; a world restates any key underplayingnow.<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/onDisconnectand every 5 s (fromNow.tick(dt), which a game calls from its own update, or which the module drives fromtask.delaywhen no one ticks it). Nothing is built per frame.
Made for Ladrilho: Block Puzzle (world 70616641-b82e-4afa-b1a4-7c99bc16c554).