srctools.fgd

Parse FGD files, used to describe Hammer entities.

class srctools.fgd.ValueTypes

Bases: Enum

Types which can be applied to a KeyValue.

VOID = 'void'
CHOICES = 'choices'
SPAWNFLAGS = 'flags'
STRING = 'string'
BOOL = 'boolean'
INT = 'integer'
FLOAT = 'float'
VEC = 'vector'
ANGLES = 'angle'
TARG_DEST = 'target_destination'

Aliases: ENT_HANDLE, EHANDLE

TARG_DEST_CLASS = 'target_name_or_class'
TARG_SOURCE = 'target_source'
TARG_NPC_CLASS = 'npcclass'
TARG_POINT_CLASS = 'pointentityclass'
TARG_FILTER_NAME = 'filterclass'
TARG_NODE_DEST = 'node_dest'
TARG_NODE_SOURCE = 'node_id'
STR_SCENE = 'scene'
STR_SOUND = 'sound'
STR_PARTICLE = 'particlesystem'
STR_SPRITE = 'sprite'
STR_DECAL = 'decal'
STR_MATERIAL = 'material'
STR_MODEL = 'studio'
STR_VSCRIPT = 'scriptlist'
STR_VSCRIPT_SINGLE = 'script'
ANGLE_NEG_PITCH = 'angle_negative_pitch'
VEC_LINE = 'vecline'
VEC_ORIGIN = 'origin'
VEC_AXIS = 'axis'
COLOR_1 = 'color1'
COLOR_255 = 'color255'
SIDE_LIST = 'sidelist'
INST_FILE = 'instance_file'
INST_VAR_DEF = 'instance_parm'
INST_VAR_REP = 'instance_variable'
EXT_STR_TEXTURE = 'texture'
EXT_VEC_DIRECTION = 'vec_dir'
EXT_VEC_LOCAL = 'vec_local'
EXT_ANGLE_PITCH = 'angle_pitch'
EXT_ANGLES_LOCAL = 'angle_local'
EXT_SOUNDSCAPE = 'soundscape'
has_list

Is this a flag or choices value, and needs a [] list?

valid_for_io

Is this type valid for I/O definitions?

extension

Is this an extension to the format?

is_ent_name

Several types are simply a targetname.

class srctools.fgd.EntityTypes

Bases: Enum

The kind of entity each definition is.

BASE = 'baseclass'

Not an entity, others inherit from this.

POINT = 'pointclass'

Point entity

BRUSH = 'solidclass'

Brush entity. Can’t have a model keyvalue.

ROPES = 'keyframeclass'

Used for move_rope etc

TRACK = 'moveclass'

Used for path_track etc

FILTER = 'filterclass'

Used for filters.

NPC = 'npcclass'

An NPC.

EXTEND = 'extendclass'

Modifies an existing entity entry (Hammer++ extension)

is_point

Return whether this is a point entity.

class srctools.fgd.HelperTypes

Bases: Enum

Types of functions in the entity header.

INHERIT = 'base'
HALF_GRID_SNAP = 'halfgridsnap'
CUBE = 'size'

Sets bounding box of entity, exposed as the size of purple cube

TINT = 'color'
SPHERE = 'sphere'
LINE = 'line'
FRUSTUM = 'frustum'
CYLINDER = 'cylinder'
ORIGIN = 'origin'

Adds circle at an absolute position.

VECLINE = 'vecline'

Draws line to an absolute position.

AXIS = 'axis'

Draws a pair of lines to an absolute position.

BRUSH_SIDES = 'sidelist'

Highlights brush faces.

BOUNDING_BOX_HELPER = 'wirebox'

Displays bounding box from two keyvalues

SWEPT_HULL = 'sweptplayerhull'

Draws the movement of a player-sized bounding box from A to B.

ORIENTED_BBOX = 'obb'

Bounding box oriented to angles.

