Placing Signals in Hammer - MagnumMacKivler/trakpak3 GitHub Wiki

Back to Hammer Tutorials

Back to Adding Signals to your Map

PREVIOUS Tutorial: Creating a Signal System with SigEdit | NEXT Tutorial: Place Nodes and Configure Paths

This tutorial will teach you how to do set up signals in Hammer, before finishing the setup in Gmod.

Table of Contents

Introduction

Make Signal Templates

Place the Signals

Place Signal Blocks

Name Everything

Entity Links and Other Keyvalues

Bidirectional Track Controllers

Compile the Map!

Install the Signal System Files

Outro

Introduction

To demonstrate the process of setting up signals, I made a simple test map consisting of a single track mainline that turns into a double track mainline, a junction, and a stub track that won't be signaled (a good example for industries, branch lines, and yards).

Imgur

Make Signal Templates

Spawn an entity and change its class to tp3_signal_master. These "master" signals are associated with the top/main head of your signal installations, and they do all of the computation and communication in Trakpak3.

This first signal is going to act as a template, so you're going to want to set a couple keyvalues before you do anything else.

Imgur

  • Model. Pretty self-explanatory, pick a model that you're probably going to use a lot. I chose models/trakpak3_us/signals/colorlight/ryg.mdl here.
  • Signal System Name. Set this to the name of the signal system you want to use, of course. Setting this now will save you a lot of typing, but be sure to double check the spelling so you don't propagate any errors. In this case, delaware_and_hudson.
  • Signal Type. Set this to the appropriate Signal Type for the model, this should match one of the Signal Types we made in SigEdit. In this case, cl_high.
  • Skin/Bodygroups. If you wanted most of your signals to have a specific, common skin or bodygroup setup, you might as well set it now. Bodygroups and Skins for Trakpak3 signals can be found in the BGAS Guides.
  • Animation Behavior. If the model is animated, and you know what you want, you can set these now. This has no effect on the Color Light signal, but if your map used Semaphores or Banjo signals (which are animated), this would be handy to set.

Leave the rest of the keyvalues alone, for now... especially the name (unless you choose to make Hammer Prefabs with them, in which case go ahead and set it using Prefab Tokens). Setting the rest of the keyvalues later will be easier than changing the keyvalues each time.

If you're going to use a similar mounting system for all your signals, you can add prop_statics for the mast and bracket. The mast used here is models/trakpak3_us/signals/generic/mast_type2c_18ft.mdl and the bracket is models/trakpak3_us/signals/generic/bracket_1_single.mdl. This setup is intended to be duplicated a lot, so feel free to Group them or even make a Hammer Prefab out of them, if desired.

We will call this template the "Home" signal.

Imgur

Next, you'll probably want to make a template for an Automatic Block Signaling (ABS) signal. These are similar to the single-headed signal, except they will have the "abs" tag and will feature a number plate to distinguish it from Home signals. Unlike Home signals, ABS signals can't show a true Stop aspect; they can only show Stop and Proceed, thus allowing a train to pass the signal at restricted speed and follow any trains that might be in the block ahead of them. Start by cloning the first template (shift+drag), then add a tp3_sign_auto entity with the model models/trakpak3_us/signage/speedsign/rect00_standalone.mdl. You can leave all the other keyvalues as default for now.

Imgur

(note the addition of the tag "abs" in the Tags keyvalue.)

Thirdly, make a template for a Junction Signal, with two heads instead of one. Clone the first template you made (the Home signal). Add the tag "adv" to the tp3_signal_master, since this signal will have two heads. Change the model of the bracket to a "double" model (models/trakpak3_us/signals/generic/bracket_1_double.mdl). Then, clone the signal head onto the lower bracket and change its class to tp3_signal_slave. Usually, you shouldn't even need to change any of its keyvalues!

Imgur

One last template for this tutorial, an Approach Signal. An Approach signal is a combination of a Junction Signal and an ABS signal... it has two heads, so it can show Approach Medium and such, but it also has the number plate. The tp3_signal_master should have "abs adv" for the Tags keyvalue.

Imgur

You should be getting the hang of this by now. feel free to make as many signal templates as you want, since you can always hide them with Visgroups and keep them from being put into the final map.

Place the Signals

Clone (shift+drag), copy/paste, or insert as a prefab, do whichever is most natural to you, to place the signals where you want them in the map. My advice to you is to try and place all the signals before setting any more of the keyvalues... this allows you to freely "steal" parts off of other, nearby signals without needing to worry about making sure all the names and what-have-you are correct.

Start with the Junction Signals

You're going to want to start by placing Junction Signals at all the mainline junctions (sometimes called interlockings or control points) where there are two or more paths, or the only path requires medium speed. Those were the ones with two heads, but no number plate.

What constitutes a mainline junction? Not every switch on the mainline needs to be one... in general, if the switch can lead to another mainline, a yard, a branch line, or a very large industry (such as a coal mine or steel mill), it should be treated as a mainline junction. If the switch leads to a small industry, a short siding, or some other track feature that's not signaled ("dark territory") and not expected to have a lot of traffic, you don't necessarily need to put a junction signal in front of it, as long as your ABS signals can display a restrictive indication like Restricting or Stop and Proceed (the Delaware and Hudson ABS signals can!).

