Using the FASTDMM_PROP macro, FastDMM2-sepecific properties and macros can be specified in the code. They are different from regular proc variables in the sense that their values are not evaluated until used - for example, set_instance_vars
, which allows you to set the variables of an object instance when the instance is placed or modified, allows you to use variables from the object to dynamically set the value.
To use FASTDMM_PROP, somewhere in the codebase there needs to be a #define statement to remove FASTDMM_PROP so that a regular BYOND compiler does not error on it:
#ifndef FASTDMM
#define FASTDMM_PROP(props...)
#endif
To use properties and macros, use the following syntax:
/obj
FASTDMM_PROP(\
pinned_vars = list("dir"), /* This is a property*/\
set_instance_vars( /*This is a macro*/\
dir = (dir == SOUTH ? INSTANCE_VAR_DEFAULT : dir)\
)\
)
Note the \ at the end of each line - the BYOND compiler error if they are not included.
The difference between a property and a macro has to do with object inheritance - when a property is inherited, anything previously specified in a parent property is wiped and the new one replaces the old one. When a macro is inherited, instead whatever is set could possibly be merged. In addition, some macros can be used multiple times on one type.
The following built-in BYOND procs can be used:
abs
arccos
arcsin
arctan
ascii2text
ckey
ckeyEx
clamp
copytext
cos
length
list
matrix
newlist
text2num
rgb
round
sin
sqrt
tan
text2ascii
Here is a list of properties and macros:
Sets the number of dirs the object can have. Can be either 0
, 1
, 4
, or 8
. The default is 0
which looks at the icon
and icon_state
and uses the metadata in the .dmi file to figure out the number of dirs available.
Prevents modifications to any vars except the specified ones. Any existing modifications to these vars are reverted.
Example:
/obj/structure/cable
FASTDMM_PROP(\
instance_var_whitelist = list("icon_state")\
)
Causes the listed variables to be displayed at the top of the variable list when using View Variables. Use for commonly-modified variables that get edited often.
Example:
/obj/machinery/door/airlock
FASTDMM_PROP(\
pinned_vars = list("req_access_txt", "req_one_access_txt", "name")\
)
Defines what kinds of pipes should connect to each other.
/obj/machinery/atmospherics/pipe/simple
FASTDMM_PROP(\
pipe_group = "atmos-[piping_layer]-[pipe_color]",\
pipe_interference_group = "atmos-[piping_layer]",\
pipe_type = PIPE_TYPE_SIMPLE\
)
Defines what kinds of pipes interfere with each other. Can be a list. Note that this does not share names at all with pipe_group
. If two pipes have matching pipe_interference_group
but not matching pipe_group
they will be considered interfering, and the astar algorithm will not allow that path.
/obj/machinery/atmospherics/pipe/simple
FASTDMM_PROP(\
pipe_interference_group = "atmos-[piping_layer]"\
)
/obj/machinery/atmospherics/pipe/layer_manifold
FASTDMM_PROP(\
pipe_interference_group = list("atmos-1", "atmos-2", "atmos-3")\
)
Defines how the pipe connects to other pipes. The following symbols are supported:
PIPE_TYPE_SIMPLE
- Ifdir
is cardinal, the pipe connects in that direction, and in the opposite direction. Otherwise, it points to the two dirs that make updir
- for example ifdir
isNORTHWEST
it will connect toNORTH
andWEST
PIPE_TYPE_STRAIGHT
- The pipe connects todir
, and in the opposite direction.PIPE_TYPE_MANIFOLD
- The pipe connects to all dirs exceptdir
PIPE_TYPE_MANIFOLD4W
- The pipe connects to all dirs.PIPE_TYPE_NODE
- The pipe connects only todir
PIPE_TYPE_CABLE
- Uses theicon_state
, in the formatdir1-dir2
to determine which dirs the pipe connects to, and does manifolds by putting multiple on the same tile.PIPE_TYPE_AUTO
- The pipe connects to all dirs, and consists only of this type.
Defines the cost to pass pipes through this tile. Defaults to 1
for turfs and 0
for everything else. Used to encourage taking other paths.
/turf/closed/wall
FASTDMM_PROP(\
pipe_astar_cost = 10\
)
When a new instance of this is created in the map editor, or when the variables are modified through View Variables (or other tools that affect variables), or on map-load, the variables will be updated according to what is specified in the macro.
The following symbols can be used in this context:
INSTANCE_VAR_DEFAULT
- Causes the property to be removed from the instance, causing the default value to be used.INSTANCE_VAR_KEEP
- Keeps the original property if overridden in the instance, with no modification. Similar to using the var, except it leaves the var as default if it's not specified in the instance.
Example:
/obj/machinery/power/apc
FASTDMM_PROP(\
set_instance_vars(\
pixel_x = dir == EAST ? 24 : (dir == WEST ? -24 : INSTANCE_VAR_DEFAULT),\
pixel_y = dir == NORTH ? 24 : (dir == SOUTH ? -24 : INSTANCE_VAR_DEFAULT)\
)\
)