-
Notifications
You must be signed in to change notification settings - Fork 519
Common Helpers
There exist a large amount of helpers in code which make the writing of functions easier and more consistent. Helpers should be used whenever they are applicable, over hardcoded duplicate code.
These can be found in the code/_macros.dm file and encompass almost every common type you would require.
For humans specifically, isspecies
style helpers exist in code/modules/mob/mob_helpers.dm file. These allow for easy checking of a carbon/human mob's species.
Call | File | Description |
---|---|---|
QDELETED(datum) |
code/__defines/qdel.dm | Macro. Returns TRUE if atom is either null or it's been qdel -d. |
QDEL_NULL(varname) |
code/__defines/qdel.dm | Macro. Invokes qdel(varname) followed by varname = null . |
QDEL_IN(datum, time) |
code/__defines/qdel.dm | Macro. Sets up a timer to invoke qdel(atom) in time deciseconds. It returns the timer's ID, so you can save it for cancellation. |
SOFTREF(datum) |
code/__defines/qdel.dm | Equivalent to "\ref[atom]" . Used to store soft references to objects. Soft-refs do not stop an object from deleting, and thus don't have to be nulled. However, they do have to be checked before use! This is now mostly deprecated and WEAKREF is preferred when possible. |
WEAKREF(datum) |
code/__defines/misc.dm | Fetches a /datum/weakref to this datum/atom, or creates a new one if it does not exist. See the section on WEAKREF in the qdel section of this wiki for more details on weakrefs. |
Call | File | Description |
---|---|---|
/atom/proc/use_check(mob/user, use_flags = 0) |
code/_helpers/unsorted.dm | Used to centralize all sanity checks that could apply for a given source object to validate the user. Applicable values for use_flags can be found in the code for it. |
/proc/GetAbove(atom/atom) |
code/modules/multiz/basic.dm | Returns the turf above atom if it is possible. Namely, if there is a valid Z-level above said atom. Otherwise, returns null . |
/proc/GetBelow(atom/atom) |
code/modules/multiz/basic.dm | Same as GetAbove(atom) , but functions in reverse, returning the applicable turf one Z-level below atom . |
/proc/HasAbove(z) |
code/modules/multiz/basic.dm | Checks if z , a number, has a valid Z-level above it. |
/proc/HasBelow(z) |
code/modules/multiz/basic.dm | Checks if z , a number, has a valid Z-level blow it. |
ROUND_IS_STARTED |
code/__defines/subsystem-defines.dm | Macro. Returns TRUE if the round has been started. FALSE otherwise. |
ADD_VERB_IN(atom, time, verb) |
code/__defines/misc.dm | Macro. Returns a timer which invokes /atom/.proc/add_verb on atom after time amount of time. It'll add verb into the atom.verbs list. |
ADD_VERB_IN_IF(atom, time, verb, callback) |
code/__defines/misc.dm | Macro. Same effect as ADD_VERB_IN with the extra condition that the CALLBACK datum sent as callback returns a non-0 value. |
UNTIL(condition) |
code/__defines/misc.dm | Macro. Invokes stoplag() until the condition evaluates as TRUE . Literally: while(!(condition)) { stoplag(); }
|
RANGE_TURFS(radius, center) |
code/__defines/misc.dm | Macro. A very fast method for returning a list of turfs within radius distances from center . |
DEBUG_REF(atom) |
code/__defines/misc.dm | Macro. Returns a string containing the memory address, name, and type of atom if it exists. "NULL" if it doesn't. |
TICK_CHECK |
code/__defines/misc.dm | Macro. Returns a value indicating if the current proc should yield (sleep() /stoplag() ) to avoid lag. |
CHECK_TICK |
code/__defines/misc.dm | Macro. Invokes stoplag() if necessary. Does not return a value. |
REALTIMEOFDAY |
code/__defines/math_physics.dm | Macro. Returns the world.timeofday with midnight rollover taken into account. |
PROCLOG_WEIRD(text) , PROCLOG(text)
|
code/__defines/misc.dm | Macro. Invokes log_debug("[procname]: [text]") . Note that in certain cases, one or both may not compile. |
A collection of standards and guidelines applied to the codebase.
Documentation regarding common APIs which speed up feature implementation and should be known by all coders.
- Atom Initialization
- Garbage, Queued Deletion, and Destroy
- Callbacks
- Timers
- Lazy Lists
- Overlays
- Processing APIs
- Common Helpers
- Global Listeners
- Singletons
Documentation for less used APIs that are not often needed.
Documentation regarding our implementation of StonedMC (SMC).
Decrepit or unused systems.
- Dynamic Maps (Not to be confused with the newer away mission implementation.)