loya 发表于 2008-9-15 21:21:32

Cycrow's Scripting Guide 脚本指南翻译(一)

本人是x3新手,对游戏的脚本很感兴趣,可惜坛子里面中文的教程偏少,在网上找到一篇 Cycrow's Scripting Guide 脚本指南系列,打算把它大概翻译一下(不知道以前有人翻译过没?),给像和我一样的x3新手一个学习脚本的入门。(声明一下:本人E文没过3级,x3接触时间也还不到一周,仅仅是对脚本编程有所爱好,所以打算采用中英文对照翻译,翻译中有什么错误还请各位大大指正,本人对各位大大对脚本方面的研究是非常滴羡慕。。。*0*)。以下是这篇指南的目录,对我来说算蛮大的工程了哎,不知道能不能坚持到底:

Cycrow's Scripting Guide
原文连接:http://x3.ircwhore.co.uk/scripts/help/index.html

Enabling the Script Editor
激活脚本编辑器

Creating your first script
创建你的第一个脚本

Adding a Command - Money Cheat
增加一个命令 - 金钱作弊

Running your script
运行你的脚本

Adding a Command with Multiple Varibles - Notority Cheat
增加一个多变量命令 - 声望作弊

Creating a Text File
创建一个文本文件

Using a Command Slot
使用命令插槽

Conditional Statements
条件语言

Using Script Arguments
使用脚本参数

Creating Wares to Use
创建物品

Creating a Hotkey - Destruct Target
创建一个热键 - 摧毁目标

Creating an AL Plugin
创建一个人工智能插件

Using Message Arguments
使用一个消息变量

Creating Incomming Questions
创建提问邮件(?这个不知道怎么翻译好)
---------------------------------------------------
List of Commands by Boron Ol Fh'art
命令列表

[ 本帖最后由 loya 于 2008-9-16 10:22 编辑 ]

loya 发表于 2008-9-15 21:27:52

Enabling the Script Editor

From the menu, selecting the "personal" menu

http://x3.ircwhore.co.uk/scripts/help/menu1.jpg

Then select the "pilot" menu

http://x3.ircwhore.co.uk/scripts/help/menu2.jpg

Finally select the "Rename" option

http://x3.ircwhore.co.uk/scripts/help/menu3.jpg

Now type the name "Thereshallbewings" as your name, note the capital "T" and the 2 ll's

http://x3.ircwhore.co.uk/scripts/help/cname.jpg

There will be a short pause and the script editor will now be enabled
Finally, just save, and then reload your game for any new scripts to be loaded

这第一篇不用翻译了吧?

[ 本帖最后由 loya 于 2008-9-15 21:32 编辑 ]

loya 发表于 2008-9-15 21:51:12

Creating a new script

Go into the script editor
进入脚本编辑器
http://x3.ircwhore.co.uk/scripts/help/editor.jpg


This will display a file list, select the "new script" option at the top
这将显示图片所示的文件列表,选择顶项“new script” 选项
http://x3.ircwhore.co.uk/scripts/help/newscript.jpg

Next enter the name for the script, this will be the filename used
下一步进入脚本名字输入框,这将会是使用的文件名
http://x3.ircwhore.co.uk/scripts/help/scriptname.jpg

Editing script, goto the code section and find "new line"
编辑脚本,在到代码区将看到 “new line”
http://x3.ircwhore.co.uk/scripts/help/editing.jpg

Press enter to go into the command menu
按 enter(回车键)进入命令菜单 (或者用鼠标点击“new line” 也行)
http://x3.ircwhore.co.uk/scripts/help/commands.jpg

dianao 发表于 2008-9-15 23:52:36

最想知道的是如何修改物品ID号,不知教材里有没有。。。

loya 发表于 2008-9-16 00:05:39

Adding a Command - Money Cheat

From the command menu, select the Trade commands item
从命令菜单中选择 "trade commands" 项目
http://x3.ircwhore.co.uk/scripts/help/tradecmd.jpg

