walkinglint
2008年07月14日 21:20
//必要であれば裏側にもテクスチャ設定する のと 回転を指示する よう改造している
// File: TextureBrowser.lsl
// Date Author number of nodes
// 2008/7/14 walkinglint 51
// 2008/7/13 walkinglint 20
// 2008/7/13 walkinglint 18 (TexturePresenter->TextureBrowser)
// 2008/6/20 walkinglint 18
//
integer num_of_texture;
integer num_of_button = 64;
integer i;
integer j;
integer SET_FRONT = 1;
integer SET_BACK = 2;
integer TURN2BACK = 3;
integer TURN2FRONT = 4;
load_textures() {
num_of_texture = llGetInventoryNumber(INVENTORY_TEXTURE);
for (i = 0; i < num_of_button; i++) {
if (i < num_of_texture) {
string nm = llGetInventoryName(INVENTORY_TEXTURE, i);
key ky = llGetInventoryKey(nm);
if (ky != NULL_KEY) {
llMessageLinked(2 + i, SET_FRONT, nm, ky);
} else {
llMessageLinked(2 + i, SET_FRONT, nm, "89556747-24cb-43ed-920b-47caed15465f");
llOwnerSay(nm + " may be no copy or no modify or no transfer");
}
} else {
llMessageLinked(2 + i, SET_FRONT, "", "89556747-24cb-43ed-920b-47caed15465f");
}
}
for (i = 0; i < num_of_button; i++) {
j = i + num_of_button;
if (j < num_of_texture) {
string nm = llGetInventoryName(INVENTORY_TEXTURE, j);
key ky = llGetInventoryKey(nm);
if (ky != NULL_KEY) {
llMessageLinked(2 + i, SET_BACK, nm, ky);
} else {
llMessageLinked(2 + i, SET_BACK, nm, "89556747-24cb-43ed-920b-47caed15465f");
llOwnerSay(nm + " may be no copy or no modify or no transfer");
}
} else {
llMessageLinked(2 + i, SET_BACK, "", "89556747-24cb-43ed-920b-47caed15465f");
}
}
}
default {
state_entry() {
state front;
}
}
state front {
touch_start(integer total_number) {
if (llDetectedLinkNumber(0) == LINK_ROOT) {
load_textures();
} else {
llMessageLinked(LINK_ALL_CHILDREN, TURN2BACK, "", NULL_KEY);
state back;
}
}
}
state back {
touch_start(integer total_number) {
if (llDetectedLinkNumber(0) == LINK_ROOT) {
load_textures();
}
llMessageLinked(LINK_ALL_CHILDREN, TURN2FRONT, "", NULL_KEY);
state front;
}
}
//ここで回転の角度を 2回に分けているけれど これ 一度でやるとちょうど 180度なので 思った向きに回転してくれなかったのだ...
// File: TextureBrowserButton.lsl
// Date Author number of nodes
// 2008/7/14 walkinglint 39
// 2008/7/13 walkinglint 8
//
integer SET_FRONT = 1;
integer SET_BACK = 2;
integer TURN2BACK = 3;
integer TURN2FRONT = 4;
string front_title = "";
string back_title = "";
integer is_front = TRUE;
default {
state_entry() {
is_front = TRUE;
}
link_message(integer sender_num, integer num, string str, key id) {
if (num == TURN2BACK) {
llSetLocalRot(llGetLocalRot() * llEuler2Rot());
llSleep(0.1);
llSetLocalRot(llGetLocalRot() * llEuler2Rot());
llSleep(0.1);
llSetText(back_title, , 1.0);
is_front = FALSE;
} else if (num == TURN2FRONT) {
llSetLocalRot(llGetLocalRot() * llEuler2Rot());
llSleep(0.1);
llSetLocalRot(llGetLocalRot() * llEuler2Rot());
llSleep(0.1);
llSetText(front_title, , 1.0);
is_front = TRUE;
} else if (num == SET_FRONT) {
front_title = str;
if (is_front) {
llSetText(str, , 1.0);
}
llSetTexture(id, 2);
} else if (num == SET_BACK) {
back_title = str;
if (!is_front) {
llSetText(str, , 1.0);
}
llSetTexture(id, 4);
}
}
}