Area Display announces the text areas of the map to the players who walk into them. It takes over the textarea area type of the Areas API: while this plugin is loaded, entering a text area shows its text as an area notice instead of the plain text the Areas API draws on its own, so a player never gets both. Entering or leaving a text area runs the PlayerEnteredTextArea and PlayerLeftTextArea hooks.

Staff create text areas with the Text Area mode of the Area Tool, which this plugin replaces with one that also has a display style and a one-time switch. Right clicking inside of an existing text area applies both to it. An area keeps them in its style and once fields, next to its text.

A notice is drawn in a display style. Three come with the plugin: 'fade', a title that fades in and out and is the default; 'typewriter', text that is typed out letter by letter with a quiet sound; and 'cinematic', a caption between the letterbox bars of the Cinematics plugin, which falls back to 'fade' when that plugin is not loaded. More are added with AreaDisplay:register_style.

The same area is not announced again until the 'area_display_cooldown' config has passed. A one-time area is shown to a player only once: the server remembers it in the data table of the player (Player:set_player_data, under 'seen_areas'). Players turn the notices off with the 'area_display' client setting when the Settings plugin is loaded.

The AdjustAreaDisplay hook lets other plugins change a notice before it is shown, for example to put the in-game time into its text. The server shows a notice of its own with AreaDisplay:show, client code with AreaDisplay:add.

The look comes from the theme, which the plugin fills in from its OnThemeLoaded handler: the 'area_display_duration', 'area_display_fade_time', 'area_display_type_interval' and 'area_display_type_volume' options, the 'area_display_text' color, the 'area_display_type' sound and the 'area_display_title' and 'area_display_typewriter' fonts.

Summary

Hooks

Replaces the Text Area mode of the Area Tool with the one of this plugin (see build_tool_mode).
Takes the notices off the screen when the local player turns them off.
Announces the areas that were entered while the HUD was hidden and draws the notices that are on screen.
Sets the options, the color, the sound and the fonts of the area notices on the theme that was loaded.
Announces the text area that the local player has entered.
Announces the text areas the local player is standing in when their client has finished loading.
Forgets the text area that the local player has left, if it was still waiting to be announced.
Registers the 'area_display' client setting, which turns the area notices on and off.

Methods

Shows an area notice to the local player.
Announces an area to the local player.
clear()client
Takes every notice off the screen and forgets the pending areas.
Draws the notices that are on screen and drops the ones that are over.
Returns a display style.
Finds a text area by its ID.
Finds the text area that a position is inside of.
Finds every text area that a position is inside of.
Announces the areas that were entered while the local player could not see notices.
Returns the opacity of a notice at a point in time.
Turns a value into the ID of a registered display style.
Returns every registered display style.
Checks whether a player has already been shown a one-time area.
Checks whether the local player has area notices turned on.
Checks whether a notice can be seen by the local player right now: they are initialized, alive and, when the Characters plugin is loaded, have a character.
Registers a display style: a way of putting an area notice on the screen.
Sets whether a player has already been shown a one-time area.
Shows an area notice to one player, several players or everyone.
Announces a text area to one player, several players or everyone, as if they had just entered it, but regardless of the cooldown and of the area being a one-time one.

Hooks

AreaDisplay:AddAreaToolModes(mode_list)

shared plugins/areadisplay/plugin/sh_plugin.lua:215

Implements hook AddAreaToolModes

Replaces the Text Area mode of the Area Tool with the one of this plugin (see build_tool_mode). The mode is passed through mode_list:Add, which fills in its defaults and merges its convars into the tool, and then takes the place of the first Text Area mode in the list; any other Text Area mode is removed, so that a code refresh does not leave more than one behind. The mode stays at the end of the list if the Areas API has not added its own.

Parameters

  • mode_list Map the Area.tool_modes table; modes are added with mode_list:Add

AreaDisplay:ClientSettingChanged(id, value, _old_value)

client plugins/areadisplay/plugin/cl_hooks.lua:40

Implements hook ClientSettingChanged

Takes the notices off the screen when the local player turns them off.

Parameters

  • id String setting id
  • value Any new value of the setting
  • _old_value Any previous value of the setting

AreaDisplay:FLHUDPaint(cur_time, scrw, scrh)

client plugins/areadisplay/plugin/cl_hooks.lua:52

Implements hook FLHUDPaint

Announces the areas that were entered while the HUD was hidden and draws the notices that are on screen. The hook only runs while the local player is alive and the HUD is shown.

Parameters

  • cur_time Number current CurTime()
  • scrw Number screen width
  • scrh Number screen height