Place the Junction Signals as close as possible to the first switch in a junction, but leave a little bit of room (about 128 to 256 units) between it and the start of the switch. Importantly, make sure that the signal can be spotted from a good distance away! Be careful if there are blind curves or obstacles in the way; if an engineer can't see a signal until they're about to pass it, the track speed limit should be reduced.

Here's an example. This junction is pretty simple--a single switch--but both the paths are mainlines, so it's a good place for it.

Imgur

Now, place another 2-headed Junction Signal on the curved side of the switch, since the only path through the junction from there is at Medium speed. Since the top head is always going to be red, I changed the model of it to models/trakpak3_us/signals/colorlight/x.mdl.

The straight side of the switch only needs a 1-headed Home signal, since the only path through the junction is at Full speed.

Imgur

You may notice, when selecting the tp3_signal_master, that there is a white circle in the 2D views, and a purple sphere in the 3D view. This is not the model origin; it's the Cab Signal Pos. When a train equipped with a Cab Signal Box passes over it, it will gather some information about the signal and may even stop the train if it passes an absolute Stop at too great a speed (SPAD). Using the 2D views, drag the white circle onto the tracks, about the height of the railhead, and about 128-256 units in front of the signal. Putting it too close to the signal, or behind it, may cause trains to SPAD even if the signal is clear! You will need to do this for all signals, not just Junction Signals!

Imgur

Here is what a signal installation could look like for the crossover further on down the line. Note the tracks with 2 available paths are governed by 2-headed signals, and the other tracks have 1-headed signals, just like the junction from before.

Imgur