SPRITE = 'iconsprite'
MODEL = 'studio'
MODEL_PROP = 'studioprop'
MODEL_NEG_PITCH = 'lightprop'

Uses separate pitch keyvalue

ENT_SPRITE = 'sprite'
ENT_INSTANCE = 'instance'
ENT_DECAL = 'decal'
ENT_OVERLAY = 'overlay'
ENT_OVERLAY_WATER = 'overlay_transition'
ENT_LIGHT = 'light'
ENT_LIGHT_CONE = 'lightcone'
ENT_ROPE = 'keyframe'
ENT_TRACK = 'animator'
ENT_BREAKABLE_SURF = 'quadbounds'

Sets the 4 corners on save

ENT_WORLDTEXT = 'worldtext'

Renders 3D text in-world.

ENT_CATAPULT = 'catapult'

Renders trigger_catpault trajectors prediction

ENT_LIGHT_CONE_BLACK_MESA = 'lightconenew'

New helper added in Black Mesa.

EXT_APPLIES_TO = 'appliesto'

Indicates this entity is only available in the given games.

EXT_ORDERBY = 'orderby'

Reorder keyvalues. Args = names in order.

EXT_AUTO_VISGROUP = 'autovis'

Convenience only used in parsing, adds @AutoVisgroup parents for the current entity. ‘Auto’ is implied at the start.

BBOX = 'bbox'

Deprecated, doesn’t exist.

extension

Is this an extension to the format?

class srctools.fgd.AutoVisgroup(name: str, parent: str, ents: set[str] = NOTHING)

Represents one of the autovisgroup options that can be set.

Due to how these are coded into Hammer, our representation is rather strange. We put all the groups into a single dictionary, and on each specify the name of the parent. Note they’re case-sensitive, and can include punctuation.

name: str
parent: str
ents: set[str]
exception srctools.fgd.FGDParseError(
message: str,
file: str | _os.PathLike[str] | None = None,
line: int | None = None,
)

Raised if the FGD contains invalid syntax.

class srctools.fgd.FGD

A FGD set for a game. May be composed of several files.

entities: dict[str, EntityDef]
map_size_min: int
map_size_max: int
mat_exclusions: set[PurePosixPath]
tagged_mat_exclusions: dict[TagsSet, set[PurePosixPath]]
auto_visgroups: dict[str, AutoVisgroup]
snippet_desc: SnippetDict[str]
snippet_choices: SnippetDict[Sequence[Choices]]
snippet_flags: SnippetDict[Sequence[SpawnFlags]]
snippet_input: SnippetDict[tuple[TagsSet, IODef]]
snippet_output: SnippetDict[tuple[TagsSet, IODef]]
snippet_keyvalue: SnippetDict[tuple[TagsSet, KVDef]]
classmethod parse(
file: File[Any] | str,
filesystem: FileSystem[Any] | None = None,
) FGD

Parse an FGD file.

Parameters:
  • file – A :py:class:filesystem.File` representing the file to read, or a file path.

  • filesystem – The system to lookup files in. This is needed to resolve file inclusions. If not passed, file must be a :py:class:filesystem.File` to retrieve this automatically.

apply_bases() None

Fix base values in entities after parsing.

While parsing the classnames may be set as strings, so order in the file doesn’t matter. This fixes them to the real entity objects.

for ... in sorted_ents() Iterator[EntityDef]

Yield all entities in sorted order.

This ensures only all bases for an entity are yielded before the entity. Otherwise, entities are ordered in alphabetical order.

collapse_bases(ignore_aliases: bool = True) None

Collapse all bases into the entities that use them.

This operates in-place, and clears all the base attributes as a result.

export(
file: FileWText | None = None,
*,
label_spawnflags: bool = True,
custom_syntax: bool = True,
old_report: bool = False,
) str | None

Write out the FGD file.