AreaDisplay:OnThemeLoaded(current_theme)

client plugins/areadisplay/plugin/cl_hooks.lua:8

Implements hook OnThemeLoaded

Sets the options, the color, the sound and the fonts of the area notices on the theme that was loaded.

Parameters

  • current_theme ThemeBase

AreaDisplay:PlayerEnteredTextArea(_actor, area, _cur_time)

client plugins/areadisplay/plugin/cl_hooks.lua:80

Implements hook PlayerEnteredTextArea

Announces the text area that the local player has entered.

Parameters

  • _actor Player the player who entered the area
  • area Map the area that was entered
  • _cur_time Number CurTime at the moment of entering

AreaDisplay:PlayerInitialized()

client plugins/areadisplay/plugin/cl_hooks.lua:68

Implements hook PlayerInitialized

Announces the text areas the local player is standing in when their client has finished loading. The Areas API reports an area once, at the moment the player enters it, and for a player who joins inside of one that is before their client is able to receive anything, so the area at the spawn point would never be announced. By the time this hook runs the areas have arrived from the server; the notice is kept as pending until the local player can see it.

AreaDisplay:PlayerLeftTextArea(_actor, area, _cur_time)

client plugins/areadisplay/plugin/cl_hooks.lua:89

Implements hook PlayerLeftTextArea

Forgets the text area that the local player has left, if it was still waiting to be announced.

Parameters

  • _actor Player the player who left the area
  • area Map the area that was left
  • _cur_time Number CurTime at the moment of leaving

AreaDisplay:RegisterClientSettings()

client plugins/areadisplay/plugin/cl_hooks.lua:26

Implements hook RegisterClientSettings

Registers the 'area_display' client setting, which turns the area notices on and off.

Methods

AreaDisplay:add(info, area)

client plugins/areadisplay/plugin/cl_plugin.lua:79

Shows an area notice to the local player. Nothing is shown while the notices are turned off or the local player cannot see them, or when a notice of the same area is on screen.

AreaDisplay:add('City 17')
AreaDisplay:add({ text = 'Sector 7', style = 'typewriter', duration = 4 })

Parameters

  • info String/Map text or language phrase of the notice, or a table with the fields: text, style (ID of a display style, the default style if left out or not registered), color (Color of the text, the 'area_display_text' theme color by default), duration (seconds the notice stays once it has appeared, the 'area_display_duration' theme option by default) and area_id (ID of the area the notice belongs to)
  • area Map optional, defaults to nil the area that is being announced, passed on to the hook

Returns

  • Map the notice, or nil if nothing is shown

See also

AreaDisplay:announce(area, force)

client plugins/areadisplay/plugin/cl_plugin.lua:159

Announces an area to the local player. An area that was announced less than 'area_display_cooldown' seconds ago is skipped. A one-time area is not shown right away: the server is asked first, and shows it if the player has not seen it before. If the local player cannot see notices at the moment, the area is announced once they can, unless they leave it first.

Parameters

  • area Map the area, with the id, text, style and once fields
  • force Boolean optional, defaults to false show the notice regardless of the cooldown and of the area being a one-time one

Returns

  • Boolean true if the notice has been shown, false otherwise

See also

Takes every notice off the screen and forgets the pending areas.

AreaDisplay:draw(cur_time, scrw, scrh)

client plugins/areadisplay/plugin/cl_plugin.lua:244

Draws the notices that are on screen and drops the ones that are over. Notices of the same style are stacked below one another.

Parameters

  • cur_time Number current CurTime()
  • scrw Number screen width
  • scrh Number screen height

AreaDisplay:find_style(id)

shared plugins/areadisplay/plugin/lib/sh_styles.lua:58

Returns a display style.

Parameters

  • id String style ID

Returns

  • Map the style, or nil if it is not registered

AreaDisplay:find_text_area(id)

shared plugins/areadisplay/plugin/sh_plugin.lua:40

Finds a text area by its ID.

Parameters

  • id String area ID

Returns

  • Map the area, or nil if there is no text area with that ID

AreaDisplay:find_text_area_at(pos)

shared plugins/areadisplay/plugin/sh_plugin.lua:88

Finds the text area that a position is inside of.

Parameters

  • pos Vector position to check, 16 units are added to its height as the Areas API does for players

Returns

  • Map the first text area that contains the position, or nil if there is none

See also

AreaDisplay:find_text_areas_at(pos)

shared plugins/areadisplay/plugin/sh_plugin.lua:63

Finds every text area that a position is inside of.

Parameters

  • pos Vector position to check, 16 units are added to its height as the Areas API does for players

