Added computer.bell() method to trigger the audible bell, automatically triggered when a string containing \a is processed by term.write(), closes #75.

Bumped version number.
This commit is contained in:
Florian Nücke 2014-04-23 13:19:58 +02:00
parent d503db63fd
commit 9c05dd7e40
4 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,6 @@
minecraft.version=1.6.4
forge.version=9.11.1.964
oc.version=1.2.7
oc.version=1.2.8
ccl.version=1.0.0.62
fmp.version=1.0.0.250
maven.url=file:///var/www/users/fnuecke/maven.cil.li

View File

@ -394,6 +394,10 @@ local libcomputer = {
return table.unpack(signal, 1, signal.n)
end
until computer.uptime() >= deadline
end,
bell = function()
libcomponent.invoke(computer.address(), "bell")
end
}

View File

@ -1,4 +1,5 @@
local component = require("component")
local computer = require("computer")
local event = require("event")
local keyboard = require("keyboard")
local text = require("text")
@ -331,6 +332,13 @@ function term.write(value, wrap)
if unicode.len(value) == 0 then
return
end
do
local noBell = value:gsub("\a", "")
if #noBell ~= #value then
value = noBell
computer.bell()
end
end
value = text.detab(value)
local w, h = component.gpu.getResolution()
if not w then

View File

@ -277,6 +277,12 @@ class Machine(val owner: Owner, val rom: Option[ManagedEnvironment], constructor
def isRunning(context: Context, args: Arguments): Array[AnyRef] =
result(isRunning)
@Callback(doc = """function() -- Plays a tone, useful to alert users via audible feedback.""")
def bell(context: Context, args: Arguments): Array[AnyRef] = {
owner.world.playSoundEffect(owner.x + 0.5, owner.y + 0.5, owner.z + 0.5, "note.harp", 1, 1)
null
}
// ----------------------------------------------------------------------- //
override val canUpdate = true