Parameters:
  • file – The file to write to. If None, the contents will be returned instead.

  • label_spawnflags – If set, prepend [X] to each spawnflag name to indicate the numeric value.

  • old_report – If enabled, use the legacy kv(*int) syntax for the ‘report’ flag. This is necessary for HL2’s Hammer.

  • custom_syntax – If disabled, all custom syntax like tags and @resources will be skipped. For tagged values, this can write out duplicate copies from different tags.

parse_file(
filesys: FileSysT,
file: File[FileSysT],
*,
eval_bases: bool = True,
eval_extensions: bool = True,
ignore_unknown_valuetype: bool = False,
encoding: str = 'cp1252',
) None

Parse one file (recursively if needed).

If eval_bases is False, bases will not be computed. This makes it impossible in some cases to evaluate these later, but it can help if it is not required.

classmethod engine_dbase() FGD

Load and return a database of entity keyvalues and I/O.

This can be used to identify the kind of keys present on an entity. If you only need specific entities, use EntityDef.engine_def() instead to avoid needing to fetch all the entities.

class srctools.fgd.EntityDef(
type: EntityTypes,
classname: str = '',
*,
keyvalues: dict[str, dict[TagsSet, KVDef]] = NOTHING,
inputs: dict[str, dict[TagsSet, IODef]] = NOTHING,
outputs: dict[str, dict[TagsSet, IODef]] = NOTHING,
kv_order: list[str] = NOTHING,
bases: list[EntityDef | str] = NOTHING,
helpers: list[Helper] = NOTHING,
desc: str = '',
resources: Sequence[Resource] = (),
is_alias: bool = False,
)

A definition for an entity.

type: EntityTypes

The kind of entity.

classname: str

The classname of this entity, as originally typed.

keyvalues: dict[str, dict[frozenset[str], KVDef]]
inputs: dict[str, dict[frozenset[str], IODef]]
outputs: dict[str, dict[frozenset[str], IODef]]
kv_order: list[str]

Keyvalues have an order. If not present in here, they appear at the end.

bases: list[EntityDef | str]

The parent entity classes defined using base() helpers.

helpers: list[Helper]

All other helpers defined on the entity.

desc: str
kv: _EntityView[KVDef]
inp: _EntityView[IODef]
out: _EntityView[IODef]
resources: Sequence[Resource]

no @resources definition, as opposed to an empty list for an explicit empty resources definition. Use resources_defined() to distinguish between these cases.

is_alias: bool

If set, the aliasof() helper was used. This entity should have 1 base, which this is simply an alternate classname for.

classmethod parse(
fgd: FGD,
tok: Tokenizer,
ent_type: EntityTypes,
eval_bases: bool = True,
eval_extensions: bool = True,
ignore_unknown_valuetype: bool = False,
) None

Parse an entity definition from an FGD file.

The @PointClass etc keyword should already have been read, and is passed as ent_type.

classmethod engine_def(classname: str) EntityDef

Return the specified entity from an internal copy of the Hammer Addons database.

This can be used to identify the kind of keys/inputs/outputs present on an entity, as well as resources the entity requires/Precache()es.

Raises:

KeyError – If the classname is not found in the database.

classmethod engine_classes() Set[str]

Return a set of known entity classnames, from the Hammer Addons database.

resources_defined() bool

Check if any resources were defined for this entity, even if blank.

for ... in get_helpers(
typ: type[HelperT] | str,
tags: frozenset[str] = frozenset({}),
) Iterator[Helper]

Find all helpers with this specific type and tags.

for ... in get_resources(ctx: ~srctools.fgd.ResourceCtx, *, ent: ~srctools.vmf.Entity | None, on_error: ~collections.abc.Callable[[str], object] = <function EntityDef.<lambda>>) Iterator[tuple[FileType, str]]

Recursively fetch all the resources this entity may use, simulating Precache().

Parameters:
  • ent – A specific entity to evaluate against. If not provided, functions will silently be skipped.

  • ctx – Common information about the current map and game configuration. This is passed along to defined entclass functions, and is seperate, so it can be reused for many calls to this function.

  • on_error – If provided, when functions or entities are missing this will be called with the specific error, and raised if it returns an exception type. If not set, lookups are ignored. Most exceptions can be passed directly here to cause that to be raised.

