Skip to content

system.playNumber

since 1.1.0

Play a number using the current locale.

system.playNumber(value[, unit[, decimals[, voice[, priority]]]])

Parameters

Name Type Required Description
value number yes
unit number optional (default is 0)
decimals number optional (default is 0)
voice number optional (default is 0)
priority number optional (default is 0)

Returns

Nothing.

Examples

system.playNumber(11.8, UNIT_VOLT, 1)       -- "eleven point eight volts"
system.playNumber(75, UNIT_PERCENT, 0)      -- "seventy five percent"

-- speak a source with its own unit and precision
local src = system.getSource({ category = CATEGORY_SYSTEM, member = MAIN_VOLTAGE })
if src then system.playNumber(src:value(), src:unit(), src:decimals()) end

Used in

Real-world usage

Called 6 times across 4 open-source Ethos Lua projects. A few short excerpts:
if system.playNumber then
    system.playNumber(announcement, UNIT_PERCENT, 0)

src/dashx/lib/events.lua:152

local function playNumber(value, unit, decimals)
  if system.playNumber then system.playNumber(value, unit, decimals) end
end

src/rfsuite/tasks/audio_events.lua:205

event = function(value)
    ofs3.utils.playFile("events", "alerts/profile.wav")
    system.playNumber(math.floor(value))
end

src/ofs3/lib/events.lua:50