- 积分
- 13
- 最后登录
- 1970-1-1
- 阅读权限
- 1
- 积分
- 13
- 帖子
- 精华
该用户从未签到
|
请登陆后查看,谢谢!
您需要 登录 才可以下载或查看,没有帐号?加入
x
http://publish.uwo.ca/~gerard/tr ... cripting/index.html
Contents
Scripting Tutorials
Utilities
CDP's
Scripting Tutorials
By popular request, I've made the Tutorials also available in PDF. I've done this with Acrobat 6, which seems to do a reasonable job but does have its peculiarities. For example, as a footer on each page you get the location where I have the file on disk (useless) plus the pagenumber (useful).
In both the HTML and PDF versions I have links to auxiliary files you can download. These will work only when you view the HTML or PDF version from the server. If you download either the HTML or the PDF version, they won't work. Just make sure you use the on-line version when trying to download auxiliary files.
Part 1: Basics of the Language
This tutorial introduces you to the basics of the language.
HTML Version
PDF Version
Part 2: The ListTrain Command
In this tutorial you make a simple driver command. You will also be introduced to the important concept of messages.
HTML Version
PDF Version
Part 3: Improving The ListTrain Command
In this tutorial we will improve the ListTrain command that we started in Tutorial 2. We will also see how casting a variable to a type works, and we will have a look at the MiniBrowser. Finally, you will see how you can use the ListTrain command as a starting point for a new command. Oh yes, there are also kangaroos.
HTML Version
PDF Version
Part 4: Scheduling the ListTrain Command
In this tutorial we will make a scheduled version of the ListTrain command that we started in Tutorial 2. It also shows you how to use the wait() keyword to wait for the closing of the browser.
HTML Version
PDF Version
Part 5: Nested Menus and The Mini-Browser
This tutorial starts by showing you how to make a nested menu for a driver command. After that it tells you more about the mini browser. It contains an introduction to its version of HTML. And it talks about threads.
HTML Version
PDF Version
Scripting Tutorial Part 6
User Activities Part 1: Rules
This tutorial tells you about Rules, which are the scripting elements you can use to control what happens on your layout. Sessions are the new way in which to create user activities, the sequel to Scenarios. This tutorial gets you started in that direction.
HTML Version
PDF Version
Scripting Tutorial Part 7
User Activities Part 2: Making a Nano-Scenario
In this tutorial you will make a very small scenario using a rule.
HTML Version
PDF Version
Utilities
In this section I'll make available various pieces of code that may be useful to more people than just me.
Sorting.gs
This is a class with sorting methods. Here is some of the "documentation" I put as comments at the top of the class, that should give you a general idea:
// This class contains methods to sort arrays of string, float and int.
// To use it put Soring.gs in the directory of your project, and then
// do include "Sorting.gs".
// If you want a sorted version of the array aa,
// do the following:
// int nitem = aa.size();
// string[] aaSorted = new string[nitem];
// int[] index = new int[nitem];
// int[] invindex = new int[nitem];
// Sorting.SortString(aa, index, invindex, nitem)
// for (i=0; i<nitem; i++)
// {
// aaSorted = aa[invindex];
// }
// Or, without declaring an extra array:
// int i, iSorted;
// for (i=0; i<nitem; i++)
// {
// iSorted = invindex;
// ... do things with aa[iSorted] ...
// }
// You can use these methods to sort anything, as follows. Say you have an array of Industries you
// want to sort by name. Put all their names in an array, sort this array and then use invindex
// to access the Industries array.
To download, right-click on the link and do Save Target As:
Download Sorting.gs.
GeneralUtilities.gs
These are the GeneralUtilities I use in my tutorials.
To download, right-click on the link and do Save Target As:
Download GeneralUtilities.gs.
StringUtilities.gs
These are the StringUtilities I use in my tutorials.
To download, right-click on the link and do Save Target As:
Download StringUtilities.gs.
TrainUtilities.gs
These are the TrainUtilities I use in my tutorials.
To download, right-click on the link and do Save Target As:
Download TrainUtilities.gs.
CDP's
Here are various cdp's.
SpeedLoad, KUID2:54936:80008
// This command will let you load all vehicles of your train from an applicable
// queue in any industry, anywhere. You don't need to be at the corresponding track,
// or even in the vicinity.
// It is meant for those who want to drop off their consist at a yard and then come
// back later when the ground crew has done the loading.
// If you want to provide for a loading time (the loading is almost instantaneous),
// use a WaitFor command before the SpeedLoad command.
// The industries are listed by product category, following an idead by Michael Forner.
To download, right-click on the link and do Save Target As:
Download SpeedLoad.cdp.
TestRule, KUID2:54936:80010
This is the start version of the TestRule from Scripting Tutorial 6, User Activities Part 1: Rules.
To download, right-click on the link and do Save Target As:
Download TestRule.cdp.
TestRule, KUID2:54936:80010
This is the final version of the TestRule from Scripting Tutorial 7, User Activities Part 2: Making a Nano-Scenario.
To download, right-click on the link and do Save Target As:
Download TestRuleFinal.cdp.
ShowBrowserRule, KUID2:54936:80011
This is an auxiliary rule. You add it in Surveyor to the rules, and then in Driver it sits and waits for you to send messages with majors that all start with "ShowBrowserRule". You can send these messages from within your own rule with PostMessage. Upon receipt of these messages the rule will display one or more browsers, of a settable size, position and type, with text loaded either from a file or from a string. Documentation is enclosed in Instructions.html.
To download, right-click on the link and do Save Target As:
Download ShowBrowserRule.cdp.
TimerRule, KUID2:54936:80012
This is an auxiliary rule. You add it in Surveyor to the rules, and then in Driver it sits and waits for you to send messages with majors that all start with "TimerRule". You can send these messages from within your own rule with PostMessage. Upon receipt of these messages the rule will start or stop timers. When a timer goes off, it broadcasts a messsage "TimerRuleTick", "n", where n is the timer number (0-6). Each timer has an interval, which is the time between "TimerRuleTick", "n" messages. Documentation is enclosed in Instructions.html.
To download, right-click on the link and do Save Target As:
Download TimerRule.cdp.
SpeedingRule, KUID2:54936:80013
This is an auxiliary rule. You add it in Surveyor to the rules, and then in Driver it sits and waits for you to send messages with majors that all start with "SpeedingRule". You can send these messages from within your own rule with PostMessage. Upon receipt of these messages the rule will start or stop watching for speeding trains. When a train is caught speeding, it broadcasts a messsage "SpeedingRuleTick", "TrainName", where TrainName is the name of the speeding train. The rule has an interval, which is the time between speeding checks, it is 1 second by default. The rule can also display a warning browser and adjust the game score when a train speeds. Documentation is enclosed in Instructions.html.
To download, right-click on the link and do Save Target As:
Download SpeedingRule.cdp.
ShowScoreRule, KUID2:54936:80014
This is an auxiliary rule. You add it in Surveyor to the rules, and then in Driver it sits and waits for you to send messages with majors that all start with "ShowScoreRule". You can send these messages from within your own rule with PostMessage. Upon receipt of these messages the rule will start or stop displaying the score, using Interface.GetScore(). It uses a mini-browser to display the score, this browser is configurable. Documentation is enclosed in Instructions.html.
To download, right-click on the link and do Save Target As:
Download ShowScoreRule.cdp. |
|