HTML Assets for Triggers Tutorial

pware

Trainz Veteran
Disclaimer: I am not an expert on creating HTML assets for Trainz. This tutorial is intended to show how popup messages can be created by triggers. The triggers can be actual trigger objects placed on the track or they can be active industries reporting that their product or raw material levels have reached critical values. The two examples shown in this post are - a popup created by an industry based trigger, and a popup created by a train passing a track trigger.

The examples used in this tutorial will create the displayed messages in the form of web pages. In all cases the HTML (web page) message or messages will be part of a Trainz HTML-Asset which must be created first. You can use an existing HTML-Asset, such as the one created in the first tutorial and simply add the new pages and graphics (if any), or you can create a brand new HTML-Asset. A session can have several HTML-Assets as its dependencies.

This is the second tutorial I have posted on creating HTML assets. The first can be found at http://forums.auran.com/trainz/showthread.php?82205-HTML-asset-for-sessions-tutorial and I would recommend it as a pre-requisite to this tutorial.

TS12 SP1 HF4: Some changes have been made to the operation of these tools in the latest version of TS12. Most are only minor and a few, as yet unexplored, additional features have been added. Notes have been placed on the posts in this thread where such changes have been made to TS12 by N3V.

Peter Ware
 
Last edited:
Creating Industry Triggers

Probably the easiest of the various trigger methods in Trainz is a message produced by an industry when the quantity of its product (or raw material) reaches a critical level.

If you are going to create a new HTML-Asset for your popup messages, then follow the steps shown in this post from the first HTML Asset tutorial at http://forums.auran.com/trainz/showpost.php?p=901563&postcount=2

If you are going to use an existing HTML-Asset for the popup messages, then start Content Manager, select the asset and open it for editing (CTRL-Shift-E)

In either case create the HTML page with the appropriate message for your particular industry and save it inside the open asset window. In the example I will use here, the users task in the session is to clear all the remaining coal from a closed coal mine which has its coal stockpile set at a particular level but no new coal is being added. The popup message will appear when the coal level is ZERO or very close to it.

Trigger01.jpg


As in the first tutorial, I strongly advise against using web authoring tools such as Dreamweaver or even MS Word to create the web page.

If you are using the same HTML-Asset created in the first tutorial then you will NOT need to edit its config.txt file to add this web page. Its string-table will still contain the name of the web page to be displayed as soon as the session starts but the names of web pages displayed by the actions of triggers are not added to the string-table.

If you have created a new HTML-Asset then you will need to edit its config.txt file to add the details of the thumbnail image, and that will be the only change needed. Messages produced by triggers are not entered into the string-table. The config.txt file for this HTML-Asset will look something like ..

Trigger02.jpg


Save the config.txt file, exit Notepad.

The HTML-Asset folder for a brand new HTML-Asset will look something like ..

Trigger03.jpg


Close the folder, select the asset in Content Manager and commit it (CTRL-M). Exit Content Manager.
 
Last edited:
Open your layout in Surveyor mode (I select the Route, click Sessions then select the session and click Edit Session). From the Main Menu select the drop down option Edit Session.

Under Rules in the Session dialogue box click Add. Locate and select the rule Resource Check.

Trigger04.jpg


Select the newly added Resource Check rule and click Edit.

Trigger05.jpg


You will have to identify, from drop down lists ..
1. the name of the industry
2. which of its product queues (there may be only one), and
3. which product (again there may be only one)

.. is to be watched. You must also enter a critical value that will activate the trigger and whether the trigger will be activated by the product queue value equaling and rising above, or falling below the critical value.

Trigger06.jpg


In the screen shot above, the trigger is set to activate if the coal queue of the Cornwall Coal Loader falls below 10 units (a very small quantity - a small wagon load is 16900 units). I could not select a trigger value of 0 because the queue would never fall below 0 - you cannot have a queue that is less than empty (according to my tax officer).

Exit the properties window and return to the Session rules window.
 
Last edited:
Under the rules in the Session dialogue box click Add. Locate and select the Timed limited display HTML rule. This is one of several rules that could be used but I have selected it because it gives you more options and controls than the others.

Trigger07.jpg


After selecting the rule we must make it a "Child Rule" of the Resource Check rule. This means that if the Resource Check rule is activated then its child rules (those rules indented directly beneath it) will also be activated. To make it child rule make sure it is selected then click the right arrow icon just once.

Trigger08.jpg


You can have as many of these trigger rules and their children as you need - each trigger rule should be flush against the left border of the rules window and its children (there can be several) should be right indented just one level directly beneath the rule.

Make sure that the Timed limited display HTML rule is selected and click the Edit button.

