Skip to content
Lohikar edited this page Sep 23, 2017 · 1 revision

Global Listeners are a simple way to maintain global lists of datums grouped by a global ID string. They replace the old Wireless system; new code should use listeners instead of wireless.

Listening

To add a datum to a global listener ID, the target object must create a /listener instance. The object will remain in the list until the listener is qdeleted - delete the listener object to remove the datum from the list. All listener instances associated with an object must be deleted when that object is deleted, or else they may block it from GCing.

Basic Usage:

/obj/mything
	var/listener/listener

/obj/mything/Initialize()
	. = ..()
	listener = new(src, "mythings")

/obj/mything/Destroy()
	QDEL_NULL(listener)
	return ..()

Accessing

To iterate through all objects belonging to a specific ID, use /proc/get_listeners_by_type(id, type). ID must be a string, and type must be /datum or a datum subtype.

Iteration Example:

for (var/thing in get_listeners_by_type("mythings", /obj/mything)
	var/obj/mything/object = thing
	object.do_the_thing()

List Ref Example:

var/list/mythings = get_listeners_by_type("mythings", /obj/mything)

This list is safe to mutate or reuse elsewhere.

Standards and Guidelines

A collection of standards and guidelines applied to the codebase.

Common API Documentation

Documentation regarding common APIs which speed up feature implementation and should be known by all coders.

Less Common APIs

Documentation for less used APIs that are not often needed.

Subsystems

Documentation regarding our implementation of StonedMC (SMC).

Decrepit

Decrepit or unused systems.

  • Dynamic Maps (Not to be confused with the newer away mission implementation.)
Clone this wiki locally