實驗準備:
- 請準備一盒衛生紙
- 一打A片
實驗只需要兩個Object即可,我分別稱之為Object1和Object2。
Object1程式碼如下:
integer count=0;
default
{
state_entry()
{
while(TRUE)
{
count++;
llSay(99,(string)count);
if(count%10==0)
count=0;
}
}
}
是的,這是無限次在99頻道喊叫的有碼Object……Zzz
總之,當他喊到10以後,又會重喊。
Object2程度碼如下:
default
{
state_entry()
{
llListen(99,"","","");
}
listen(integer ch,string name,key id,string message)
{
llSay(0,"state default:"+message);
if((integer)message%10==0)
state test;
}
}
state test
{
state_entry()
{
llListen(99,"","","");
}
listen(integer ch,string name,key id,string message)
{
llSay(0,"state test:"+message);
if((integer)message%10==0)
state default;
}
}
簡單來講,這個Object2的程式碼去聽99頻道,也就是Object1喊的數字,一喊到10就轉換到test state。而test state一喊到10就回到default state。
實驗結果如下:
[7:24] Object: state default:1
[7:24] Object: state default:2
[7:24] Object: state default:3
[7:24] Object: state default:4
[7:24] Object: state default:5
[7:24] Object: state default:6
[7:24] Object: state default:7
[7:24] Object: state default:8
[7:24] Object: state default:9
[7:24] Object: state default:10
[7:24] Object: state test:9
[7:24] Object: state test:10
[7:24] Object: state default:9
[7:24] Object: state default:10
[7:24] Object: state test:4
[7:24] Object: state test:5
[7:24] Object: state test:6
[7:24] Object: state test:7
[7:24] Object: state test:8
[7:24] Object: state test:9
[7:24] Object: state test:10
[7:24] Object: state default:1
[7:24] Object: state default:2
[7:24] Object: state default:3
[7:24] Object: state default:4
[7:24] Object: state default:5
[7:24] Object: state default:6
[7:24] Object: state default:7
[7:24] Object: state default:8
[7:24] Object: state default:9
[7:24] Object: state default:10
[7:24] Object: state test:2
[7:24] Object: state test:3
[7:24] Object: state test:4
[7:24] Object: state test:5
[7:24] Object: state test:6
[7:24] Object: state test:7
[7:24] Object: state test:8
[7:24] Object: state test:9
[7:24] Object: state test:10
[7:24] Object: state default:1
[7:24] Object: state default:2
[7:24] Object: state default:3
[7:24] Object: state default:4
[7:24] Object: state default:5
[7:24] Object: state default:6
[7:24] Object: state default:7
[7:24] Object: state default:8
[7:24] Object: state default:9
[7:24] Object: state default:10
雖然llSay會delay,但是,delay歸delay,他還是會say,而且say的時間不會晚得太離普,所以把say很晚的問題先排除。在這個前提下,注意紅色的state test,它確實有遺漏一些資料,因此實驗結果證明了我的假設—state轉換會造成資訊遺漏。
沒有留言:
張貼留言