ソラマメブログ

2008年03月09日

walking のスクリプティング講座5 - 留守番メイド

時たまどこか行ってしまって まだ 問題はあるんだが
-----
留守番は結構役に立っているので 取り上げることにしよう
-----
ベースはフェアリー
-----
それに訪問者を記録する機能を付けた
-----
一応挨拶もするけど w
-----
解説は次回以降だ w
//
// File: steambit_maid_for_ouchi.lsl
// Date Author number of nodes
// 2007/10/4 Walking Lint 88
// 2007/10/4 Walking Lint 79 (steambit_maid_for_sorority_LSL->steambit_maid_for_ouchi)
// 2007/9/29 walkinglint 70
// 2007/9/29 walkinglint 70 (steambit_maid_for_sorority->steambit_maid_for_sorority_LSL)
// 2007/9/22 walkinglint 70
// 2007/9/22 walkinglint 67 (steambit_maid->steambit_maid_for_sorority)
// 2007/9/22 walkinglint 67
// 2007/9/17 walkinglint 54
// 2007/9/17 walkinglint 19 (follower_pet->steambit_maid)
// 2007/8/5 walkinglint 19
// 2007/8/3 Walking Lint 18
// 2007/8/3
//
//
// ================================
// Faily Script
// (C) 20070325 oitake
// ================================ ;
//
// http://oitake.jugem.jp/?eid=118
key owner;
string notecard_name = "message_list";
list message_list;
integer irasshaimase_message_idx = 0;
integer message_idx;
integer read_line;
key query_id;
list name_list;
list time_list;
string owner_name;
integer i;
string name;
vector first_position;
integer handler;
integer listening = FALSE;
string get_time() {
integer second = llFloor(llGetWallclock());
integer min = llFloor(second / 60);
second = second - (min * 60);
integer hour = llFloor(min / 60);
min = min - (hour * 60);
hour = hour + 16;
if (hour > 24) {
hour = hour - 24;
}
string shour = (string)hour;
string smin;
string ssecond;
if (min < 10) {
smin = "0" + (string)min;
} else {
smin = (string)min;
}
if (second < 10) {
ssecond = "0" + (string)second;
} else {
ssecond = (string)second;
}
return shour + ":" + smin + ":" + ssecond;
}
default {
state_entry() {
message_list = [];
if (llGetInventoryType(notecard_name) == INVENTORY_NOTECARD) {
query_id = llGetNotecardLine(notecard_name, read_line); // request first line
} else {
llOwnerSay("Notecard " + notecard_name + " is not found");
}
name_list = [];
time_list = [];
owner = llGetOwner();
owner_name = llKey2Name(owner);
name_list = llListInsertList(name_list, [owner_name], 0);
time_list = llListInsertList(time_list, [llGetDate() + " " + get_time()], 0);
llParticleSystem
([
PSYS_PART_FLAGS,PSYS_PART_EMISSIVE_MASK | PSYS_PART_INTERP_COLOR_MASK
        | PSYS_PART_INTERP_SCALE_MASK | PSYS_PART_WIND_MASK,
PSYS_PART_MAX_AGE,1.0,
PSYS_PART_START_ALPHA,1.0,
PSYS_PART_END_ALPHA,0.0,
PSYS_PART_START_COLOR,<1.0,1.0,1.0>,
PSYS_PART_END_COLOR,<1.0,1.0,0.0>,
PSYS_PART_START_SCALE,<0.125,0.125,0.125>,
PSYS_PART_END_SCALE,<0.0,0.0,0.0>,
PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_EXPLODE,
PSYS_SRC_ACCEL,<0.0,0.0,-1.0>,
PSYS_SRC_BURST_RATE,0.0,
PSYS_SRC_BURST_PART_COUNT,1,
PSYS_SRC_BURST_RADIUS,0.0,
PSYS_SRC_BURST_SPEED_MIN,0.1,
PSYS_SRC_BURST_SPEED_MAX,0.2,
PSYS_SRC_MAX_AGE,0.0,
PSYS_SRC_INNERANGLE,0.0,
PSYS_SRC_OUTERANGLE,PI,
PSYS_SRC_TEXTURE,"Kirameki"
]);
llSetStatus(STATUS_PHYSICS, TRUE);
llMoveToTarget(llGetPos(), 1.5);
llSensorRepeat("", NULL_KEY, AGENT, 20.0, PI, 2);
llSetTimerEvent(5.0); // customize time interval if set too long then bit may be lost following customer
handler = llListen(0, "", NULL_KEY, "");
listening = TRUE;
}
on_rez(integer param) {
llResetScript();
}
dataserver(key queryid, string data) {
if (queryid == query_id) {
if (data != EOF) {
// process data
if (llStringLength(data) != 0) {
message_list = llListInsertList(message_list, [data], llGetListLength(message_list));
}
read_line++;
query_id = llGetNotecardLine(notecard_name, read_line);
} else {
llOwnerSay("Loading complete.");
}
}
}
listen(integer channel, string name, key id, string message) {
if (message == "visitor") {
for (i = 0; i < llGetListLength(name_list); i++) {
llOwnerSay(llList2String(name_list, i) + " " + llList2String(time_list, i));
}
}
}
sensor(integer num_detected) {
vector left = llRot2Left(llDetectedRot(0));
integer l;
message_idx = irasshaimase_message_idx;
for (i = 0; i < num_detected; i++) {
name = llDetectedName(i);
if ((l = llListFindList(name_list, [name])) == -1) {
llMoveToTarget(llDetectedPos(i) + left * 0.5 + <0.0, 0.0, 1.0>, 1.5);
// customize duration time with last paramete
// see http://rpgstats.com/wiki/index.php?title=LlMoveToTarget
llSay(0, name + " " + llList2String(message_list, 0));
name_list = llListInsertList(name_list, [name], llGetListLength(name_list));
time_list = llListInsertList(time_list, [llGetDate() + " " + get_time()], llGetListLength(time_list));
} else if (name == owner_name) {
first_position = llDetectedPos(i) + left * 0.5 + <0.0, 0.0, 1.0>;
} else {
time_list = llListReplaceList(time_list, [llGetDate() + " " + get_time()], l, l);
}
}
if (listening == FALSE) {
handler = llListen(0, "", NULL_KEY, "");
listening = TRUE;
}
}
no_sensor() {
if (listening == TRUE) {
llListenRemove(handler);
listening = FALSE;
}
}
timer() {
llMoveToTarget(first_position, 0.75);
}
}

(続く)

同じカテゴリー(walking のスクリプティング講座)の記事
 プロフィール写真の表示に問題 (2009-11-30 20:55)
 ミニ太陽系 (2009-03-21 06:03)
 関数から文字列を返したら何か問題になる? (2009-03-18 18:02)
 llListFindList って型って関係ないんだったっけ (2009-03-18 14:02)
 夏時間(PDT)の実験 (2009-03-08 22:04)
 15パズルの作り方(その3) (2009-03-08 06:03)
上の画像に書かれている文字を入力して下さい
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。