strip_tags(tags: frozenset[str]) None

Strip all tags from this entity, blanking them.

Only values matching the given tags will be kept.

export(
file: FileWText,
label_spawnflags: bool = True,
custom_syntax: bool = True,
old_report: bool = False,
) None

Write the entity out to a FGD file.

See FGD.export() for the meaning of the parameters.

iter_bases() Iterator[EntityDef]

Yield all base entities for this one.

If an entity is repeated, it will only be yielded once.

extend(other: EntityDef) bool

Take another entity definition and extend this definition with its data.

Returns true if any changes are made to the entity.

class srctools.fgd.KVDef(
name: str,
type: ValueTypes | str,
disp_name: str,
default: str = '',
desc: str = '',
val_list: list[tuple[int, str, bool, frozenset[str]]] | list[tuple[str, str, frozenset[str]]] | None = None,
readonly: bool = False,
reportable: bool = False,
editor_only: bool = False,
)

Represents a keyvalue that may be set on entities

If the type is choices or spawnflags, val_list is required: * For choices it’s a list of (value, name, tags) tuples. * For spawnflags it’s a list of (bitflag, name, default, tags) tuples.

name: str
disp_name: str
default: str
desc: str
val_list: list[tuple[int, str, bool, frozenset[str]]] | list[tuple[str, str, frozenset[str]]] | None
readonly: bool

Causes Hammer to prevent this keyvalue from being changed. Doesn’t force the value to the default though.

reportable: bool

If set, this value is shown in the Entity Report list. Usually applied to things like a sprite’s material or a prop’s model.

editor_only: bool

Extension, marks keyvalues which are only used to preview things in Hammer.

property choices_list: list[tuple[str, str, frozenset[str]]]

Check that the keyvalues are CHOICES type, and then return val_list.

This isolates the type ambiguity of the attr.

property flags_list: list[tuple[int, str, bool, frozenset[str]]]

Check that the keyvalues are SPAWNFLAGS type, and then return val_list.

This isolates the type ambiguity of the attr.

copy() KVDef

Create a duplicate of this keyvalue.

for ... in known_options() Iterator[str]

Use the default value and value list to determine values this can be set to.

export(
file: FileWText,
tags: Collection[str] = (),
label_spawnflags: bool = True,
custom_syntax: bool = True,
old_report: bool = False,
) None

Write this back out to a FGD file.

class srctools.fgd.IODef(name: str, type: ValueTypes | str = ValueTypes.VOID, desc: str = '')

Represents an input or output for an entity.

name: str
desc: str
copy() IODef

Create a duplicate of this IODef.

export(
file: FileWText,
io_type: str,
tags: Collection[str] = (),
custom_syntax: bool = True,
) None

Write this back out to a FGD file.

io_type should be “input” or “output”.

class srctools.fgd.EntAttribute

Common base class for IODef and KVDef.

name: str
desc: str
property type: ValueTypes

The type of this field.

Custom types can be set as a string, but will appear as ValueTypes.STRING. To retrieve the custom name, access custom_type.

property custom_type: str | None

If a custom type is specified, return the type name.

class srctools.fgd.Helper(*, tags: frozenset[str] = frozenset({}))

Base class for representing helper() commands in the header of an entity.

These mainly add visual widgets in Hammer’s views for manipulating and previewing keyvalues.

This should not be instantiated, only subclasses in _fgd_helpers.

TYPE: ClassVar[HelperTypes | None] = None
IS_EXTENSION: ClassVar[bool] = False
tags: frozenset[str]
classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse this helper from the given arguments.

The default implementation expects no arguments.

export() list[str]

Produce the argument text to recreate this helper type.

get_resources(entity: EntityDef) Iterable[str]

