This article's documentation is for anything that uses the Source engine. Click here for more information.

Func train: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(13 intermediate revisions by 11 users not shown)
Line 1: Line 1:
{{ent not in fgd}}
{{LanguageBar}}
{{HL_series_point|func_train}} It is a used leftover from Quake that ping-pongs between the start and end of its path. In GoldSrc, it is primarily used for looping auto-scrolling backgrounds. In Source, it has been superseded in usability with the introduction of parenting of entities, rendering it obsolete but still functional.
{{back|Trains}}
{{TabsBar|main=gs|base=func_train}}
{{Ent not in fgd}}
{{CD|CFuncTrain|file1=1}}
{{This is a|brush entity|name=func_train}}


==Entity Description==
It is a leftover from {{Quake|2}} that ping-pongs between the start and end of a series of [[path_corner]]s. It was mostly replaced by {{ent|func_tracktrain}} in {{gldsrc|2}}, but was still used for looping auto-scrolling backgrounds. In Source, the introduction of parenting has rendered this method obsolete{{how}}. However, the entity is still functional.
===FGD Code===
 
<pre>@SolidClass base(Targetname, Origin, RenderFields) = func_train
{{tip|This entity is not affected by the turning inaccuracy issues that <code>func_tracktrain</code> is, making it a good alternative for fast-moving objects.}}
{{bug|It will always try to play sounds, regardless of whether they are actually specified. This can be set to <code>Default.Null</code> with a volume of 0 to play no sound.}}
 
== Keyvalues ==
{{Brush rendering note}}
 
