作者 |
[原创[分享][深夜无眠Secondlife对象编程语言LSL汉化] 第五到第十章中英文 |
![缩小字体](images/ZoomOut.gif) |
文清 [博客] [个人文集]
![](images/avatars/82145599745e2dcd502156.jpg)
头衔: 海归上尉 年龄: 40 加入时间: 2006/12/21 文章: 883
海归分: 8578
|
|
作者:文清 在 项目找投资与合作 发贴, 来自【海归网】 http://www.haiguinet.com
Chapter 5. States 状态
All sc<x>ripts must have a 'default' state, which is the first state entered when the sc<x>ript starts. States contain event handlers that are triggered by the LSL virtual machine. All states must supply at least one event handler - it's not really a state without one.
When state changes, all callback settings are retained and all pending events are cleared.
所有的程序都有个默认状态, 这是指令第一次运行开始的状态. 状态包含有LSL虚拟机激发的事件指针. 所有的状态都必须赋予一个事件指针.没有事件指针的状态是不存在的.
当状态改变时,所有的调用设置都被保存,所有暂停的事件都被清除.
________________________________________
5.1. state_entry() 状态输入函数
The state_entry event occurs whenever a new state is entered, including program start, and is always the first event handled. No data is passed to this event handler.
每一个状态输入时候,状态输入事件都会发生,其中包括程序开始,第一个事件指针开始,没有数据传入这个指针内.
You will usually want to set callbacks for things such as timers and sensor in the state_entry() callback of the state to put your ob<x>ject into a useful condition for that state.
计算器和感应器需要在状态输入函数调用时设置好,以便对象适合于那种状态下使用.
Warning: It is a common mistake to assume that the state_entry() callback is called when you rez an ob<x>ject out of your inventory. When you derez an ob<x>ject into your inventory the current state of the sc<x>ript is saved, so there will not be a call to state_entry() during the rez. If you need to provide startup code every time an ob<x>ject is created, you should create a global function and call it from both state_entry() and the on_rez() callbacks.
警告:通常错误是认为调用状态输入函数是调用库里 你rez的对象. 当derez一个对象入库的时候,程序现在状态被保存,所以在rez过程中,没有调用状态输入函数.在创建一个对象时,需要提供启动代码的话,可以创建一个全局函数,然后同时调用函数state_entry() 和the on_rez()
// global initialization function.全局初始函数
init()
{
// Set up a listen callback for whoever owns this ob<x>ject.
//设定一个听的调用,无论谁拥有这个对象时.
key owner = llGetOwner();
llListen(0, "", owner, "");
}
default
{
state_entry()
{
init();
}
on_rez(integer start_param)
{
init();
}
listen(integer channel, string name, key id, string message)
{
llSay(0, "Hi " + name + "! You own me.");
}
}
________________________________________
5.2. state_exit()状态存在函数
You will want to provide a state_exit()if you need to clean up any events that you have requested in the current state, but do not expect in the next state.
如果需要在当年状态下,清除事件,就可以用状态存在函数.而不用考虑下一个状态.
default
{
state_entry()
{
state TimerState;
}
}
state TimerState
{
state_entry()
{
// set a timer event for 5 seconds in the future.
llSetTimerEvent(5.0);
}
timer()
{
llSay(0, "timer");
state ListenState;
}
state_exit()
{
// turn off future timer events.
llSetTimerEvent(0.0);
}
}
integer g_listen_control;
state ListenState
{
state_entry()
{
// listen for anything on the public channel
g_listen_control = llListen(0, "", NULL_KEY, "");
}
listen(integer channel, string name, key id, string message)
{
llSay(0, "listen");
state TimerState;
}
state_exit()
{
// turn off the listener
llListenRemove(g_listen_control);
}
}
The state_exit() handler is not called when an ob<x>ject is being deleted - all callbacks, handlers, sounds, etc, will be cleaned up automatically for you.
状态存在函数不会在一个对象删除时候调用. 所有的调用.指针,声音等都会对象删除时候自动清除.
________________________________________
5.3. States vs. Global variables状态vs全局变量
A state and a set of global variables can serve the same purpose, and each can be expressed in terms of the other. In general, you should prefer the use of states over global variables since states allow you to immediately assume sc<x>ript state without making comparisons. The less comparisons a sc<x>ript makes, the more regular code statements it can run.
一个状态和一套全局变量可以有同样效果,也可以互相转换.一般来说,最好用状态,而不是全局变量,因为状态允许马上设定程序状态而不用做比较.一个程序比较越少,它可以允许更通常的代码状态.
________________________________________
Chapter 6. Math 代数
6.1. Tables of Functions 函数表
Table 6-1. Trigonometry Functions
Function
llAbs
llAcos
llAsin
llAtan2
llCeil
llCos
llFabs
llFloor
llFrand
llPow
llRound
llSin
llSqrt
llTan
Table 6-2. Vector Functions
Function
llVecDist
llVecMag
llVecNorm
Table 6-3. Rotation Functions
Function
llAngleBetween
llAxes2Rot
llAxisAngle2Rot
llEuler2Rot
llRot2Angle
llRot2Axis
llRot2Euler
llRot2Fwd
llRot2Left
llRot2Up
llRotBetween
________________________________________
Chapter 7. Strings 串
7.1. Tables of Functions
Table 7-1. String Functions
Function
llba<x>se64ToString
llDeleteSubString
llGetSubString
llInsertString
llMD5String
llStringLength
llSubStringIndex
llStringToba<x>se64
llToLower
llToUpper
llXorba<x>se64Strings
________________________________________
Chapter 8. Lists 历表
8.1. Tables of Functions
Table 8-1. List Functions
Function
llCSV2List
llDeleteSubList
llGetListEntryType
llGetListLength
llList2CSV
llList2Float
llList2Integer
llList2Key
llList2List
llList2ListStrided
llList2Rot
llList2String
llList2Vector
llListFindList
llListInsertList
llListRandomize
llListSort
llParseString2List
________________________________________
Chapter 9. Communication 交流
9.1. Tables of Functions
Table 9-1. In World Functions
Function
llListen
llListenControl
llListenRemove
llSay
llShout
llWhisper
Table 9-2. Messaging Functions
Function
llEmail
llGetNextEmail
llInstantMessage
________________________________________
Chapter 10. Inventory 库
10.1. Tables of Functions
Table 10-1. Inventory Functions
Function
llAllowInventoryDrop
llGetInventoryCreator
llGetInventoryKey
llGetInventoryName
llGetInventoryType
llGetInventoryNumber
llGetInventoryPermMask
llGetNotecardLine
llGiveInventory
llGiveInventoryList
llRemoveInventory
llRequestInventoryData
llRezob<x>ject
llRezAtRoot
作者:文清 在 项目找投资与合作 发贴, 来自【海归网】 http://www.haiguinet.com
|
|
|
返回顶端 |
|
![](templates/cnphpbbice/images/spacer.gif) |
|
-
[原创[分享][深夜无眠Secondlife对象编程语言LSL汉化] 第五到第十章中英文 -- 文清 - (6346 Byte) 2007-1-21 周日, 09:31 (1306 reads) |
|
|
您不能在本论坛发表新主题, 不能回复主题, 不能编辑自己的文章, 不能删除自己的文章, 不能发表投票, 您 不可以 发表活动帖子在本论坛, 不能添加附件可以下载文件, |
|
|