Return the resources used by this helper.

overrides() Collection[HelperTypes]

Specify which types can be overriden by this.

If any of these helper types are present before this type, they’re redundant and can be removed. For example size() is ignored if a studio() is present after it.

class srctools.fgd.UnknownHelper(name: str, args: list[str], *, tags: frozenset[str] = frozenset({}))

Represents an unknown helper.

This is intended only as a method for roundtripping FGDs with unexpected helpers. If you need to interact with an unknown helper, please file an issue/PR to get it implemented properly.

TYPE: ClassVar[HelperTypes | None] = None
name: str

The name of the helper.

args: list[str]

The raw parameters passed to this helper. This is not stable.

export() list[str]

Produce the argument text to recreate this helper type.

srctools.fgd.match_tags(
search: Container[str],
tags: Collection[str],
) bool

Check if the search constraints satisfy tags.

The search tags should be uppercased.

All !tags or -tags cannot be present, all +tags must be present, and at lest one normal tag must be present (if they are) to pass.

srctools.fgd.validate_tags(tags: ~collections.abc.Collection[str], error: ~collections.abc.Callable[[str], BaseException] = <class 'ValueError'>) frozenset[str]

Check these tags have valid values.

The error exception is raised if invalid.

class srctools.fgd.Resource(
filename: str,
type: FileType = FileType.GENERIC,
tags: frozenset[str] = frozenset({}),
)

Resources used by an entity, with filetype.

If the tags mapping is present, that indicates branch features that should/should not be present. Examples: ‘episodic’ (vs HL2), ‘mapbase’.

filename: str
type: FileType
tags: frozenset[str]
classmethod mdl(
filename: str,
tags: frozenset[str] = frozenset({}),
skinset: Sequence[int] | int = (),
) Resource

Create a resource definition for a model.

Models have an optional filename#1,2,3 suffix to specify which skins are used.

classmethod mat(
filename: str,
tags: frozenset[str] = frozenset({}),
) Resource

Create a resource definition for a material.

classmethod snd(
filename: str,
tags: frozenset[str] = frozenset({}),
) Resource

Create a resource definition for a soundscript.

classmethod part(
filename: str,
tags: frozenset[str] = frozenset({}),
) Resource

Create a resource definition for a particle system.

classmethod weapon_script(
filename: str,
tags: frozenset[str] = frozenset({}),
) Resource

Create a resource definition for a weapon script.

class srctools.fgd.ResourceCtx(tags: ~collections.abc.Iterable[str] = (), fsys: ~srctools.filesys.FileSystem = VirtualFileSystem('<virtual>'), fgd: ~srctools.fgd.FGD | ~collections.abc.Mapping[str, ~srctools.fgd.EntityDef] | ~collections.abc.Callable[[str], ~srctools.fgd.EntityDef] = <bound method EntityDef.engine_def of <class 'srctools.fgd.EntityDef'>>, mapname: str = '', funcs: ~collections.abc.Mapping[str, ~collections.abc.Callable[[~srctools.fgd.ResourceCtx, ~srctools.vmf.Entity], ~collections.abc.Iterator[~srctools.fgd.Resource | ~srctools.vmf.Entity]]] = ...)

Map information passed to FileType.ENTCLASS_FUNC functions.

tags: frozenset[str]
fsys: FileSystem
mapname: str

The BSP/VMF map name, like what is passed to map in-game.

get_entdef: Callable[[str], EntityDef]
class srctools.fgd.Snippet(name: str, source_path: str, source_line: int, value: ValueT_co)

A part of some definition which has been given a name to be reused.

name: str
source_path: str
source_line: int
value: ValueT_co
classmethod lookup_single(
error: Callable[[str], BaseException],
kind: str,
mapping: SnippetLookupDict[T],
key: str,
) T

Locate the one snippet using the specified mapping.

If not found or having multiple, error is used to create the exception to raise, using kind as the snippet type.

