Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Animated Texture Slideshow

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-04-2008 11:41
i've posted this in both the scripting tips and products wanted threads. Maybe i'm not using the right search words or whatever the reason is, i can't seem to find this script. I've checked Xstreet and OnRez as well.

I'm looking for an animated texture slideshow/vendor script. Preferebly notecard configurable, the script would change the texture and the texture animation settings for that texture. i would use a simple picture changer, but most of my animated textures don't have the same layout. It can be just a slideshow, but if it had vendor capability that would rock.
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
10-04-2008 16:45
the only suggestion I can make is get in touch with teachers/trainers in SL, most classes I have been to use a device like this, I think, but then again they may just be loading the texture themselves.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-04-2008 19:57
it was actually easier than i thought. here's a very simple version. if anyone has any input they'd like to add, please post it here. i may add it to the library later. an idea i didn't use in this script is possibly adding an index to the texture name for changing the timer according to how long it takes to play the anim.

edited to add this comment: the only drawback is, of course some animations need different size prims to look right. that could be another possibility to add the config list. but you can only do so much as llParseString2List is limited to 8 indexes

From: someone

// Animated Texture Changer
// by Ruthven Willenov
//
//Instructions: Simply Name the Anim Texture According to this example: "fireanim#3#2#2.5" (name#sizex#sizey#fps) the script will split the name up according to where the "#" sign is, and use the derived indexes to set the //texture anim. I also have it set to change the color to black in between pictures to avoid seeing odd transitions.
//
float Timer = 10; // speed in seconds
integer face = 0;//which face to display the texture on
//
//
integer choice;
default
{
state_entry()
{
llSetTimerEvent(Timer);
}

timer()
{
integer number = llGetInventoryNumber(INVENTORY_TEXTURE);
choice ++;
if (choice == number)
choice = 0;

string name = llGetInventoryName(INVENTORY_TEXTURE, choice);
list config = llParseString2List(name,["#"],[]);
integer sizex = llList2Integer(config,1);
integer sizey = llList2Integer(config,2);
float rate = llList2Float(config,3);
if (name != "";)
llSetColor(<0,0,0>,face);//set the color to black
llSetTexture(name, face);//changes the texture
llSetColor(<1,1,1>,face);//changes the color back to white so you can see the texture
llSetTextureAnim(ANIM_ON | LOOP, face, sizex, sizey, 0, 0,rate);//sets the anim according to the rules set in the texture name
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-05-2008 04:06
hmmm... llCSV2List() isn't limited to only 8 entries AFAIK. Let's use it instead of llParseString2List() and let's add a price.

I kept Ruthven's method to use the name of the textures to store data but that can be easily adapted to use a notecard instead.

The working principle of the vendor is simple: When you see a texture you like, you click to freeze the slideshow and then you can pay.

Another click will resume the slideshow to the next texture. The same happens when you buy a texture or after a timeout (set to 4 minutes).

The unplanned feature: A double-click makes the slideshow jump to the next texture.

I would strongly suggest something more subtle than llWhisper() to warn the customer about what the vendor is doing. ;-)

(Just quote me to retrieve the formating of the script.)

----------------------------------------------------------------------
// Textures name: "whatever,x_size,y_size,rate,price"
//
float Delay = 20.0; // in seconds for each anim
integer Side = 0; // Which side? (Can be ALL_SIDES.)
//
string Name;
integer Texture = 0;
integer Price = 0;

uuFade(integer direction)
{
if (direction > 0)
{
float f = 0.0;
for (; f <= 1.0; f += 0.01)
{
llSetColor(<f, f, f>, Side);
}
}
else if (direction < 0)
{
float f = 1.0;
for (; f >= 0.0; f -= 0.01)
{
llSetColor(<f, f, f>, Side);
}
}
}

uuAnimateTexture()
{
integer num = llGetInventoryNumber(INVENTORY_TEXTURE);
if (num)
{
Name = llGetInventoryName(INVENTORY_TEXTURE, Texture);
list params = llCSV2List(Name);
if (llGetListLength(params) == 5)
{
Price = llList2Integer(params, 4);
uuFade(-1);
llSetTexture(Name, Side);
integer xx = llList2Integer(params, 1);
integer yy = llList2Integer(params, 2);
llSetTextureAnim(ANIM_ON | LOOP, Side, xx, yy,
0.0, (float)(xx * yy),
llList2Float(params, 3));
uuFade(1);
}
Texture = (Texture + 1) % num;
}
}

default
{
on_rez(integer param) { llResetScript(); }

state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}

run_time_permissions(integer perms)
{
if (perms & PERMISSION_DEBIT)
{
state slideshow;
}
else
{
llOwnerSay("Debit permission is mandatory!" + EOF);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
}
}

state slideshow
{
on_rez(integer param) { llResetScript(); }

state_entry()
{
llSetTouchText("Buy";);
llSetTimerEvent(Delay);
llWhisper(0, "Slideshow is running...";);
uuAnimateTexture();
}

timer()
{
uuAnimateTexture();
}

touch_start(integer num)
{
//if (Price)
//{
llSetTimerEvent(0.0);
state buying;
//}
//else // Freebies?
//{
// llGiveInventory(llDetectedKey(0), Name);
//}
}
}

state buying
{
on_rez(integer param) { llResetScript(); }

state_entry()
{
llWhisper(0, "Richt-click to pay";);
llSetTouchText("Slide";);
llSetPayPrice(PAY_HIDE, [Price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llSetTimerEvent(240.0); // 4 minutes to buy
}

timer()
{
llSetTimerEvent(0.0); // Time Out!
Texture = (Texture + 1) % llGetInventoryNumber(INVENTORY_TEXTURE);
state slideshow; // Resume
}

money(key id, integer amount)
{
llSetTimerEvent(0.0);
if (amount < Price)
{
llGiveMoney(id, amount);
}
else if (amount > Price)
{
llGiveMoney(id, amount - Price);
}
llGiveInventory(id, Name);
Texture = (Texture + 1) % llGetInventoryNumber(INVENTORY_TEXTURE);
state slideshow; // Resume
}

touch_start(integer num)
{
llSetTimerEvent(0.0);
Texture = (Texture + 1) % llGetInventoryNumber(INVENTORY_TEXTURE);
state slideshow; // Resume
}
}
----------------------------------------------------------------------
Compiled and tested in world. Mono/Havok 4 compatible, etc, etc :P
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-05-2008 06:17
awesome, thanks Kaluura. actually i wasn't planning on selling the textures themselves, just a means of displaying them rather than flipping thru prims. i would actually be silling the prim with the texture anim already applied. so what i did was set the object's name exactly the same as the name index of the texture. not in world to check exactly what i did at the moment. something like

string item = llList2String(name,0);

keep in mind the script i displayed is the basic version. i was using a next and back button the my vendor version, rather than a timer, and i nearly fell asleep at my desk trying to figure out how to implement the timer and have it pause when the user makes a choice
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369