Trigger09.jpg


The first 3 items on the list are fairly obvious. Select from the drop down list the name of the HTML-Asset that contains the page you want shown. Next enter the name of the page (without the ".html").

Enter a value for the number of seconds you want your message to be shown. The browser window does have an OFF button so the user can manually switch it off if you leave it on for too long.

The remaining figures are all values, in pixels, that represent screen positions and sizes. "Left position" and "Top position" are the co-ordinates of the top left corner of the browser window measured from the left and top margins of the Trainz screen. The "Browser width" and "Browser height" values are the width and height of the browser display window for your message - the "Browser width" value is the more important of the two.

If you make your browser window height smaller than the actual height of your message then Trainz will automatically add a vertical scrolling tool bar - which may not be an ideal solution if the user has only a few seconds to read the message. However, if you make the browser window width less than the actual width of your message (e.g. you may have a table or an image 500 pixels wide but have made the window only 400 pixels wide) then the message may not be displayed at all.

Below is a sample configuration that I would use for a short text only message.

Trigger10.jpg


If you include a graphic then the browser height would have to be increased. It is all a matter of trial and error.

In TS12 SP1 HF4 the following suggestion no longer works as described. It was probably just a "bug" that has now been fixed but the method described will only display the HTML Startup pages and not any of the HTML pages associated with triggers.

A quick way to test if the size and position of the browser window is correct is to start the session in Driver, press the F7 key and select Toggle session instructions. All the HTML messages in all the HTML-assets loaded into the session will be opened on the screen.
 
Last edited:
Creating Track Triggers

Many layouts use trigger objects (bright green 3D crosses) placed on the track. These triggers can be set to respond to a particular locomotive (e.g. No. 4833), a wagon (e.g. GTX1134), a type of wagon (e.g. any GTX oil tanker) or locomotive (e.g. any NSWGR 48 class), or driver (e.g. Alister regardless of what he is driving). Common responses or actions caused by these track triggers include setting switches and/or signals, activating other trains, or simply posting a message on the screen.

The process starts by placing and naming your triggers throughout the layout. It is important, simply from a management point of view, to use trigger names that are easy to remember and make sense e.g. "Mt Nicholas Trigger" for a trigger placed outside the yard at a location called Mt Nicholas. Complicated or alphanumerical code names may be easier to type but, for my 60 year old brain at least, can cause problems.

Trigger13.jpg


Because these triggers were only going to be used in a single session ("History Tour" - one of three sessions) based on this layout, I created a specific session layer named "History Triggers" in the session to contain all the track triggers. This prevents them from appearing and causing possible issues in the other sessions where they will have no significance. If only one session is to be created from the layout then placing all the triggers in the "route-layer" would also be a satisfactory solution.

Trigger14.jpg


If you are going to create a new HTML-Asset for your popup messages, then follow the steps shown in this post from the first HTML Asset tutorial at http://forums.auran.com/trainz/showp...63&postcount=2

If you are going to use an existing HTML-Asset for the popup messages, then start Content Manager, select the asset and open it for editing (CTRL-Shift-E).

Create each message as a separate web page inside the asset and again take care with selecting consistent names for the .html files. For the page generated by the "Mt Nicholas Trigger" I used "mtnicholas.html" in the screenshot shown below, eliminating spaces in the name.

Trigger11.jpg


There is no need to edit or do anything with the config.txt file except to ensure that it contains the details of the assets thumbnail image.

The contents of the "mtnicholas.html" file is shown below. Once again I recommend against using web page creation software such as Dreamweaver or even MS Word because they create HTML code that is far to complex for Trainz to deal with. Use a basic text editor even though it means you have to type all the tags yourself.

Trigger12.jpg


The page contains a graphic 480 pixels wide and a table 500 pixels wide. The browser window needed to display the page will be set (see post further down) at 600 pixels wide - giving it a margin on both sides as well as a margin for error. The page height will be set at 600 pixels which was basically an educated guess based on the height of the picture (300 pixels) and the quantity of text in the message.

Close and commit the asset. Close Content Manager.
 
Last edited:
Load the session into Surveyor and, from the Main Menu, select Edit Session.

Each trigger has to be entered into the session as a separate rule and page display parent-child pair.

Under Rules in the Session dialogue box click Add. Locate and select the Trigger Check rule.

Trigger15.jpg


This rule will be the Parent part of the parent-child pair so it must be flush up against the left side of the rule box.

Select the newly added Trigger Check rule and click Edit.

Trigger16.jpg


The rule properties window will appear.

Trigger17.jpg