classmethod for ... in lookup_multi(
error: Callable[[str], BaseException],
kind: str,
mapping: SnippetLookupDict[T],
key: str,
) Iterator[T]

Locate all snippets with a key using the specified mapping.

If not found, error is used to create the exception to raise, using kind as the snippet type.

classmethod parse(
fgd: FGD,
path: str,
tokeniser: BaseTokenizer,
) None

Parse snippet definitions in a FGD.

class srctools.fgd.HelperAxis(key: str, *, tags: frozenset[str] = frozenset({}))

A helper which draws a line between two points.

key: str
TYPE: ClassVar[HelperTypes | None] = 'axis'
class srctools.fgd.HelperBBox(**kwargs)

Deprecated, implementation for the non-existent bbox() type. Use size() instead.

TYPE: ClassVar[HelperTypes | None] = 'bbox'
class srctools.fgd.HelperBoundingBox(min: str, max: str, *, tags: frozenset[str] = frozenset({}))

Displays bounding box between two keyvalues.

min: str
max: str
TYPE: ClassVar[HelperTypes | None] = 'wirebox'
export() list[str]

Produce the wirebox(min, max) arguments.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse wirebox(min, max)

class srctools.fgd.HelperBreakableSurf(*, tags: frozenset[str] = frozenset({}))

Specialized helper for func_breakable_surf.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'quadbounds'
class srctools.fgd.HelperBrushSides(key: str, *, tags: frozenset[str] = frozenset({}))

Highlights brush faces in a space-sepearated keyvalue.

key: str
TYPE: ClassVar[HelperTypes | None] = 'sidelist'
class srctools.fgd.HelperCylinder(
r: int,
g: int,
b: int,
start_key: str,
start_value: str,
end_key: str | None = None,
end_value: str | None = None,
start_radius: str | None = None,
end_radius: str | None = None,
*,
tags: frozenset[str] = frozenset({}),
)

Helper implementation for cylinder().

Cylinder has the same sort of arguments as line(), plus radii for both positions.

start_radius: str | None
end_radius: str | None
TYPE: ClassVar[HelperTypes | None] = 'cylinder'
export() list[str]

Produce the correct line() arguments.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse cylinder(r g b, start key/value/radius, end key/value/radius).

class srctools.fgd.HelperDecal(*, tags: frozenset[str] = frozenset({}))

Specialized helper for infodecal.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'decal'
class srctools.fgd.HelperEnvSprite(mat: str | None, *, tags: frozenset[str] = frozenset({}))

Variant of iconsprite() specifically for env_sprite.

mat: str | None
TYPE: ClassVar[HelperTypes | None] = 'sprite'
class srctools.fgd.HelperFrustum(
fov: str | float,
near_z: str | float,
far_z: str | float,
color: str | tuple[int, int, int],
pitch_scale: float = 1.0,
*,
tags: frozenset[str] = frozenset({}),
)

Helper for env_projectedtexture visuals.

As an extension, values can be literals as well as key names. This is only natively supported by Vitamin Source, but HammerAddons will generate keyvalues to make this work.

fov: str | float
near_z: str | float
far_z: str | float
color: str | tuple[int, int, int]
pitch_scale: float
TYPE: ClassVar[HelperTypes | None] = 'frustum'
export() list[str]

Export back out frustrum() arguments.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse frustum(fov, near, far, color, pitch_scale).

class srctools.fgd.HelperHalfGridSnap(*, tags: frozenset[str] = frozenset({}))

Helper implementation for halfgridsnap().

This causes the entity to snap to half a grid. This argument doesn’t use () in Valve’s files.

TYPE: ClassVar[HelperTypes | None] = 'halfgridsnap'
class srctools.fgd.HelperInherit(*, tags: frozenset[str] = frozenset({}))

Helper implementation for base().

These specify the base classes for an entity def. This implementation isn’t used, the EntityDef special-cases it.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'base'
class srctools.fgd.HelperInstance(*, tags: frozenset[str] = frozenset({}))

