赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 54280 |
最后登录 | 2006-1-29 |
在线时间 | 0 小时 |
Lv1.梦旅人 (禁止发言)
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 0 小时
- 注册时间
- 2005-10-22
- 帖子
- 81
|
下面的链接:
http://rpg.blue/web/dlFTP/up/技术区/RMXP_SDK_1.3_T-CN.TXT
#==============================================================================
# 文本翻译:FantasyDR
# 联系方式:FantasyDR#emsky.net
# 无责任无授权翻译,为了避免误人子弟,所以将翻译文本附与原文之后,请对照查看。
# 转载请保留声明,避免以讹传讹,万一出了错可以找原文来看。
# 2005-12-23
#==============================================================================
# 译者废话:这个东西是Rpg Maker XP的RGSS的一个非官方扩充计划,具体实用价值对于广大
# RM爱好者来说似乎不大,对于脚本制作者来说……目前也不大。我翻译的是文档开头关于这个
# 项目的介绍和一些开发约定。似乎离RM比较遥远,各位不看也罢。其所有代码请在原文后自行
# 寻找,这个翻译稿没有包含此内容。
#==============================================================================
# ** RMXP Standard Development Kit (SDK)
# ** RMXP 标准开发工具包
# (这个标题有点奇怪,因为一般意义上的SDK是Software Develpment Kit,软件开发工具包)
# (但是,为了统一,后面提到的SDK也是指这里的Standard Development Kit)
#------------------------------------------------------------------------------
#(开发历史,未翻译)
# Build Date - 2005-11-22
# Version 1.0 - Near Fantastica - 2005-11-22
# Version 1.1 - SephirothSpawn - 2005-12-18 - (Near Fantastica)
# Version 1.2 - Near Fantastica - 2005-12-18
# Version 1.3 - Wachunga - 2005-12-19
#------------------------------------------------------------------------------
=begin
1.0 - Outline
The Standard Development Kit (SDK) aims to increase compatibility between
RGSS scripts by:
a) defining a set of scripting standards (see section 3)
b) restructuring often-used default classes and methods (see section 4)
c) providing a scripting tools module (see section 5)
1.0 - 大纲
这个SDK是用来改进RGSS脚本间的兼容性,通过:
a)定义一套脚本书写标准(见章节3)
b)对于一些常用的默认类和方法进行重构(见章节4)
c)提供一个脚本编写工具模块(见章节5)
#------------------------------------------------------------------------------
2.0 - Modifications to the RMXP Standard Development Kit
Since edits to the SDK may cause massive capability errors, any and all
modifications must first be approved by a member of the RMXP SDK Team.
The author of any modifications must be sure to update all relevant
documentation. This also includes the header, where the author is to put
the next version number with his or her name and the name of the approval
member (from the SDK Team) under the latest version in the following format.
Version # - Name - Date - (Approval Member Name)
2.0 - 对于RMXP SDK的修改
因为修改SDK可能会导致很多兼容性问题,所以任何修改都必须首先经过RMXP SDK Team的成员允许。
作出任何修改的人都必须保证提交了所有相关文档。这些文档要包括header,header中包含作者名字,
版本号,批准人(来自SDK Team),而且要以下面的格式:
版本号 # - 名字 - 日期 - (批准成员名单)
#------------------------------------------------------------------------------
3.0 - Coding Standards
To be compliant with the SDK, a script must compy with the following
coding standards:
3.1 - Commenting
3.2 - Classes
3.3 - Variables
3.4 - Aliases
3.5 - Strings
3.6 - Line Length
3.7 - White Space
3.8 - Constants
3.9 - Parentheses
3.0代码书写标准
为了保证和SDK兼容,脚本必须符合下面的编码标准(小节题目翻译略):
#------------------------------------------------------------------------------
3.1 - Commenting
3.1 - 注释
Scripts must begin with the following header:
脚本必须用以下格式的开头:
#==============================================================================
# ** Script Name
#------------------------------------------------------------------------------
# Your Name
# Version
# Date
#==============================================================================
All classes and methods must have a comment describing the process or what
was added. All code added to methods that can not be aliased must be
formatted as follows:
所有的类和方法必须有注释,用于描述其实现过程或增加了什么功能。所有不可被重命名的方法的
附加代码,必须按照下面的格式:
#------------------------------------------------------------------------------
# Begin Script Name Edit
#------------------------------------------------------------------------------
[Code]
#------------------------------------------------------------------------------
# End Script Name Edit
#------------------------------------------------------------------------------
Single line comments should precede the described block of code and should be
indented at the same level. Code that is not self-documenting should be
commented.
单行注释必须写在代码内容之前,并且保持缩进一致。不能self-documenting
(自成文档,明确表达自身含义)的代码必须有注释。
However, very short comments can appear on the same line as the described
code, but should be shifted far enough to separate them from the statements.
If more than one short comment appears in a chunk of code, they should all be
indented to the same tab setting. Attribute declarations should always have a
trailing comment.
但是,很短的注释可以写在代码段的同一航,但是必须和段间保持足够的空白。如果多余一个的
短注释出现在很拥挤的代码中,他们必须保持同样的缩进。Attribute(属性,成员)的声明后
应该有一个简短注释。
#------------------------------------------------------------------------------
3.2 - Classes
3.2 - 类
All classes must be named consistently with the default code, namely:
所有的类必须兼容默认代码命名风格:
Data - Any class that holds data
Game - Any class that processes data
Sprite - Any class that defines a sprite
Spriteset - Any class that defines multiple sprites
Window - Any class that defines a window
Arrow - Any class that defines an arrow
Scene - Any class that defines a scene
Data - 保存资料的的类
Game - 游戏进程类
Sprite - 定义Sprit(精灵,游戏画面单元)的类
Spriteset - 定义大量Sprite的类
Window - 定义Window(窗口,游戏UI元素)的类
Arrow - 定义Arrow(?)的类
Scene - 定义Scene(场景)的类
#------------------------------------------------------------------------------
3.3 - Variables
3.3 - 变量
All variable names must be reasonably descriptive. Use of class and global
variables should be limited. Any variable used by the default system can not
have its use changed.
所有变量名称必须有明确的含义。被类和全局变量使用过的名称被保留。所有被原系统(指RGSS默认脚本)
使用过的不能改变其用途。
#------------------------------------------------------------------------------
3.4 - Aliases
3.4 - 重命名
Aliasing a method is preferable to overriding it; an alias should be used
whenever possible to increase compatibility with other scripts. All alias
names must have the following format:
重命名一个方法要比覆盖这个方法更好。需要保持兼容性的时候应该使用Alias关键字。所有
重新命名的方法名称必须符合下面的规格:
yourname_scriptname_classname_methodname
作者名称_脚本名称_类名称_方法名称
#------------------------------------------------------------------------------
3.5 - Strings
3.5 - 字符串
Strings should normally be defined with single quotes ('example'); this
decreases the processing time of the engine. Double quotes are useful when
using the following features:
字符串一般使用单引号定义('例如这样');这样可以减少引擎的处理时间。双引号在使用
下面所提到的特性的场合中使用:
a) substitutions, i.e. sequences that start with a backslash character
(e.g. \n for the newline character)
a)替代符,即使用反斜线开头的字符
(例如:\n 换行符)
b) expression interpolation, i.e. #{ expression } is replaced by the value
of expression
b)替换表达式,比如 #{ expresion }这段字符串会被expression的值替换掉。
#------------------------------------------------------------------------------
3.6 - Line Length
3.6 - 每行长度
Lines should not cause the the viewer to have to scroll sideways to view them
in the script editor. When the line needs to be broken, it should follow the
following guidelines, in preferential order:
代码不应该让读者必须使用滚动条才能看全。当需要换行的时候,应该遵循下面的原则,保持
一定的顺序:
Break after a comma.
Break before an operator.
Prefer higher-level breaks to lower-level breaks.
Align the new line with the beginning of the expression at the same level
on the previous line.
在逗号后换行。
在运算符前换行。
higher-level breaks 优先于 lower-level breaks
新一行文字开头和上一行文字开头缩进保持一致。
If the above rules lead to confusing code or to code that squished up
against the right margin, just indent 4 spaces instead.
如果上面的原则导致了代码变得晦涩或者代码超过右边界,那么就只缩进4个空格距离。
#------------------------------------------------------------------------------
3.7 - White Space
3.7 - 空白
A blank line(s) should be used in the following places:
应该在如下地方加上空行:
Between sections of a source file
Between class and module definitions
Between attributes and the class definition
Between methods
Between the local variables in a method and its first statement
Before a block or single-line comment
Between logical sections inside a method to improve readability
源文件的代码段之间
类和模块定义之间
属性和类定义之间
方法之间
方法中的局部变量和它的首次声明之间
单行注释
方法中的某个段前后增加空行,可以提高代码可读性。
Blank spaces should be used in the following places:
应该在入下地方加入空格:
A keyword followed by a parenthesis, e.g. if (some_boolean_statements)
After commas in argument lists, e.g. def method (arg1, arg2, ...)
All binary operators except '.', e.g. a + b; c = 1
带括号的关键字和括号之间
参数定义的逗号之后
除了'.'以外的运算符
#------------------------------------------------------------------------------
3.8 - Constants
3.8 - 常量
New numerical values should not be "hard-coded", except for -1, 0, and 1,
which can appear in for loops as counter values. Instead, these numerical
values should be made into constant variables and these used instead.
除去-1,0,1这种用于循环计数的值,数值不要直接书写于代码中。应该定义这些数值为常量,
然后在代码中使用常量。
#------------------------------------------------------------------------------
3.9 - Parentheses
3.9 - 括号
It is generally a good idea to use parentheses liberally in expressions
involving mixed operators to avoid operator precedence problems. Even if
the operator precedence seems clear to you, it might not be to others -you
shouldn't assume that other programmers know precedence as well as you do.
在表达式中使用括号来分割运算符以避免优先级产生的问题是一个不错的方法。即使这个表达式
对于你来说是很清晰的,但是对于其他人也许不是这样-你不应该假设其他程序员和你一样清楚
表达式的运算过程。
#------------------------------------------------------------------------------
4.0 - Engine Updates
4.0 - 引擎更新
The following is a list of classes and methods that have been updated by the
SDK to help improve compatibility:
下面是此SDK为改进兼容性,所更新过的类与方法的列表:
Game_Map - setup
Game_Map - update
Game_Character - update
Game_Event - refresh
Game_Player - update
Spriteset_Map - initialize
Spriteset_Map - update
Scene_Tile - main
Scene_Map - main
Scene_Map - update
Scene_Save - write_save_data
Scene_Load - read_save_data
Scene_Menu - initialize
Scene_Menu - main
Scene_Menu - update & command input
Scene_Battle - main
Scene_Battle - update
Scene_Battle - update_phase3_basic_command
Scene_Battle - make_basic_action_result
#------------------------------------------------------------------------------
5.0 - SDK Tools
5.0 - SDK工具
The following tools are included in the SDK to help improve the development
process:
SDK中的一些方便开发的工具:
5.1 - Logging Scripts
5.2 - Enabling/Disabling Scripts
5.3 - Script Dependencies
5.4 - Standard Text Box Input
5.5 - Standard Event Comment Input
#------------------------------------------------------------------------------
5.1 - Logging Scripts
5.1 - 日志脚本
All SDK-compliant scripts should be logged. This is done by calling the
SDK.log(script, name, ver, date) method, where
所有加入SDK的脚本都必须被记录。调用
SDK.log(script, name, ver, date)
方法即可完成此工作。
script = script name
name = your name
ver = version
date = date last updated
#------------------------------------------------------------------------------
5.2 - Enabling/Disabling Scripts
5.2 - 启用/禁用 脚本
When a script is logged it is also enabled. A script can be enabled and
disabled using the following calls:
当脚本被登录,它就被启用了。也可以调用如下方法来启用/禁用一个脚本:
SDK.enable('Script Name')
SDK.disable('Script Name')
All non-default scripts (and code added to default scripts) must be enclosed
in an if statement that checks whether or not they have been enabled, as
follows:
非默认脚本(以及附加在默认脚本上的代码),无论它是否被启用,都必须被放入下面的
if statement(指那个判断SDK.state状态的if语句)中:
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.state('Script Name') == true
[Script or Code]
end
#--------------------------------------------------------------------------
# End SDK Enabled Test
#--------------------------------------------------------------------------
Keep in mind that this if statement can not continue on to other pages and
every page needs its own if statement testing the state of the script. As
well every script should have its own test.
记住这个if statement不能跨页面使用,每个页面都需要有自己的if statement用于检查脚本状态。
#------------------------------------------------------------------------------
5.3 - Script Dependencies
5.3 - 脚本引用
Any script that requires (i.e. has a dependency on) another script can check
if that dependency is met provided that the required script is set up before
the script in question. This would be done in the following way:
需要其他脚本支持的脚本,可以用下面的语句检测自己需要的脚本是否已经在自己之前被建立:
(比较拗口,就是说是不是引用了一个未被定义的脚本)
p 'Script Name not found' if SDK.state('Script Name') != true
#------------------------------------------------------------------------------
5.4 - Standard Text Box Input
5.4 - 标准文本输入??(没有领会这个方法的用途)
Any script that requires input from a database text field should use the
following:
如果需要从数据库文本中获取脚本运行的,可以使用下面的方法:
SDK.text_box_input(element, index)
where:
element = an object of the text field
index = the index in which your script call falls
参数说明:
element:文本对象,也就是下面格式的那种文本
index:被运行的文本内容索引号
The text field should be formatted in the following way:
数据库文本格式如下:
"Default value | script call | script call"
#------------------------------------------------------------------------------
5.5 - Standard Event Comment Input
5.5 - 标准事件输入??(亦没有领会)
Any script that requires input from an event comment should use the
following:
需要从获取事件参数的,可以使用下面的脚本:
SDK.event_comment_input(event, elements, trigger)
where:
event = an object of the event
elements = the number of elements the method is to process
trigger = the text value triggering the script to start processing
参数列表:
event:被获取参数的事件对象
elements:需要获取的事件代码量
trigger:事件触发条件
or
SDK.event_comment_input(page, elements, trigger)
where:
page = an object of the event.page
elements = the number of elements the method is to process
trigger = the text value triggering the script to start processing
参数列表:
event:被获取参数的Event.page对象
elements:需要获取的事件代码量
trigger:事件触发条件
The method returns nil if the trigger can not be found; otherwise, it
returns a list of the parameters from the event.
如果条件不存在则返回nil,否则返回事件参数列表。
#==============================================================================
=end |
|