trap of llKey2Name(llKey2Name の罠)

ちゃんとLSL wiki 読んでおけばわかる恥ずかしい罠にはまってしまった。sensor を使って見つけたobject の名前とそのオーナー名を表示するっていうスクリプトを書いていたら、なぜか

I was caught in the trap of llKey2Name.if i read detail of LSL wiki, i have been caught…. i wrote code sensor script. it search object in there and show objects name and owner name of object. but script cannot get owner name from key exclude my key and my friend… following is its script.

自分の名前と知り合いの名前(?)しかkeyから名前を拾えないとういう症状に。


touch_start(integer num)
{
llSensor("", NULL_KEY, ACTIVE|PASSIVE|SCRIPTED, 96, 2*PI);
}
sensor(integer total_number)
{
items = [];
integer i;
string str;
for(i=0;i< total_number;i++)
{
str = llDetectedName(i);
str += llKey2Name(llGetOwnerKey(llDetectedKey(0)));
llSay(DEBUG_CHANNEL,str)
}
}

こんな感じのコード。llDetectedKey でlist に溜めておいて、後で見たほうがいいのかなぁとか、悩んだ末に

after i was thinking for long time…

LSL wikiのllKey2Nameにて(llKey2Name in LSL wiki)

If the object or agent identified by the key id is in the same simulator as the object containing the script,  ….

なんて行を発見。i found that sentence.

 the key id is in the same simulator

!!

 in the same simulator

….同じsim にいるagent やobject の名前しか引けないらしい。しかも 最初の行に書いてありますよ!

script can get name from  key in the same sim….
しかも

See llRequestAgentData for a (much slower) way to use the dataserver to get the name of an agent even outside the sim or offline.

とか見えます。無駄に試行錯誤する前にちゃんとドキュメントを読めと。

よく考えると..クライアントでコンパイルされたscript はそのsim にupload され、そして字実行時もevent もsimから受け取る。そしてsim の動作しているserver を越える通信てよく考えたら dataserver 等からしか受け付けない作りなわけで当たり前な気がしてきました。

thinking detail of imprementation of LSL, Scripts was compiled in SL client and Scripts was uploaded to SIM.  Script recive event from only SIM  at runtime.

communication over SIM is used by only “dataserver”  and others. its reason is

well known …. if i think detail of it…

Leave a comment