Specialized helper for func_instance.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'instance'
class srctools.fgd.HelperLight(*, tags: frozenset[str] = frozenset({}))

Specialized helper for omnidirectional lights.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'light'
class srctools.fgd.HelperLightSpot(
inner: str,
outer: str,
color: str,
pitch_scale: float,
*,
tags: frozenset[str] = frozenset({}),
)

Specialized helper for displaying spotlight previews.

inner: str
outer: str
color: str
pitch_scale: float
TYPE: ClassVar[HelperTypes | None] = 'lightcone'
export() list[str]

Produce the arguments for lightcone().

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse lightcone(inner, outer, color, pitch_scale).

class srctools.fgd.HelperLine(
r: int,
g: int,
b: int,
start_key: str,
start_value: str,
end_key: str | None = None,
end_value: str | None = None,
*,
tags: frozenset[str] = frozenset({}),
)

Helper implementation for line().

Line has the arguments line(r g b, start_key, start_value, end_key, end_value) It searches for the first entity where ent[start_key] == self[start_value]. If the second pair are present it does the same for those for the other line end.

r: int
g: int
b: int
start_key: str
start_value: str
end_key: str | None
end_value: str | None
TYPE: ClassVar[HelperTypes | None] = 'line'
export() list[str]

Produce the correct line() arguments.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse line(r g b, start_key, start_value, end_key, end_value).

class srctools.fgd.HelperModel(model: str | None, *, tags: frozenset[str] = frozenset({}))

Helper which displays models.

If the model is not provided, the ‘model’ key is used.

model: str | None
TYPE: ClassVar[HelperTypes | None] = 'studio'
export() list[str]

Produce the arguments for iconsprite().

for ... in get_resources(
entity: EntityDef,
) Iterable[str]

studio() uses a single model.

overrides() Collection[HelperTypes]

Avoid some issues where other helpers break this one.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse iconsprite(mat).

class srctools.fgd.HelperModelLight(model: str | None, *, tags: frozenset[str] = frozenset({}))

Special model helper, with inverted pitch.

model: str | None
TYPE: ClassVar[HelperTypes | None] = 'lightprop'
class srctools.fgd.HelperModelProp(model: str | None, *, tags: frozenset[str] = frozenset({}))

Model helper which does not affect the bounding box.

model: str | None
TYPE: ClassVar[HelperTypes | None] = 'studioprop'
class srctools.fgd.HelperOrientedBBox(min: str, max: str, *, tags: frozenset[str] = frozenset({}))

A bounding box oriented to angles.

min: str
max: str
TYPE: ClassVar[HelperTypes | None] = 'obb'
class srctools.fgd.HelperOrigin(key: str, *, tags: frozenset[str] = frozenset({}))

Parse the origin() helper.

key: str
TYPE: ClassVar[HelperTypes | None] = 'origin'
class srctools.fgd.HelperOverlay(*, tags: frozenset[str] = frozenset({}))

Specialized helper for env_overlay.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'overlay'
class srctools.fgd.HelperOverlayTransition(*, tags: frozenset[str] = frozenset({}))

Specialized helper for env_overlay_transition.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'overlay_transition'
class srctools.fgd.HelperRenderColor(r: int, g: int, b: int, *, tags: frozenset[str] = frozenset({}))

Helper implementation for color().

r: int
g: int
b: int
TYPE: ClassVar[HelperTypes | None] = 'color'
export() list[str]

Produce color(R G B).

overrides() Collection[HelperTypes]

Previous ones of these are overridden by this.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse color(R G B).

class srctools.fgd.HelperRope(name_kv: str | None = None, *, tags: frozenset[str] = frozenset({}))

Specialized helper for displaying move_rope and keyframe_rope.

name_kv: str | None
TYPE: ClassVar[HelperTypes | None] = 'keyframe'
export() list[str]

Produce the arguments for keyframe().

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse keyframe(name).

