helloworld program of Linden Scripting Language

本文提供了Linden Scripting Language (LSL) 的几个实用示例,包括默认状态入口脚本、用于坐姿传送的功能脚本及一个简单的单词查询功能。通过这些示例,读者可以了解如何使用 LSL 进行基本的交互设计。
ContractedBlock.gif ExpandedBlockStart.gif Code
default
{
    state_entry()
    {
               
// llResetScript();
        llListen(0,"","","");
        
// listens for just the owner, on channel 0
    }

    listen(integer chan, 
string name, key id, string mess)
    {
        
if(mess == "hello"){
           llOwnerSay(
"hello world!");
           llOwnerSay((
string)id);
           llOwnerSay(name);
           llOwnerSay((
string)chan);
        }
    }
}

 

sit for teleport script

 

ContractedBlock.gif ExpandedBlockStart.gif Code
vector target=<17,17,129>// Enter the target coordinates here!!! 
default 

    state_entry() 
    { 
        llSetText(
"talking in the sky",<255,255,255>,5); 
        llSetSitText(
"Teleport"); 
        rotation my_rot
=llGetRot(); 
        llSitTarget((target 
- llGetPos()) / my_rot,ZERO_ROTATION / my_rot); 
    } 
    changed(integer change) 
    { 
        llUnSit(llAvatarOnSitTarget()); 
    } 

 

 简单的单词查询功能

 

ContractedBlock.gif ExpandedBlockStart.gif Code
key url;
default
{
    state_entry()
    {
        llListen(
1,"",NULL_KEY,"");
    }
    
    touch_start(integer totalnums){
        llOwnerSay(
"type the unfamilar words here for translate.For example:");
        llOwnerSay(
"/1 hello"); 
    }
    
    listen( integer channel, 
string name, key id, string message )
    {
        
//llOwnerSay(message);
        
//url = llHTTPRequest("http://dict.cn/mini.php?q=" + message + "&utf8=true",[],"");
        
//llWhisper(0,message);
        url = llHTTPRequest("http://tstring.com.cn/dict.aspx?q="+llEscapeURL(message)+"&o=korn",[],"");
        
//llWhisper(0,"http://tstring.com.cn/dict.aspx?q="+ message);
    }
    
    http_response(key request_id, integer status, list metadata, 
string body)
    {
        
if (request_id == url);
        {
            
//llOwnerSay((string)status);
            llOwnerSay(body);
        }
    }
}

 

http://oz.slinked.net/history/lsl2_reference.htm

http://lslwiki.net/lslwiki/wakka.php?wakka=glossary

转载于:https://www.cnblogs.com/kkun/archive/2009/10/03/1577720.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值