- UID
- 17833
- UCC
-
- 声望
-
- 好评
-
- 贡献
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 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 编辑 ] |
|