class srctools.fgd.HelperSize(
point1: Vec,
point2: Vec,
tags: frozenset[str] = frozenset({}),
)

Helper implementation for size().

This sets the bbox for the entity.

bbox_min: Vec
bbox_max: Vec
TYPE: ClassVar[HelperTypes | None] = 'size'
export() list[str]

Produce (x1 y1 z1, x2 y2 z2).

overrides() Collection[HelperTypes]

Additional versions of this are not available.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse size(x1 y1 z1, x2 y2 z2).

class srctools.fgd.HelperSphere(
r: int,
g: int,
b: int,
size_key: str,
*,
tags: frozenset[str] = frozenset({}),
)

Helper implementation for sphere().

r: int
g: int
b: int
size_key: str
TYPE: ClassVar[HelperTypes | None] = 'sphere'
export() list[str]

Export the helper.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse sphere(radius, r g b).

class srctools.fgd.HelperSprite(mat: str | None, *, tags: frozenset[str] = frozenset({}))

The sprite helper, for editor icons.

If the material is not provided, the ‘model’ key is used.

mat: str | None
TYPE: ClassVar[HelperTypes | None] = 'iconsprite'
export() list[str]

Produce the arguments for iconsprite().

for ... in get_resources(
entity: EntityDef,
) Iterator[str]

iconsprite() uses a single material.

overrides() Collection[HelperTypes]

Specifies helpers which this makes irrelevant.

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse iconsprite(mat).

class srctools.fgd.HelperSweptPlayerHull(*, tags: frozenset[str] = frozenset({}))

Draws the movement of a player-sized bounding box from A to B.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'sweptplayerhull'
class srctools.fgd.HelperTrack(*, tags: frozenset[str] = frozenset({}))

Specialized helper for path_track-style entities.

This no longer does anything.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'animator'
class srctools.fgd.HelperVecLine(key: str, *, tags: frozenset[str] = frozenset({}))

A variant of line() which draws a line to the entity.

key: str
TYPE: ClassVar[HelperTypes | None] = 'vecline'
class srctools.fgd.HelperWorldText(*, tags: frozenset[str] = frozenset({}))

Specialized helper for point_worldtext.

tags: frozenset[str]
TYPE: ClassVar[HelperTypes | None] = 'worldtext'
class srctools.fgd.HelperExtAppliesTo(applies: list[str] = NOTHING, *, tags: frozenset[str] = frozenset({}))

Allows specifying “tags” to indicate an entity is only used in certain games.

applies: list[str]
IS_EXTENSION: ClassVar[bool] = True
TYPE: ClassVar[HelperTypes | None] = 'appliesto'
export() list[str]

Produce the arguments for appliesto().

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse appliesto(tag1, tag2).

class srctools.fgd.HelperExtAutoVisgroups(path: list[str] = NOTHING, *, tags: frozenset[str] = frozenset({}))

Convenience for parsing, adds @AutoVisgroups to entities.

‘Auto’ is implied at the start.

path: list[str]
IS_EXTENSION: ClassVar[bool] = True
TYPE: ClassVar[HelperTypes | None] = 'autovis'
export() list[str]

Produce the arguments for autovis().

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse autovis(group1, group2).

class srctools.fgd.HelperExtOrderBy(order: list[str] = NOTHING, *, tags: frozenset[str] = frozenset({}))

Reorder keyvalues. Args = names in order.

order: list[str]
IS_EXTENSION: ClassVar[bool] = True
TYPE: ClassVar[HelperTypes | None] = 'orderby'
export() list[str]

Produce the arguments for orderby().

classmethod parse(args: list[str], tags: frozenset[str]) Self

Parse orderby(key1, key2).

class srctools.fgd.HelperExtCatapult(*, tags: frozenset[str] = frozenset({}))

Specialized helper for trigger_catapult, in Hammer++.

TYPE: ClassVar[HelperTypes | None] = 'catapult'