Chose the command, add money to player
选择命令: add money to player
http://x3.ircwhore.co.uk/scripts/help/addmoney.jpg

Then a menu will come up to enter the first varible, in this case, its the money to add
Select the "number" option
然后将出现输入第一个变量的菜单,这个变量是要增加的金钱,选择"number"项.
http://x3.ircwhore.co.uk/scripts/help/number.jpg

Next input the amount you want
接下来输入你想要的数量,(然后按回车键)
http://x3.ircwhore.co.uk/scripts/help/inputnumber.jpg


Once added, this command will show up in the editor, now just press escape to close and save the script
一旦添加完,此命令将显示在编辑器中,现在只需按下esc键,关闭并保存该脚本
http://x3.ircwhore.co.uk/scripts/help/finish1.jpg


Running a Script运行脚本
From the script list, scroll down to the script you created
在脚本列表中向下滚动到你创建的脚本
http://x3.ircwhore.co.uk/scripts/help/scriptlist.jpg

Once highlighted, press the "r" key to run the script
高亮选择它,按下"r"键执行这个脚本
http://x3.ircwhore.co.uk/scripts/help/runscript.jpg

Next, you will be asked for the object you want the script to run on, this can be a ship or station
For this script, you dont need it run on any perticlar object, so just select "null"
接下来将要你选择脚本在你想要的对象上运行,可以是太空船或者是空间站,对于这个脚本,你不需要它运行在任何特定的对象上,只要选择"null"就行
http://x3.ircwhore.co.uk/scripts/help/execute.jpg

The execute script will display the script your about to run, just hit enter, and it will be finished
执行脚本框将显示你将要执行的脚本,点击回车键,脚本将被执行

loya 发表于 2008-9-16 00:07:57

原帖由 dianao 于 2008-9-15 23:52 发表 http://bbs.deeptimes.org/static/image/common/back.gif
最想知道的是如何修改物品ID号,不知教材里有没有。。。

这个教程我也没看完,不知道有没有哇。。。

loya 发表于 2008-9-16 12:13:50

Adding a command with multiple Varibles - Notority Cheat

From the script command menu, select the "Global Object Commands"
在脚本命令菜单选择 "GeneralObject Commands"

http://x3.ircwhore.co.uk/scripts/help/genobject.jpg

Select the "add notoriety" command
选择 "add notoriety"命令
http://x3.ircwhore.co.uk/scripts/help/addnot.jpg

Then you enter the first varible, which is the race to add notorty too, goto "Select Race"
然后输入第一个变量,这是为种族增加声望,选择 “select Race”

http://x3.ircwhore.co.uk/scripts/help/selectrace.jpg

Then choose the race you want yo adjust the notoriety for, IE Argon
接下来选择你想要调整声望的种族,例如 Argon

http://x3.ircwhore.co.uk/scripts/help/argon.jpg

Once selected, you will be taken back to the script editor, but there are other varibles to set
选择之后你将回到脚本编辑器,但是这里还有其他的变量需要设置
http://x3.ircwhore.co.uk/scripts/help/notcommand1.jpg

Use left and right arrow keys to select the varible to change then press enter, select the second one now
使用左右方向键选择需要改变的变量然后回车。现在选择第二个变量

http://x3.ircwhore.co.uk/scripts/help/notcommand2.jpg

This is the race to add the notoriety for, so to give yourself more rep, you use the "Player" race, in this list this will be displayed as your pilots named, but change to "Player" when selected.Goto "Select Race" again then choose "Argon"
这是把声望增加到的那个种族,当然是给你自己,你使用的“Player(玩家)“的种族,在这个列表里面将显示为你的飞行员的名字。再次转到”select Race“然后选择”Argon“(不知是我的理解错误还是原文这里有错,应该是选择玩家的飞行员的名字才对。)
http://x3.ircwhore.co.uk/scripts/help/player.jpg

Now for the third and final varible, which is the value to add
现在是第三个也是最后一个变量,这是增加的声望值
http://x3.ircwhore.co.uk/scripts/help/notcommand3.jpg

