Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Texture cycler with press & hold trigger - select individual textures

Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
04-05-2007 14:26
This is an outgrowth of my press & hold trigger code.

How this works is, you load up a prm with textures and the script. The prim will automatically display the first texture (as expected) and each mouse click will rotate to the next one.

Where this is different is, if you hold down the mouse key for two seconds, you get a dialog asking if you want to take the texture. This can be handy if you are on a building project and want to keep a hot list of textures handy in your "Recent Items" tab without having a lot of unwanted textures in inventory (which can slow you down by contributing to inventory lag and also by having to constantly search for the exact texture...). With a little more code jiggery, someone could also add a pay method allowing buyers to purchase individual textures instead of having to buy (or choose not to buy) complete sets.

Revisions:
-----------------------------------------------
4/11/2007 - auto reset on inventory drop

CODE

// set these to whatever values you wish
integer myChannel = 123;
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);
llSetText(llGetObjectName() + "\n" + (string)(n+1) + " of " + (string)count + " - " + texture_name, <1.0,1.0,1.0>, 1.0);
}
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()
{
listenHandle = llListen(myChannel,"","","");
elapsed = 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)
{
if (llDetectedKey(0) == llGetOwner()) {
elapsed = llGetAndResetTime();
}
}
touch(integer num_detected)
{
if (llDetectedKey(0) == llGetOwner()) {
elapsed = llGetTime();
if (elapsed >= trigger_time) {
agent_key = llDetectedKey(0);
touch_hold();
}
}
}
touch_end(integer num_detected)
{
if (elapsed < trigger_time) {
i += 1;
if (i >= count) i = 0;
texture_name = llGetInventoryName(INVENTORY_TEXTURE, i);
display(i);
}
}
timer()
{
llSetTimerEvent(0.0);
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();
}
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
04-09-2007 04:59
/54/85/176343/1.html
_____________________
i've got nothing. ;)
Cat Fratica
Miaow...
Join date: 28 Dec 2006
Posts: 153
Cool - thanks
05-01-2007 15:48
Just what I wanted...

I have a club with 12 picture boards - I change them for each event, so if its a 'Best in Black' or 'Best in Red' event, for example, I drag and drop appropriate pictures to each one. This will enable me to have all the textures stored and displayed as required by either me or partner or one of my staff (hopefully).

Ideally I would like to change them all at once, with a voice command or having them all 'linked' in some way - any ideas?

Will make new post with this question I think...

Thanks

Cat x