模拟火车中国站

 找回密码
 加入

QQ登录

只需一步,快速开始

扫一扫,访问微社区

用百度帐号登录

只需两步,快速登录

模拟火车中国站欢迎您的到来
查看: 5368|回复: 1
打印 上一主题 下一主题
收起左侧

TRS 2004 Scripting Tutorials (转贴)

  [复制链接]

该用户从未签到

跳转到指定楼层
1股道
trainz2010 发表于 2010-10-9 23:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

请登陆后查看,谢谢!

您需要 登录 才可以下载或查看,没有帐号?加入 用百度帐号登录

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.
分享到:  微信微信 QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 支持支持 反对反对

模拟火车中国站 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
2、本站所有主题由该帖子作者发表,该帖子作者与模拟火车中国站享有帖子相关版权
3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和模拟火车中国站的同意
4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
7、模拟火车中国站管理员和版主有权不事先通知发贴者而删除本文

模拟火车中国站 - Www.Trainsimchina.Com - 国内最大的模拟火车游戏基地
回复

使用道具 举报

该用户从未签到

2股道
jacklovebaby2 发表于 2010-11-16 23:59 | 只看该作者
喜欢!








-------------------
If you don''t see Tiffany inclusions with your unaided eye probably no one else will.
模拟火车中国站 - Www.Trainsimchina.Com - 国内最大的模拟火车游戏基地
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入 用百度帐号登录

本版积分规则

关闭

站长推荐上一条 /2 下一条

QQ|申请友链|小黑屋|手机版|Archiver|模拟火车中国站 ( 粤ICP备14026763号-4 )

GMT+8, 2024-12-13 22:18 , Processed in 0.114320 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表