05-02-2008 05:54
Single prim texture vendor, allows users to move forward, backwards, and to retrieve stored textures.

Instructions for creation:
1. rez a cube, setting x to 0.2 and y & z to 1. These dimensions are guidelines - you can make them any size you wish.
2. Optional: set texture color to black for all faces but the one you will be viewing the textures from, make that one white. This will prevent the textures from being shown on the other faces.
3. Place textures you wish to store in the contents tab, along with this script.
4. Reset the script (under the Tools menu) while the prim is selected.
5. Set object name to something appropriate for the types of textures stored, such as "floors" or "wallpaper".
6. Set the description to some unique integer number. This will be used by the dialog control for communications, so the numbers must all be different when you have multiple organizers out.

Instructions for use:
single click advances to the next texture
double click moves to the previous texture
hold the left mouse button down for 2 seconds to retrieve the texture

CODE

// Advanced texture cycler
// 10/1/2007 Soen Eber
// includes double click code by Jimmy Roo
//
// Operation:
// left-click to advance to next texture
// double left-click to change to previous texture
// left-click and hold for 2 seconds to retrieve texture

// set these to whatever values you wish
integer myChannel;
integer wait_for_click = FALSE;
float trigger_time = 2.0;
float idle_time = 10.0;
list menu = ["Get Texture"];

// used for controlling command entry
float elapsed = 0.0;
integer listenHandle;

// used for texture cycling
integer count;
integer i;
string texture_name;

// used to retrieve texture
key agent_key;

display(integer n)
{
llSetTexture(texture_name, ALL_SIDES);
llWhisper(0, (string)(n+1) + " of " + (string)count + " - " + texture_name);
}
get_texture()
{
llGiveInventory(agent_key, texture_name);
}
touch_hold()
{
elapsed = llGetAndResetTime();
llListenControl(listenHandle, TRUE); // ...enable
llSetTimerEvent(idle_time);
llDialog(llDetectedKey(0), texture_name, menu, myChannel);
}
default
{
state_entry()
{
myChannel = (integer)llGetObjectDesc();
listenHandle = llListen(myChannel,"","","");
elapsed = 0.0;
llSetText("",<1,1,1>, 0.0);
count = llGetInventoryNumber(INVENTORY_TEXTURE);
i = 0;
texture_name = llGetInventoryName(INVENTORY_TEXTURE, 0);
display(i);
}
on_rez(integer startup_param)
{
llResetScript();
}
touch_start(integer num_detected)
{
elapsed = llGetAndResetTime();
}
touch(integer num_detected)
{
elapsed = llGetTime();
if (elapsed >= trigger_time) {
agent_key = llDetectedKey(0);
touch_hold();
}
}
touch_end(integer num_detected)
{
if (elapsed < trigger_time) {
if (wait_for_click == TRUE) {
llSetTimerEvent(0);
wait_for_click = FALSE;
i -= 1;
if (i < 0) i = (count - 1);
texture_name = llGetInventoryName(INVENTORY_TEXTURE, i);
display(i);
}
else {
wait_for_click = TRUE;
llSetTimerEvent(0.3);
}
}
}
timer()
{
llSetTimerEvent(0.0);
if (wait_for_click == TRUE) {
wait_for_click = FALSE;
i += 1;
if (i >= count) i = 0;
texture_name = llGetInventoryName(INVENTORY_TEXTURE, i);
display(i);
}
else {
llListenControl(listenHandle, FALSE); // ...disable
}
}
listen(integer chan, string name, key id, string cmd)
{
if (llListFindList(menu, [cmd]) != -1) {
if (llToUpper(cmd) == "GET TEXTURE") {
get_texture();
}
}
}
}