Now select "<Number>"
现在选择"<Number>"
http://x3.ircwhore.co.uk/scripts/help/number.jpg

Enter the number of notority points to add, usually between 1 and 40
输入增加的声望点数字,通常是1到40
http://x3.ircwhore.co.uk/scripts/help/notnumber.jpg

Now the script is finished, escape and save, now run the script whenever you need a boost in Argon Rep
现在这个脚本完成了,点击"esc"键并保存,现在每当你需要提升在 Argon的声望就运行这个脚本

http://x3.ircwhore.co.uk/scripts/help/notcommand4.jpg

loya 发表于 2008-9-16 21:23:34

Creating a Text File
Text file are used to load all text required into the game as well as using command slots and wares
文本文件被用来装载进入游戏以及使用命令插槽和商品所有必需的文本
To create a text file, you must first pick an id to use, id's are 4 numbers, usually between 7000 and 9000.
为了创建一个文本文件你必须选择一个 id 号,id是一个4位数字,通常是7000到9000之间
View the egosoft page will list all the text files that are currently being used by scripts, so its usually best to pick one thats not used to avoid conflicts.
浏览 egosoft 页面将列出目前所有被使用的文本文件 ,因此最好选择一个未被使用的以避免冲突
Click Here for the text file list

Now you need to create the file itself, the filename is the language id followed by the text id you've chosen, for English, the id is 44
现在你需要创建文件本身,它的文件名是语言id+你选择的文本文件id,对于英语,id是44
So for the language file id 9000, the filename is 449000.xml and it goes in the x3/t directory, and can edit it in a standard text editor like notepad.
所以对于这个语言和文件 id 9000,文件名是 449000.xml,并且它位于 x3/t 目录,可以在类似记事本之类的标准文本编辑器中编辑它
The first line is the file information this can be pretty much the same in all files.
第一行文件信息在所以的文件中几乎和下面这句一样
<?xml version="1.0" encoding="UTF-8" ?>

This sets the file as an xml file using UTF-8 encoding, UTF-8 is used to allow the special characters from other languages like russian to work.

The next line is the language id, this is the same id that you used to name the file, ie 44 for english
接下来的一行是语言 id,这和你在文件名中使用的id一致,对英语是44
<language id="44">

The rest of the file is set out in page blocks, each page has an id which is used in the script editor to load which block of text to use.
文件其余部分安排在 page 块中,每一个page有一个 id ,要使用哪一个的文本块就在脚本编辑器中使用哪一个 id .
There are various predefined pages to use when adding commands or wares, but if you're just adding some text to be used, then you need to pick an
id like you did for the file name.
当添加命令或者商品时有各种预定义的 pages 可以使用,但是如果你只是增加一下文本来使用,那么你可以像取文件名那样选择一个id。
Again the id's are usually between 7000 and 9000, so its usually best to use the same page id as file id.
So the next line will be the start of your page block
id通常也是7000到9000,因此最后使用和文件id一样的page id。


<page id="9000" title="my script text">

The title argument is used mainly for reference and isn't nesesary
title参数主要用于参考,它不是必需的
Inside the page blocks you have each indivial text entries, each having an id of thier own
These are in t blocks
page块中每一个text项都有一个它们自己的 id

<t id="1">Some text</t>

Note the closing of the block at the end with the </t>. Like html all tags must be closed.
Finally you need to close the page block
注意结束块,就像html的标签必需是封闭的,最后你需要 结束 page 块
</page>

You can add as many page blocks into the files as you like, at the end of the file you need to close the language block
你可以随意加入许多 page 块 ,在最后必需结束 language 块
</language>

So now you've made the text file, this is how the complete file should look
完整的文件看起来像下面的

<?xml version="1.0" encoding="UTF-8" ?>
<language id="44">
<page id="9000" title="my script text">
<t id="1">Some text</t>
</page>
</language>