Returns

  • List<Map> the text areas that contain the position, empty if there are none

AreaDisplay:flush_pending()

client plugins/areadisplay/plugin/cl_plugin.lua:197

Announces the areas that were entered while the local player could not see notices.

AreaDisplay:get_alpha(display, cur_time)

client plugins/areadisplay/plugin/cl_plugin.lua:221

Returns the opacity of a notice at a point in time.

Parameters

  • display Map the notice
  • cur_time Number CurTime() to get the opacity at

Returns

  • Number opacity from 0 to 255, or nil if the notice is over

AreaDisplay:get_style_id(id)

shared plugins/areadisplay/plugin/lib/sh_styles.lua:71

Turns a value into the ID of a registered display style.

Parameters

  • id Any style ID to check

Returns

  • String the ID if such a style is registered, otherwise the ID of the default style

AreaDisplay:get_styles()

shared plugins/areadisplay/plugin/lib/sh_styles.lua:64

Returns every registered display style.

Returns

  • Map styles keyed by style ID

AreaDisplay:has_seen(actor, area)

server plugins/areadisplay/plugin/sv_plugin.lua:59

Checks whether a player has already been shown a one-time area.

Parameters

  • actor Player
  • area Map the area

Returns

  • Boolean

AreaDisplay:is_enabled()

client plugins/areadisplay/plugin/cl_plugin.lua:42

Checks whether the local player has area notices turned on. They are always on when the Settings plugin is not loaded.

Returns

  • Boolean

AreaDisplay:is_ready()

client plugins/areadisplay/plugin/cl_plugin.lua:53

Checks whether a notice can be seen by the local player right now: they are initialized, alive and, when the Characters plugin is loaded, have a character.

Returns

  • Boolean

AreaDisplay:register_style(id, data)

shared plugins/areadisplay/plugin/lib/sh_styles.lua:44

Registers a display style: a way of putting an area notice on the screen. Register it from shared code, so that the server accepts it from the Area Tool. Registering an ID again replaces the style.

local style = { name = 'my_schema.area_styles.corner' }

if CLIENT then
  function style:draw(display, alpha, scrw, scrh, offset)
    local font = Theme.get_font('text_normal')
    local color = Theme.get_color('text'):alpha(alpha)

    draw.SimpleText(display.text, font, 32, scrh - 64 - offset, color)

    return util.font_size(font)
  end
end

AreaDisplay:register_style('corner', style)

Parameters

  • id String unique style ID, stored in the style field of an area
  • data Map style definition: name (String phrase or text shown in the Area Tool, the ID by default) and the optional clientside functions is_available(style) (return false to have the default style used instead), start(style, display) (called when a notice is about to be shown, may change its fade_in, hold and fade_out times; return false if the style shows the notice by other means and nothing is to be drawn) and draw(style, display, alpha, scrw, scrh, offset) (draws the notice at the given opacity from 0 to 255 and returns the height it took, which is the offset of the next notice of the same style)

Returns

  • Map the registered style, or nil if the arguments are not valid

AreaDisplay:set_seen(actor, area, seen)

server plugins/areadisplay/plugin/sv_plugin.lua:71

Sets whether a player has already been shown a one-time area. It is kept in the data table of the player, which is saved with their database record.

Parameters

  • actor Player
  • area Map the area
  • seen Boolean optional, defaults to true false to have the area shown to the player again

AreaDisplay:show(targets, info)

server plugins/areadisplay/plugin/sv_plugin.lua:29

Shows an area notice to one player, several players or everyone. Clients that have the notices turned off, or whose player cannot see them at the moment, ignore it.

AreaDisplay:show(nil, 'The curfew has begun.')
AreaDisplay:show(target, { text = 'Sector 7', style = 'typewriter', duration = 4 })

Parameters

  • targets Player/List<Player> who to show the notice to; everyone if nil. Players that are not valid any more are left out
  • info String/Map text or language phrase of the notice, or a table with the fields that AreaDisplay:add takes on the client: text, style, color and duration

Returns

  • Boolean true if the notice has been sent, false if it has no text

See also

AreaDisplay:show_area(targets, area)

server plugins/areadisplay/plugin/sv_plugin.lua:47

Announces a text area to one player, several players or everyone, as if they had just entered it, but regardless of the cooldown and of the area being a one-time one.

Parameters

  • targets Player/List<Player> who to announce the area to; everyone if nil. Players that are not valid any more are left out
  • area Map the text area

Returns

  • Boolean true if the request has been sent, false if the area is not valid

Defined in