找回密码
 注册
X系列官方授权正版
搜索
查看: 8723|回复: 11

[原创] Cycrow's Scripting Guide 脚本指南翻译(一)

[复制链接]
发表于 2008-9-15 21:21:32 | 显示全部楼层 |阅读模式
本人是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 编辑 ]

评分

参与人数 1UCC +30 贡献 +1 收起 理由
roy986 + 30 + 1 [仅管理操作]发帖为精品内容

查看全部评分

 楼主| 发表于 2008-9-15 21:27:52 | 显示全部楼层
Enabling the Script Editor

From the menu, selecting the "personal" menu



Then select the "pilot" menu



Finally select the "Rename" option



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



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 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2008-9-15 21:51:12 | 显示全部楼层
Creating a new script

Go into the script editor
进入脚本编辑器



This will display a file list, select the "new script" option at the top
这将显示图片所示的文件列表,选择顶项“new script” 选项


Next enter the name for the script, this will be the filename used
下一步进入脚本名字输入框,这将会是使用的文件名


Editing script, goto the code section and find "new line"
编辑脚本,在到代码区将看到 “new line”


Press enter to go into the command menu
按 enter(回车键)进入命令菜单 (或者用鼠标点击“new line” 也行)
回复

使用道具 举报

发表于 2008-9-15 23:52:36 | 显示全部楼层
最想知道的是如何修改物品ID号,不知教材里有没有。。。
回复

使用道具 举报

 楼主| 发表于 2008-9-16 00:05:39 | 显示全部楼层
Adding a Command - Money Cheat

From the command menu, select the Trade commands item
从命令菜单中选择 "trade commands" 项目


Chose the command, add money to player
选择命令: add money to player


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


Next input the amount you want
接下来输入你想要的数量,(然后按回车键)



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



Running a Script运行脚本
From the script list, scroll down to the script you created
在脚本列表中向下滚动到你创建的脚本


Once highlighted, press the "r" key to run the script
高亮选择它,按下"r"键执行这个脚本


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"就行


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

使用道具 举报

 楼主| 发表于 2008-9-16 00:07:57 | 显示全部楼层
原帖由 dianao 于 2008-9-15 23:52 发表
最想知道的是如何修改物品ID号,不知教材里有没有。。。


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

使用道具 举报

 楼主| 发表于 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"



Select the "add notoriety" command
选择 "add notoriety"命令


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



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



Once selected, you will be taken back to the script editor, but there are other varibles to set
选择之后你将回到脚本编辑器,但是这里还有其他的变量需要设置


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



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“(不知是我的理解错误还是原文这里有错,应该是选择玩家的飞行员的名字才对。)


Now for the third and final varible, which is the value to add
现在是第三个也是最后一个变量,这是增加的声望值


Now select "<Number>"
现在选择"<Number>"


Enter the number of notority points to add, usually between 1 and 40
输入增加的声望点数字,通常是1到40


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



回复

使用道具 举报

 楼主| 发表于 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开头,这样才能在游戏开始的时候自动运行这个脚本)




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



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"命令获得文本



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 创建一个新变量来储存从文件中载入的文本。



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块



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”



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 "命令



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”



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



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

使用道具 举报

发表于 2008-9-17 12:59:24 | 显示全部楼层
顶起来!
慢慢翻译,质量最重要!
回复

使用道具 举报

 楼主| 发表于 2008-9-17 15:08:44 | 显示全部楼层
呵呵,没想到第一次发贴就被加精,心里那个感动啊。。。如果置顶就更理想了(贪心了哈哈。。。

[ 本帖最后由 loya 于 2008-9-28 10:20 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

Archiver|手机版|小黑屋|DeepTimes.NET 太空游戏站