mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 18:55:03 -04:00
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:
parent
d503db63fd
commit
9c05dd7e40
@ -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
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user