<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.trainzsimulator.com/index.php?action=history&amp;feed=atom&amp;title=New_TrainzScript_Features_-_TS2009</id>
	<title>New TrainzScript Features - TS2009 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.trainzsimulator.com/index.php?action=history&amp;feed=atom&amp;title=New_TrainzScript_Features_-_TS2009"/>
	<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;action=history"/>
	<updated>2026-11-05T09:27:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=11693&amp;oldid=prev</id>
		<title>Tonyhilliam: Tonyhilliam moved page New TrainzScript Features to New TrainzScript Features - TS2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=11693&amp;oldid=prev"/>
		<updated>2018-03-14T01:47:09Z</updated>

		<summary type="html">&lt;p&gt;Tonyhilliam moved page &lt;a href=&quot;/wiki/New_TrainzScript_Features&quot; class=&quot;mw-redirect&quot; title=&quot;New TrainzScript Features&quot;&gt;New TrainzScript Features&lt;/a&gt; to &lt;a href=&quot;/wiki/New_TrainzScript_Features_-_TS2009&quot; title=&quot;New TrainzScript Features - TS2009&quot;&gt;New TrainzScript Features - TS2009&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 01:47, 14 March 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Tonyhilliam</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=1687&amp;oldid=prev</id>
		<title>Marinus: /* Global script context */</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=1687&amp;oldid=prev"/>
		<updated>2010-10-31T00:32:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Global script context&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:32, 31 October 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  always-load-in-global-context 1&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  always-load-in-global-context 1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If a library is shared between assets, it is important to be aware in which context the library is loaded. If &#039;&#039;always-load-in-global-context&#039;&#039; is not used, assets running in &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local (active module) &lt;/del&gt;context will access an instance of the library also running in &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local &lt;/del&gt;context. Assets running in global context however access an instance of the library in global context. In other words, there are two parallel instances of the ibrary. To prevent this situation the &#039;&#039;always-load-in-global-context&#039;&#039; tag forces the library to only load once (in global context). The library resisting in global context is then available to other assets in &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local &lt;/del&gt;and global context.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If a library is shared between assets, it is important to be aware in which context the library is loaded&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. A script running in a gameplay context can make calls to a Library in the global context. The reverse is not possible&lt;/ins&gt;. If &#039;&#039;always-load-in-global-context&#039;&#039; is not used, assets running in &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;gameplay  &lt;/ins&gt;context will access an instance of the library also running in &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;gameplay &lt;/ins&gt;context. Assets running in global context however access an instance of the library in global context. In other words, there are two parallel instances of the ibrary. To prevent this situation the &#039;&#039;always-load-in-global-context&#039;&#039; tag forces the library to only load once (in global context). The library resisting in global context is then available to other assets in &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;gameplay &lt;/ins&gt;and global context.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;CAUTION:&amp;#039;&amp;#039;&amp;#039; there are some pitfalls when passing data between objects in different contexts. No references to objects of another context can be stored as members. This means you must make a copy of every &amp;#039;&amp;#039;reference&amp;#039;&amp;#039; type (e.g. strings and arrays) you want to store in another context. In other words, you need to extract any relevant details during the cross-context call and keep copies. [[Types#string|Strings]] are copied using [[class Str#CloneString|Str.CloneString()]] and [[Types#Array|arrays]] can be copied using the [[Arrays#copy|copy()]] operator. There are also possible limitations to cross context message passing, sniffing, etc.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;CAUTION:&amp;#039;&amp;#039;&amp;#039; there are some pitfalls when passing data between objects in different contexts. No references to objects of another context can be stored as members. This means you must make a copy of every &amp;#039;&amp;#039;reference&amp;#039;&amp;#039; type (e.g. strings and arrays) you want to store in another context. In other words, you need to extract any relevant details during the cross-context call and keep copies. [[Types#string|Strings]] are copied using [[class Str#CloneString|Str.CloneString()]] and [[Types#Array|arrays]] can be copied using the [[Arrays#copy|copy()]] operator. There are also possible limitations to cross context message passing, sniffing, etc.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Marinus</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=1686&amp;oldid=prev</id>
		<title>Marinus: /* Global script context */  - added always-load-in-global-context information</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=1686&amp;oldid=prev"/>
		<updated>2010-10-31T00:20:12Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Global script context: &lt;/span&gt;  - added always-load-in-global-context information&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:20, 31 October 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l16&quot;&gt;Line 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The global VM is responsible for global settings libraries, menubar interface addons, etc. and does not have access to the World. It persists until Trainz exits.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The global VM is responsible for global settings libraries, menubar interface addons, etc. and does not have access to the World. It persists until Trainz exits.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The active module VM is responsible for maintaining the session, route, and gameplay aspects and does not persist beyond the lifetime of the module.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* The active module VM is responsible for maintaining the session, route, and gameplay aspects and does not persist beyond the lifetime of the module.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[KIND Library|Libraries]] can be forced to always load in the global script context using a config.txt tag&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; always-load-in-global-context 1&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;If a library is shared between assets, it is important to be aware in which context the library is loaded. If &#039;&#039;always-load-in-global-context&#039;&#039; is not used, assets running in local (active module) context will access an instance of the library also running in local context. Assets running in global context however access an instance of the library in global context. In other words, there are two parallel instances of the ibrary. To prevent this situation the &#039;&#039;always-load-in-global-context&#039;&#039; tag forces the library to only load once (in global context). The library resisting in global context is then available to other assets in local and global context.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;CAUTION:&#039;&#039;&#039; there are some pitfalls when passing data between objects in different contexts. No references to objects of another context can be stored as members. This means you must make a copy of every &#039;&#039;reference&#039;&#039; type (e.g. strings and arrays) you want to store in another context. In other words, you need to extract any relevant details during the cross-context call and keep copies. [[Types#string|Strings]] are copied using [[class Str#CloneString|Str.CloneString()]] and [[Types#Array|arrays]] can be copied using the [[Arrays#copy|copy()]] operator. There are also possible limitations to cross context message passing, sniffing, etc.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Scripts running in global context cannot use some of the functions which are intended for the game context (e.g. driver module). This concerns mainly functions of [[class World]] and [[class Interface]]. Calling these functions from global context causes a &#039;&#039;ER_NativeCallError&#039;&#039; script exception.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Global settings libraries =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Global settings libraries =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Marinus</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=1447&amp;oldid=prev</id>
		<title>Windwalkr: /* Cross-asset script includes */</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=1447&amp;oldid=prev"/>
		<updated>2010-05-26T04:56:29Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Cross-asset script includes&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:56, 26 May 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Add the same KUIDs to your asset&amp;#039;s &amp;#039;&amp;#039;kuid-table&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Add the same KUIDs to your asset&amp;#039;s &amp;#039;&amp;#039;kuid-table&amp;#039;&amp;#039;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You must ensure that there are no script filename conflicts between any assets involved.  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You must ensure that there are no script filename conflicts between any assets involved.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;note: This functionality is untested and may be withdrawn.&#039;&#039;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Global script context =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Global script context =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Windwalkr</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=628&amp;oldid=prev</id>
		<title>Windwalkr: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=628&amp;oldid=prev"/>
		<updated>2010-02-03T13:59:31Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:59, 3 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Windwalkr</name></author>
	</entry>
	<entry>
		<id>https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=627&amp;oldid=prev</id>
		<title>imported&gt;John259: /* Global script context */ Expanded VM on first occurance</title>
		<link rel="alternate" type="text/html" href="https://wiki.trainzsimulator.com/index.php?title=New_TrainzScript_Features_-_TS2009&amp;diff=627&amp;oldid=prev"/>
		<updated>2009-11-24T16:38:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Global script context: &lt;/span&gt; Expanded VM on first occurance&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The following features are newly added to TrainzScript in [[TS2009]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Cross-asset script includes =&lt;br /&gt;
As of trainz-build 2.9, any scripted asset may directly include script files from the top-level directory of any other scripted asset. In your script code, you use the &amp;#039;include&amp;#039; keyword as normal to import the script file. In order for Trainz to find the include file, you must make the following [[config.txt file]] changes:&lt;br /&gt;
&lt;br /&gt;
* Add a &amp;#039;&amp;#039;script-include-table&amp;#039;&amp;#039; and list the KUID of the asset(s) from which you will be including files.&lt;br /&gt;
* Add the same KUIDs to your asset&amp;#039;s &amp;#039;&amp;#039;kuid-table&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
You must ensure that there are no script filename conflicts between any assets involved. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;note: This functionality is untested and may be withdrawn.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Global script context =&lt;br /&gt;
Trainz now runs multiple concurrent script virtual machines (VMs). Objects in each VM are largely disassociated, but because the native interface is shared, there is some level of cross-talk. This has not been clearly delineated, and is likely to change in future versions once we&amp;#039;ve had time to investigate it further. For now, you should treat the VMs as completely distinct except where Auran documentation explicitly declares otherwise.&lt;br /&gt;
&lt;br /&gt;
The two obvious script contexts are the global menu system, and the active module.&lt;br /&gt;
* The global VM is responsible for global settings libraries, menubar interface addons, etc. and does not have access to the World. It persists until Trainz exits.&lt;br /&gt;
* The active module VM is responsible for maintaining the session, route, and gameplay aspects and does not persist beyond the lifetime of the module.&lt;br /&gt;
&lt;br /&gt;
= Global settings libraries =&lt;br /&gt;
Global settings libraries are standard script libraries with an additional tag entry in their [[config.txt file]]s.&lt;br /&gt;
&lt;br /&gt;
 custom-category-list &amp;quot;GSET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The global settings libraries are loaded into the global VM in the following scenarios:&lt;br /&gt;
* The user clicks on the library in the [[Trainz Settings]] dialog.&lt;br /&gt;
* Another script in the global VM calls GetLibrary().&lt;br /&gt;
* The library is a built-in settings library recognized by Trainz, and Trainz wishes to read the current settings.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;note: Currently there is nothing to stop a global settings library from being loaded into a module VM. It is likely that we&amp;#039;ll change this prior to release, to ensure that they&amp;#039;re loaded into the global VM regardless of from where they&amp;#039;re instantiated.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Libraries loaded into the global module have their properties saved to the global settings file.&lt;br /&gt;
&lt;br /&gt;
The following TS2009 built-in content are Global Settings Libraries:&lt;br /&gt;
* &amp;quot;Video Settings&amp;quot; &amp;lt;kuid:30501:1021&amp;gt;&lt;br /&gt;
* &amp;quot;Surveyor Settings&amp;quot; &amp;lt;kuid:30501:1022&amp;gt;&lt;br /&gt;
* &amp;quot;Global Interface Addons&amp;quot; &amp;lt;kuid:30501:1026&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Interface Addons =&lt;br /&gt;
Interface Addons are standard script libraries with an additional tag entry in their [[config.txt file]]s.&lt;br /&gt;
&lt;br /&gt;
 custom-category-list &amp;quot;GADD&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Interface Addons are loaded into the global VM by the &amp;quot;Global Interface Addons&amp;quot; library. The user must choose to enable the interface addon before it is loaded.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;note: As they are normal script libraries, the interface addons may be loaded through other means. The &amp;quot;Global Interface Addons&amp;quot; library also provides a mechanism for users to unload addons. At the current time, this requires the user to reload Trainz; it is likely that we will add a script mechanism to truly unload the library, or at least tell it to clean up. We are also likely to provide a mechanism for interface addons to determine whether they were loaded by the Global Interface Addon (and should display their UI) or by some other mechanism (in which case they should remain hidden.)&amp;#039;&amp;#039; &lt;br /&gt;
&lt;br /&gt;
The following TS2009 built-in content are Interface Addons:&lt;br /&gt;
* &amp;quot;iTrainz Chat Interface&amp;quot; &amp;lt;kuid:30501:1003&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= iTrainz URL Helper library =&lt;br /&gt;
This script library provides a unified mechanism for handling custom &amp;#039;&amp;#039;trainz://xx/yy&amp;#039;&amp;#039; style URLs, regardless of where they occur in the game. The library is used by native code, and by scripts via the new TrainzScript.OpenURL() function.  Script code should never call into this library directly where a call to TrainzScript.OpenURL() would suffice, as the native code may perform some URL parsing before handing over to the script library.&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;iTrainz URL Helper library&amp;quot; is &amp;lt;kuid:30501:1025&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;note: Currently there is nothing to stop this library from being loaded into a module VM. It is likely that we&amp;#039;ll change this prior to release, to ensure that it&amp;#039;s loaded into the global VM regardless of from where it&amp;#039;s instantiated.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The current version of the library supports the following URL styles:&lt;br /&gt;
* &amp;#039;&amp;#039;trainz://buddy/NAME&amp;#039;&amp;#039; - routed to the &amp;quot;iTrainz Chat Interface&amp;quot;&lt;br /&gt;
* &amp;#039;&amp;#039;trainz://channel/NAME&amp;#039;&amp;#039; - routed to the &amp;quot;iTrainz Chat Interface&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The OpenURL() call will additionally support the following URL styles internally:&lt;br /&gt;
* &amp;#039;&amp;#039;trainz://install/KUID&amp;#039;&amp;#039; - opens an &amp;#039;asset details&amp;#039; window which allows the user to install the specified content.&lt;/div&gt;</summary>
		<author><name>imported&gt;John259</name></author>
	</entry>
</feed>