ItemRadio is the base class for radios: items that let the character who keeps one in their hotbar speak and listen on a frequency. A radio can be turned on and off and retuned through its item menu. A derived item may set frequency, the frequency its instances are tuned to until a player changes it (100.1 by default).

Summary

Methods

Asks the player to enter a new frequency for the radio.
Returns the frequency the radio is tuned to.
Checks whether the radio is turned on.
Turns the radio on or off.
Tunes the radio to a frequency and plays the tuning sound.

Methods

ItemRadio:change_frequency(actor)

shared plugins/radios/plugin/items/bases/sh_item_radio.lua:65

Asks the player to enter a new frequency for the radio. Called on the server when the frequency button of the item menu is pressed; the answer is checked by Communications.tune_radio before the radio is retuned.

Parameters

  • actor Player player changing the frequency

Returns the frequency the radio is tuned to.

Returns

  • Number frequency, the item's default or 100.1 if it was never set

Checks whether the radio is turned on.

Returns

  • Boolean whether the radio is enabled, true by default

ItemRadio:on_toggle(_actor)

shared plugins/radios/plugin/items/bases/sh_item_radio.lua:44

Turns the radio on or off.

Parameters

  • _actor Player player toggling the radio

ItemRadio:set_frequency(frequency)

shared plugins/radios/plugin/items/bases/sh_item_radio.lua:56

Tunes the radio to a frequency and plays the tuning sound.

Parameters

  • frequency Number new frequency

Defined in