Canvas EFIS framework: Difference between revisions

mNo edit summary
Line 416: Line 416:
|param2text = Vector of message definitions. See below for format.
|param2text = Vector of message definitions. See below for format.
}}
}}
{{caution|Use setSoundPath() before addAuralAlert() or addAuralAlerts().}}
==== setSoundPath() ====
{{Nasal doc
|syntax = setSoundPath(path);
|text = Set aural alert configuration hash
|param1 = path
|param1text = Default path for aural alert audio files.
|example1 =
var sound_dir = getprop("sim/aircraft-dir")~"/Sounds/auralalerts/";
myMessageSystem..setSoundPath(sound_dir);
}}
==== addAuralAlert() ====
{{Nasal doc
|syntax = addAuralAlert(id, filename, volume=1.0, path=nil);
|text = Add a single aural alert.
|param1 = id
|param1text = Name of aural alert referenced in the message definitions or the auralAlert() method.
|param2 = filename
|param2text = Name of the sound file, e.g. "alert.wav"
|param3 = volume
|param3text = Sound volume for this alert, defaults to 1.0
|param4 = path
|param4text = Optional, override default path set with setSoundPath() before(!).
}}
{{note|If you want to store the alerts in a single hash you can pass this to the message system by calling addAuralAlerts(). Note the 's' at the end.}}
{{warning|addAuralAlerts() overwrites any previous alert config. If you want to add single alerts with addAuralAlert() this has to be done after calling addAuralAlerts(). }}


==== addAuralAlerts() ====
==== addAuralAlerts() ====
Line 422: Line 452:
|text = Set aural alert configuration hash
|text = Set aural alert configuration hash
|param1 = alert_hash
|param1 = alert_hash
|param1text = Hash; aural_name: {path: "myAircraft/Sounds", file: "sound.wav", volume: 1.0 }
|param1text = Hash
|example1 =
var sound_dir = getprop("sim/aircraft-dir")~"/Sounds/auralalerts/";
# you can add aural alerts one by one...
myMessageSystem.addAuralAlert("firebell", "firebell.wav");
# ... or you can define everything in one hash and pass it to addAuralAlerts (mind the trailing 's')
var Alerts = {
    overspeed: {path: "/Sounds", file: "overspeed.wav", volume: 1.0 },
    alert1: {file: "sound.wav", volume: 0.8 },
    alert2: "sound2.wav",
};
myMessageSystem.setSoundPath(sound_dir);
myMessageSystem.addAuralAlerts(Alerts);
}}
}}


Line 435: Line 477:
|param3 = visible
|param3 = visible
|param3text = bool; 0 = hide, otherwise show
|param3text = bool; 0 = hide, otherwise show
}}
==== auralAlert() ====
{{Nasal doc
|syntax = auralAlert(id);
|text = Plays an aural alert.
|param1 = id
|param1text = Identifier of the aural alert (see addAuralAlert() ).
}}
}}


Line 554: Line 604:
|param2text = Total number of pages.
|param2text = Total number of pages.
}}
}}


=== Format for message definitions ===
=== Format for message definitions ===
250

edits