The three check boxes at the top should only be checked ON if you need very precise control over the trigger and you know what you are doing. My advice is that in most situations they are safer left OFF.

Click the link Add Trigger. A list of all the triggers in your loaded layout and session will appear. The list will include signals and other line side objects.

Trigger18.jpg


Select the correct trigger, in this case the one named "Mt Nicholas Trigger". You can have more than one trigger object activating this trigger rule.

Next select the option Accept trains matching specific criteria,

Trigger19.jpg


Scroll down the properties dialogue display window to see the different criteria you can use.

Trigger20.jpg


The three criteria are:
1. specific vehicles - click the plus symbol in the criteria box to bring up a list of all the different rolling stock assets in your current session. The same type of locomotive, for example, may appear several times each with the different name that has been entered into its properties window. You can select more than one vehicle to activate the trigger.

2. types of vehicles - click the plus symbol in the criteria box to bring up a list of all the different types of rolling stock assets in your current session. Each type of locomotive, for example, will only appear once in the list regardless of how many different examples of that locomotive are running in the session. You can select more than one type of vehicle to activate the trigger.

3. drivers - click the plus symbol in the criteria box to bring up a list of all the available drivers in your current session, not just those installed in the Driver Setup rule so you must be careful to select drivers you are actually using. You can select more than one driver to activate the trigger.

In the figure below I have selected just a single specific locomotive to activate the trigger.

Trigger24.jpg


Close the properties window to return to the Rule selection window.
 
Last edited:
In the Rule selection window, click Add then locate and select the Timed limited display HTML rule.

Trigger25.jpg


This is the same rule we used at the start of this tutorial to display a message from a particular industry.

It will become a Child of the trigger rule so select it and right indent it one place.

Trigger26.jpg


While it is selected click Edit.

Trigger27.jpg


Example properties have been entered as shown. Setting the values, particularly for the Browser height, will be a trial and error exercise.

Repeat the above steps - add and configure the Trigger Check parent rule, then add and configure the Timed limited display HTML child rule rule - for all the triggers you have installed in your layout. You will soon see why selecting simple and obvious names for your triggers and their web pages is an important design trick. [This tip no longer works in TS12 SP1 HF4] The quick way to test all your trigger messages is to start the session in Driver, press the F7 key and select Toggle session instructions. All the HTML messages in all the HTML-assets loaded into the session will be opened on the screen.

End of Tutorial 2
 
Last edited:
Pware thank you very much for this useful tutorial.
If i remember correct the first example (Resource Check ) work only once and he don't repeat actions the second, third... times.
We have the lack of informations inside the sessions, this tutorial show the possibilities, but you must admit that this demand a lot of work. My opinion is that HTML pages are clumsy and not suitable for this kind, short quick (blitz) informations.

We have very good solution with sforget's rules, Message Console Rule with
Trigger rule
-MC add Message
Very easy, but with one big problem, when you save the session and return later through 'Resume session', this rules are not show anymore. If author ( or N3V) would be so kind and repair this rules for TS12, then this is the best solution for short informations.

Second solution is
Trigger rule
-Show message rule
Information is shown in Auran's Message window.

I wrote this so that we have more informations about this matter.

regards
celje
 
Last edited:
Celje, thank you very much for your comments and suggestions.

This one, a tutorial on using triggers, was always going to be a tough one. My attempts at using triggers over many years and in many different versions of Trainz has always been an exercise in frustration. As you pointed out, there have always been problems with triggers, trigger rules and message display rules. Lack of knowledge, or even knowing where to find out more, has always been one of the issues.

I decided to restrict myself to only using the rules that were already installed as a normal part of Trainz - even rejecting those available on the DLS. Even then I could not get all of the rules to work.

As you noted there is a set of rules by sforget that may work better than the built in Trainz rules but have the problem of not working in a saved session. Trainz 2006 also had this problem on the display of user instruction pages.

I was not aware that the Resource Check rule only works once, on its first use - but in the situation where I am using it that is not a problem and, in fact, may have been an advantage. And you are right - the whole area of rules and message displays in Trainz does involve a lot of work and a lot of frustration!

At the start of my first tutorial I did mention that using Web pages was not the only way of creating display messages in Trainz. Many creators make use of "string tables" to pass messages to the users screen. I found that this method does have some limitations, specifically adding images and the need to make modifications to the config.txt file - which is always a danger.

Some creators have attempted to overcome some of these limitations by combining string tables with web pages, the ECML Kings Cross to Newcastle route is one example. However the end result, in my opinion, is increased complexity. Since I felt that most Trainz users would be more comfortable with using web pages than manipulating string tables in config.txt files, I decided to go with the web page approach. I may cover string tables at another time.