Lastly you need to be able to access these text's from inside the script editor
最后你需要能从脚本编辑器里面访问这些文本
The first thing you need to do is load the text file into the game for use
This is usually done in a setup file, or it could just be run manually if you prefer
Create a new script and from the general commands, select the command: load id
首先你需要在进入游戏时载入文本文件,这通常是做在一个安装文件中,或者你更喜欢它仅仅是手动执行,
创建一个新脚本,从 general commands 中选择命令:load text: id

(说明一下:这里新建的脚本文件名很重要,必需以 setup开头,这样才能在游戏开始的时候自动运行这个脚本)


http://x3.ircwhore.co.uk/scripts/help/textfile/loadid.jpg

The only argument is a number, and its the id of the file, in this case, its 9000
So enter 9000 as the number
仅有一个数字型参数,它就是文件的 id,这个例子中它是9000,因此选择 number 输入 9000

http://x3.ircwhore.co.uk/scripts/help/textfile/loadid2.jpg

This is the setup script done, onces its loaded, the text from the file will be loaded
这是做到安装脚本,一旦被加载,文本将会从文件中载入
To get some text you can use the "read text" command from the general menu
你可以使用 general commmands 菜单中的 "read text"命令获得文本

http://x3.ircwhore.co.uk/scripts/help/textfile/readtext1.jpg

The first argument is the return value, this is a varible that the text will be stored in, select varible and input the varible name.
第一个参数是返回值,这是一个变量, 文本将会储存其中,选择 "varible" 并且输入变量名称
For this example, im going to use the varible "message". This will create a new varible as $message and store the text from the file
这个例子中我将使用 变量 "message"。这将以 $message 创建一个新变量来储存从文件中载入的文本。

http://x3.ircwhore.co.uk/scripts/help/textfile/readtext2.jpg

The next argument is the page id, this is the page block you want to get the text from.
下一个参数是 page id,这就是你想得到的文本的 page 块
Using the number 9000, will get the text block we added to the text file.
使用数字 9000 ,将获得我们添加在文本文件中的 文本块
When loading text files, all files will be loaded into memory, so if you have a few files with the same page blocks, they will overright each
other.
文本文件载入时,所以的文件将被载入到内存,因此如果你有一些文件有相同的page块,他们将会彼此覆盖。
When getting the text, It will look in all text files that are loaded to find the correct page block.
当获取文本时将在载入的所有的文本文件中找到正确的page块

http://x3.ircwhore.co.uk/scripts/help/textfile/readtext3.jpg

The file argument is the text id, this is the t id from the file, using the id of 1 for page 9000, will return the text "Some Text"
最后一个参数是文本 id,就是文件中的 t标签的 id ,使用 page 9000 中的 1 id将返回文本“Some Text”

http://x3.ircwhore.co.uk/scripts/help/textfile/readtext3.jpg

Now the varible $message should contrain the string "Some Text"
现在变量 $message 应该包含字符串 "Some Text"
To test this, we can just put it to the logbook
为了测试这个,我们把它填入飞行日志
From the logbook commands menu select the write to player logbook command
从 logbook command 菜单中选择"write to player logbook "命令

http://x3.ircwhore.co.uk/scripts/help/textfile/logbook1.jpg

The only argument is the text to put to the logbook, we will use the varible just created.
select the varible "message" from the list
仅有的一个参数就是填入飞行日志的文本,我们将使用刚才创建的变量,
从列表中选择变量 “message”

http://x3.ircwhore.co.uk/scripts/help/textfile/final.jpg

When this script is run, it will display the text in your logbook
当这个脚本运行之后它将在你的飞行日志中显示 这段文本



[ 本帖最后由 loya 于 2008-9-17 16:41 编辑 ]

roy986 发表于 2008-9-17 12:59:24

顶起来!
慢慢翻译,质量最重要!

loya 发表于 2008-9-17 15:08:44

呵呵,没想到第一次发贴就被加精,心里那个感动啊。。。如果置顶就更理想了(贪心了哈哈。。。 )

[ 本帖最后由 loya 于 2008-9-28 10:20 编辑 ]
页: [1] 2
查看完整版本: Cycrow's Scripting Guide 脚本指南翻译(一)