Module CorsixTH.CorsixTH.Lua.announcer

Creates an announcement queue: a collection of announcements with queue semantics.

Functions

AnnouncementEntry:AnnouncementEntry () Creates an announcement
AnnouncementQueue:checkForDuplicates (sound, date) Checks for duplicates in the announcement queue and refreshes the announcement's created_date
AnnouncementQueue:isEmpty () Returns true if the queue is empty, false otherwise.
AnnouncementQueue:pop () Dequeues the announcement with the highest priority, nil if the queue is empty.
AnnouncementQueue:push (priority, entry) Adds the announcement entry to the queue.
Announcer:Announcer (app) Announces audible messages to the player.
Announcer:_onPlayed (entry) Private function.
Announcer:_play (entry) Private function.
Announcer:_setRandomAnnouncementTarget () Private function.
Announcer:onTick () The announcer's (game) tick handler.
Announcer:playAnnouncement (name, priority, decay_hours, played_callback, played_callback_delay) Requests the announcer to play an announcement.


Functions

AnnouncementEntry:AnnouncementEntry ()
Creates an announcement
AnnouncementQueue:checkForDuplicates (sound, date)
Checks for duplicates in the announcement queue and refreshes the announcement's created_date

Parameters:

  • sound the announcement to check
  • date the date to use, usually the current date
AnnouncementQueue:isEmpty ()
Returns true if the queue is empty, false otherwise.
AnnouncementQueue:pop ()
Dequeues the announcement with the highest priority, nil if the queue is empty.
AnnouncementQueue:push (priority, entry)
Adds the announcement entry to the queue.

Parameters:

  • priority (int) the priority of the announcement
  • entry (AnnouncementEntry) the announcement entry
Announcer:Announcer (app)
Announces audible messages to the player. The announcer plays announcements based on their priority. If the caller requests an announcement to be played, it will be played directly if there are no announcements currently being announced. Note that announcements are only played if there is a worker at the reception desk and announcements are enabled in the settings. Constructor.

Parameters:

  • app (App) The CorsixTH app
Announcer:_onPlayed (entry)
Private function. Handles the playSound completed event. Also calls the callback of the announcement.

Parameters:

  • entry (AnnouncementEntry) The announcement that has been played.
Announcer:_play (entry)
Private function. Plays the actual sound of an announcement.

Parameters:

  • entry (AnnouncementEntry) The announcement to play.
Announcer:_setRandomAnnouncementTarget ()
Private function. Sets the new time (in ticks) when a random announcement should be played.
Announcer:onTick ()
The announcer's (game) tick handler. Plays the actual sound of the announcements, if available. Also queues random announcements if no announcements have been played for a while.
Announcer:playAnnouncement (name, priority, decay_hours, played_callback, played_callback_delay)
Requests the announcer to play an announcement.

Parameters:

  • name (string) The filename to play.
  • priority (int | nil) The priority of the announcement. See AnnouncementPriority.
  • decay_hours (float | nil) After this amount of hours the announcement should be considered irrelevant. Provide nil for a decay time based on the provided priority.
  • played_callback (function | nil) The callback to trigger when the announcement was successfully played.
  • played_callback_delay (int | nil) Delay the callback with this amount of milliseconds.
generated by LDoc TESTING Last updated 2015-01-01 12:00:00