If you have several junctions really close to each other (so close that there's no way an average train would be able to fit in between them), consider combining the two junctions into one and omitting the signals between the switches. I'm only keeping them here for the purposes of the demonstration.

Add Approach Signals

Once all the Junction Signals are placed, you should place the Approach Signals. Approach Signals are used to warn trains in advance of any non-normal route conditions... For example, using the Delaware & Hudson system, if a Junction Signal is showing Medium Clear, the Approach Signal will show Approach Medium, as in, "the next signal is a medium speed signal." Approach Signals should be one block before the Junction Signals... if there are two junctions separated by only one block, Approach Signals are not necessary, since the previous Junction Signal can act as an Approach Signal for the next one.

Signal Blocks should generally be long enough to fit an entire train... the signal system works better with longer blocks! But just so everything can fit into a screenshot, here's an example placement for an Approach Signal:

Imgur

Add ABS Signals

Once all the Approach Signals are placed, you can split up the remainder of the tracks with ABS Signals. Remember the guidance about block lengths and signal visibility from before.

Imgur

Place Signal Blocks

After all the signals have been placed, it's time to place the actual tp3_signal_block entities that the signal system interfaces with. This entity functions like a general purpose track circuit, detecting the presence of trains and translating that to a Boolean true or false state.

Imgur

The actual area the tp3_signal_block governs will be set in Gmod, later... for now, all you need to do is place the entity and configure a keyvalue or two. The Scan Speed keyvalue is of interest here; the signal blocks work by checking individual segments, so shorter/straighter blocks can have fewer segments and can get away with a slower Scan Speed. If you're not sure, it's totally fine to leave them all at "Normal (10/s)".

Place the entities somewhere it can be easily found in Hammer and in Gmod... the most logical place to put them is beside the track it governs.

Imgur

Don't worry about placing signal blocks on/in junctions, for now... most junctions are small enough that it won't be a problem. I'll go into detail on how to set up junctions with signal blocks later on.

Name Everything

Now that all the signals and blocks have been placed, it's finally time to name all the entities you've placed. Why wait until now, you ask? Well...

Imgur

I recommend figuring out a standardized naming scheme to make the process easier... for example, if I've got a part of the map called "area1", I would name the master signals "sig_area1_1", "sig_area1_2", etc. The slave signals would be "sig_area1_1a", "sig_area1_2a", etc. The blocks would be "block_area1_1", "block_area1_2", and so on.

Entity Links and Other Keyvalues

For signals with more than one head, set the tp3_signal_master's Slave Signal 1 and Slave Signal 2 (as applicable) to the tp3_signal_slave(s) on the appropriate mast. The eyedropper button is recommended for this.

For non-Junction Signals, set the Signal Block keyvalue to the tp3_signal_block the signal is meant to monitor, and the Next Signal keyvalue to the next tp3_signal_master after it. You could set these for Junction Signals too, but it's not necessary--that will be set up in Gmod after the map is compiled.

A signal doesn't require a Block or a Next Signal in order to function. Signals at off-map tracks, or signals leading into unsignaled "dark" territory are some examples.

For Junction Signals, there are a couple other tp3_signal_master keyvalues that may be of interest.

  • Starting CTC State. If you intend to set up a dispatch board with your map, you may want to consider changing this keyvalue to "Hold" on Junction signals. The dispatcher has the ability to set certain signals to either Hold a train (displaying a Stop indication regardless of track conditions) or to Allow it to pass, track conditions permitting. Because ABS Signals have no dispatcher control, they must always be set to Allow; with Junction Signals that will be on the dispatch board, however, the mapper can choose to have them default to one state or the other.
  • Interlock Path Switches. This is a safety feature to prevent switches from being changed in front of an oncoming train. If set to "Yes", the signal will lock all the switches in the current path if the CTC State is set to Allow, and release them if set to Hold. If a signal is not meant to be on a dispatch board, this should be set to "No".

Bidirectional Track Controllers

If you are making a map with multi-block stretches of single track, you may be interested in a way to automatically prevent trains from entering the string of blocks at opposite ends and having a "cornfield meet", while still allowing trains moving in the same direction to follow each other. There is an entity that does this! For each string of blocks, spawn one tp3_bidirectional entity.

Imgur

Name the controller if desired. Set "Block 1" to the first tp3_signal_block in a chain, then "Block 2" to the second tp3_signal_block, and so on. If you have more than 8 Blocks, you can add extra keyvalues by turning SmartEdit off, and adding keyvalues named "block_9", "block_10", etc.

Imgur

Next, find the signals that control entry into the string of blocks. This should not be an ABS signal... They should be Junction/Home signals at the last switch before entering the single track. (I added one here just to demonstrate, though in a real map there should be a full block in between it and the first ABS signal). Since this was protecting the entry into "Block 1", we'll call this the "Bottom" of the chain.

Imgur

At the other end, these two signals guard the entrance into the single track. Since they are protecting entry into "Block 4" (the highest number block in the chain), we'll call this the "Top" of the chain.

Imgur

The other two signals which grant entry into the chain are in the middle, so we'll call them the "Middle" signals.

Imgur

Open up the Outputs tab in the tp3_bidirectional entity, and add the following outputs:

For each "Bottom" Signal:

  • OnTopOccupied -> (signal name) -> SetCTC_Hold
  • OnMiddleOccupied -> (signal name) -> SetCTC_Hold
  • OnChainClear -> (signal name) -> SetCTC_Allow

For each "Top" Signal:

  • OnBottomOccupied -> (signal name) -> SetCTC_Hold
  • OnMiddleOccupied -> (signal name) -> SetCTC_Hold
  • OnChainClear -> (signal name) -> SetCTC_Allow

For each "Middle" Signal:

  • OnTopOccupied -> (signal name) -> SetCTC_Hold
  • OnBottomOccupied -> (signal name) -> SetCTC_Hold
  • OnMiddleOccupied -> (signal name) -> SetCTC_Hold
  • OnChainClear -> (signal name) -> SetCTC_Allow

Imgur

So, what does all this do? Let's say a train enters the "Bottom" block. All the signals except for the Bottom ones are set to CTC Hold--in other words, forcing a Stop signal regardless of track conditions. This allows additional trains to follow if they're coming up from the Bottom, but won't let any trains in from the Top or Middle. Once the first train enters the chain, the state of the tp3_bidirectional changes, so the trains can move from block to block without affecting any of the signals, until ALL the blocks are clear. Once that happens, the tp3_bidirectional resets all the signals to CTC Allow again, letting trains enter the chain from any direction once more.

A train entering from the Middle is a special case, and will drop all the entry signals to CTC Hold instead of making an exception.

This system is handy for controlling traffic on maps with no CTC (Dispatch Boards). In real life, the dispatcher would intelligently admit trains into single track so that cornfield meets are avoided.

Compile the Map!

When you're ready, compile the map normally.

Install the Signal System Files

Before we can hop into Gmod and finish up the setup process, there's one last thing we need to do. In order to use the Signal System we made, we have to copy it into a new folder and change its extension. Go into GarrysMod\garrysmod\data\trakpak3\signalsystems and find delaware_and_hudson.txt.

Now open a second window and go into GarrysMod\garrysmod\addons. Make a legacy addon for your map by making a new folder with the map name (the map I used in this example is named "signal_tutorial" so I made a folder called "signal_tutorlal"). Make a subfolder inside that named "lua", then a subfolder inside that named "trakpak3", then a subfolder inside that named "signalsystems", and finally a subfolder inside that named after the map (again, "signal_tutorial" in my example). So you should end up with a folder structure like addons\<mapname>\lua\trakpak3\signalsystems\<mapname>.

Go back to the first window and copy the signal system TXT file (delaware_and_hudson.txt) into the signal_tutorial folder in the second window. Then, change its extension to .lua.

If you're having trouble changing the file extension (or can't even see it), go to the "File" tab on the top left of the window and click "Change folder and search options". Then, go to the "View" tab of the dialog that pops up, and un-check the box labeled "Hide extensions for known file types", then press OK. You should now be able to see (and edit) file extensions. Use this power wisely!

Imgur

Imgur

Remember, a map can use multiple signal systems if desired.

Outro

And that's it for the Hammer setup! The next step is to boot up the map in Gmod, and finish the signal system setup in-game.

⚠️ **GitHub.com Fallback** ⚠️