{{KV Targetname}}
{{KV|Spawn path_corner|intn=target|target_destination|The name of the first path_corner in the train's path. The train will spawn at this path_corner.}}
{{KV|Speed|intn=speed|float|Speed at which the train moves.}}
{{KV|Movement Sound|intn=noise1|string|The sound to play when the train moves.}}
{{KV|Stop Sound|intn=noise2|string|The sound to play when the train stops moving.}}
{{KV|Sound Volume (0-10)|intn=volume|float|Volume of the sounds emitted when moving and stopping.}}
{{KV|Crush Damage|intn=dmg|float|Amount of damage to deal to entities blocking the train.}}
 
== Flags ==
{{fl|8|Non-solid}}
 
== Inputs ==
{{I|Toggle|Toggle movement}}
{{I|Start|Start movement}}
{{I|Stop|Stop movement}}
 
 
== FGD Code ==
<!--Editor's note: TexFrameIndex exists on every brush entity, so I'm not sure why it was specifically included here. It should be in KVBaseEntity if anything.-->
<pre>
@SolidClass base(Targetname, Origin, RenderFields) line(255 255 0, targetname, target) = func_train: "An old entity leftover from Quake. It follows a series of path_corner entities."
[
[
spawnflags(flags) =
spawnflags(flags) {{=}}
[
[
8 : "Non-solid" : 0
8 : "Non-solid" : 0
]
]
texframeindex(integer) : "Initial Brush Frame Index" : : "Use this to set the initial frame of materials with multiple frames in the brush"
target(target_destination) : "Spawn path_corner" : : "The name of the first path_corner in the train's path. The train will spawn at this path_corner."
target(target_destination) : "First path_corner"
speed(float) : "Speed" : "50" : "Speed at which the train moves."
noise1(sound) : "Movement Sound" : : "The sound to play when the train moves."
noise1(sound) : "Movement Sound" : "Default.Null" : "The sound to play when the train moves. This must be specified, but can be set to 'Default.Null' to play no sound."
noise2(sound) : "Stop Sound" : : "The sound to play when the train stops moving."
noise2(sound) : "Stop Sound" : "Default.Null" : "The sound to play when the train stops moving. This must be specified, but can be set to 'Default.Null' to play no sound."
speed(float) : "Speed" : "50.000000" : "Speed at which the brush moves."
volume(float) : "Sound volume (0-10)" : "10" : "Volume of the sounds emitted when moving and stopping."
volume(float) : "Sound volume [0.0, 10.0]" : "0.000000"
dmg(float) : "Crush Damage" : "0" : "Amount of damage to deal to entities blocking the train."
dmg(float) : "Crush Damage" : "0.000000"
 
// Inputs
input Toggle(void) : "Toggle movement"
input Toggle(void) : "Toggle movement"
input Start(void) : "Start movement"
input Start(void) : "Start movement"
input Stop(void) : "Stop movement"
input Stop(void) : "Stop movement"
input Use(void) : "Toggle movement - has a different functionality than Toggle"
]
]</pre>
</pre>
==Keyvalues==
*{{KV Targetname}}
*{{KV Origin}}
*{{KV RenderFields}}
* '''texframeindex'''
: <integer> Use this to set the initial frame of materials with multiple frames in the brush
* '''target'''
: <target_destination> First path_corner
* '''noise1'''
: <sound> The sound to play when the train moves.
* '''noise2'''
: <sound> The sound to play when the train stops moving.
* '''speed'''
: <float> Speed at which the brush moves.
* '''volume'''
: <float> Sound volume 0.0 to 10.0
* '''dmg'''
: <float> Crush Damage
==Flags==
*8 : Non-solid
==Inputs==
*{{I Targetname}}
*{{I RenderFields}}
* '''Toggle'''
: Toggle movement between start and stop
* '''Start'''
: Start movement
* '''Stop'''
: Stop movement
* '''Use'''
: Toggle movement - the train will move only when the input is triggered.
 
==Outputs==
*{{O Targetname}}
[[Category:Entities]]

Latest revision as of 22:25, 3 May 2025

English (en)Translate (Translate)
Trains
Icon-NotInFGD.png
This entity is not in the FGD by default.
See below for instructions on making it available.
C++ Class hierarchy
CFuncTrain
CBasePlatTrain
CBaseToggle
CBaseEntity
C++ trains.cpp

func_train is a brush entity available in all Source Source games.

It is a leftover from Quake Quake that ping-pongs between the start and end of a series of path_corners. It was mostly replaced by func_tracktrain in GoldSrc GoldSrc, but was still used for looping auto-scrolling backgrounds. In Source, the introduction of parenting has rendered this method obsolete[How?]. However, the entity is still functional.

Tip.pngTip:This entity is not affected by the turning inaccuracy issues that func_tracktrain is, making it a good alternative for fast-moving objects.
Icon-Bug.pngBug:It will always try to play sounds, regardless of whether they are actually specified. This can be set to Default.Null with a volume of 0 to play no sound.  [todo tested in ?]

Keyvalues

Note.pngNote:For Keyvalues and Inputs affecting brush rendering, see Brush entity/Rendering related keyvalues and inputs


Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Spawn path_corner (target) <targetname>
The name of the first path_corner in the train's path. The train will spawn at this path_corner.
Speed (speed) <float>
Speed at which the train moves.
Movement Sound (noise1) <string>
The sound to play when the train moves.
Stop Sound (noise2) <string>
The sound to play when the train stops moving.
Sound Volume (0-10) (volume) <float>
Volume of the sounds emitted when moving and stopping.
Crush Damage (dmg) <float>
Amount of damage to deal to entities blocking the train.

Flags

Non-solid : [8]

Inputs

Toggle
Toggle movement
Start
Start movement
Stop
Stop movement


FGD Code

@SolidClass base(Targetname, Origin, RenderFields) line(255 255 0, targetname, target) = func_train: "An old entity leftover from Quake. It follows a series of path_corner entities."
[
	spawnflags(flags) {{=}}
	[
		8 : "Non-solid" : 0
	]
	target(target_destination) : "Spawn path_corner" : : "The name of the first path_corner in the train's path. The train will spawn at this path_corner."
	speed(float) : "Speed" : "50" : "Speed at which the train moves."
	noise1(sound) : "Movement Sound" : "Default.Null" : "The sound to play when the train moves. This must be specified, but can be set to 'Default.Null' to play no sound."
	noise2(sound) : "Stop Sound" : "Default.Null" : "The sound to play when the train stops moving. This must be specified, but can be set to 'Default.Null' to play no sound."
	volume(float) : "Sound volume (0-10)" : "10" : "Volume of the sounds emitted when moving and stopping."
	dmg(float) : "Crush Damage" : "0" : "Amount of damage to deal to entities blocking the train."

	// Inputs
	input Toggle(void) : "Toggle movement"
	input Start(void) : "Start movement"
	input Stop(void) : "Stop movement"
]