Your suggested second solution, the Show message rule, involved using a DLS rule, not built in, that was designed for Trainz 2004. I have not tried this rule (and did not know of its existence until you pointed it out) so I cannot confirm that it works on Trainz 2009 and later versions.

Thank you once again for your message. I am always open to suggestions and am more than happy to receive new information.

Peter Ware
 
Last edited:
Hello pware
I'm happy that we start with this theme. A couple of times i tried to encourage N3V to do something about informations inside the session. We don't know what is going on the tracks.
A simple information e.g. TrainX delivered coal to Powerstation is to short for making HTML page, but for me is very valuable, because i get information that deliver succeed and that everything work correct.
As i said sforget's rules are very good because they are simple and efficient
and the second solution ( Trigger rule is builtin, show message rule is made by crid) work without problem in TS12 too. But we know that all this solutions are clumsy, because you must make a seperate command for every trigger and every text. It would be very good if we have somekind of list (similar Inputtable) where all triggers and informations would be together.
With pguy we were talking about this, maybe he will find solution.

Pware. once again, congratulation for both tutorial.

regards
celje
 
Last edited:
Hi Peter,

Thank you so much for taken the time to do this insightful and intelligence tutorials! You have save me, for sure, a lots of time of figuring it all out! I just hope many in the forum feel the same way!

you take care now!!!!

Ish

:p
 
Personally, I prefer to use the Check Trackside rule. This rule allows you to use a trackmark or a junction to fill in for a trigger, and you can also specify whether the train is entering, stopping at, or leaving the trackside object.
 
Hi Peter,

I read the tutorial but I didn't quite get it ...

Display HTML pages using triggers or trackmars, etc .. how is that displayed in the config file, meaning, that if have this:

string-table
{
html-page-0 "mars00.html"
html-page-1 "mars01.html"
html-page-2 "mars02.html"
}

That will displayed at the starte of the session, what would then be the paramenters displayed in the config file to be use with triggers or trackmarks!?

Thanks in advance!
Ishie
 
The names of web pages created for triggers, trackmarks, etc are not added the config.txt file of the HTML asset. You just simply store them as web pages in the asset itself (along with the thumbnail image and config.txt file). Only those pages that will be displayed at the start of a session are added to the string-table of the config.txt file.

Peter Ware
 
The names of web pages created for triggers, trackmarks, etc are not added the config.txt file of the HTML asset. You just simply store them as web pages in the asset itself (along with the thumbnail image and config.txt file). Only those pages that will be displayed at the start of a session are added to the string-table of the config.txt file.

Peter Ware

Hey Peter,

Ok, I get it ... going to experiment to see what happens!!!

Ishie
 
Me again, Peter ... lol

I tried out the Check Trackside rule as someone suggested on this thread, and the time limited Displayed rule as a child, and it worked like a charm!!!:)

However, if you have any other suggestions please let me know.. lol :wave:

Thanks a bunch
Ishie
 
Hi Peter,

Do you know of a rule that can be use to displayed all of the HTML pages, without adding a main rule and a child rule for each html page?
For example, the Check Trackside rule with the time limited Displayed rule works great but I must add it again for each html page, tho!

Thanks in advance for any suggestions!
Ishie

BTW - I gave this thread a 5 star rating ... I am surprise that it wasn't given that before! This is a great thread!!!
 
Last edited:
Do you know of a rule that can be use to displayed all of the HTML pages, without adding a main rule and a child rule for each html page?
For example, the Check Trackside rule with the time limited Displayed rule works great but I must add it again for each html page, tho!

Others have made the same comment - unfortunately there appears to be no solution. But practice makes perfect :)

Peter Ware
 
Ok, thanks, Peter!!

I'll post in the suggestion forum to auran -- maybe something like it can come along with the next version of trainz!

Ishie
 
HTML Assets

Issue Resolved -- see Post Below :B~)

I hope someone can provide helpful insight with my issue:
Yesterday I followed these instructions and created pop-up switching lists for two of my sessions, controlled by the Driver Help button. Yay!
I converted my MSWord table switching lists to PDF, then exported them to JPG and use minimal HTML docs to point to them. They all test right in the Internet browser.
Today I followed the same procedure on two more sessions but all the window displays is a black square at 0,0. Display HTML shows the same. I have tried redoing the image conversion. Same result. When I replaced one switch list with a copy of the asset thumbnail, that displayed correctly. Misery.
The two original sessions still work fine. I've checked and rechecked spelling and punctuation several times, and will again tomorrow, but ?????

:B~(
Bob
 
Last edited:
Back
Top