Jump to content
You are about to reply to a thread that has been inactive for 1535 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted (edited)

Hello! I'm trying to make a script for a three buttons HUD and a receiver - the GIF texture animator. I sorted them by 4 textures in 3 lists with the same number of frames in each list. and since it is necessary to change textures, I need to use a timer. but I ran into such a problem that it looks like I need to use 3 timers (?). can this be somehow avoided? I used this script as a basis, but it is only for one list. This is the original script:

integer count;
list texture=[

// UUID GIF LIST:

"631a2817-9221-7eb2-912c-9e05732fe690",
"1285e7d6-f4c9-0110-cda5-3be688765d99",
"f77a5416-07aa-d3a1-a2cc-cee318ec7dda",
"0f673d21-16bc-fb53-6014-aea127c71150"

];

integer FRAMES_X = 4; // Number of frames horizontally
integer FRAMES_Y = 2; // Number of frames vertically
integer ALL_FRAMES = 8; // Number of all frames
integer ANIM_RATE = 10; // Animation rate (speed)
integer TIMER = 3; // Timer to change texture
integer SHOWN_FACE = 2; // Shown face number (to display)
integer HIDDEN_FACE = 0; // Hidden face number (to preload)

default
{

    state_entry()
        {   
        llSetTimerEvent(TIMER); 
        }
        
    timer() 
        {
                llSetTexture(llList2Key(texture,count), SHOWN_FACE);
                ++count;
                count %=llGetListLength(texture);
        llSetTextureAnim(ANIM_ON | LOOP, SHOWN_FACE, FRAMES_X, FRAMES_Y, 0.0, ALL_FRAMES, ANIM_RATE);
        llSetTexture(llList2Key(texture,count), HIDDEN_FACE);
                            
    }
}

And here is what i got so far :P

// LISTENER 
integer count;
list texture1 = [

    // UUID GIF LIST1:

    "cb7e2af3-8849-8f2d-b210-7abca03e3bca",
    "6ae33bf3-9217-9046-5827-28774f63253d",
    "d8a470ec-6856-0603-9a68-94f27248555f",
    "c2668d35-03e4-03b1-3e09-5cab249cc6aa"

];

list texture2 = [

    // UUID GIF LIST2:

    "e8a6c9ef-b460-7fea-309e-12ceb4888b55",
    "c153f141-0222-1a9e-e3d2-00694ab5d2cb",
    "ef59b79c-e586-0158-e6b0-8c86114bd6bf",
    "1d60bb24-b2b6-3dec-b873-6311392dea16"

];

list texture3 = [

    // UUID GIF LIST3:

    "c3511757-3584-93c5-655a-3cdd68b7f2fb",
    "8c8bfb5b-42b0-6d22-4c61-6e343a850ebb",
    "9b784a25-9626-b878-a58f-5c8cf63c01dd",
    "a1dc904f-06ec-ff9b-0a85-d334b5556589"

];

integer FRAMES_X_1 = 4; // Number of frames horizontally
integer FRAMES_Y_1 = 2; // Number of frames vertically
integer ALL_FRAMES_1 = 8; // Number of all frames

integer FRAMES_X_2 = 2; // Number of frames horizontally
integer FRAMES_Y_2 = 2; // Number of frames vertically
integer ALL_FRAMES_2 = 4; // Number of all frames

integer FRAMES_X_3 = 5; // Number of frames horizontally
integer FRAMES_Y_3 = 2; // Number of frames vertically
integer ALL_FRAMES_3 = 10; // Number of all frames

integer ANIM_RATE = 10; // Animation rate 

integer TIMER = 3; // Timer to change texture
integer SHOWN_FACE = 2; // Shown face number (to display)
integer HIDDEN_FACE = 0; // Hidden face number (to preload)

default
{
    state_entry()
    {
        llListen(-54321, "", "", ""); // Listen to anybody saying anything on channel -54321
    }
    
    listen(integer channel, string name, key id, string msg)
    {
        if (msg == "gif1")
        {
            llSetTexture(llList2Key(texture1, count), SHOWN_FACE);
            ++count;
            count %= llGetListLength(texture1);
            llSetTextureAnim(ANIM_ON | LOOP, SHOWN_FACE, FRAMES_X_1, FRAMES_Y_1, 0.0, ALL_FRAMES_1, ANIM_RATE);
            llSetTexture(llList2Key(texture1, count), HIDDEN_FACE);
            llSetTimerEvent(TIMER);
        }
        else if (msg == "gif2")
        {
            llSetTexture(llList2Key(texture2, count), SHOWN_FACE);
            ++count;
            count %= llGetListLength(texture2);
            llSetTextureAnim(ANIM_ON | LOOP, SHOWN_FACE, FRAMES_X_2, FRAMES_Y_2, 0.0, ALL_FRAMES_2, ANIM_RATE);
            llSetTexture(llList2Key(texture2, count), HIDDEN_FACE);
            llSetTimerEvent(TIMER);
        }
        else if (msg == "gif3")
        {
            llSetTexture(llList2Key(texture3, count), SHOWN_FACE);
            ++count;
            count %= llGetListLength(texture3);
            llSetTextureAnim(ANIM_ON | LOOP, SHOWN_FACE, FRAMES_X_3, FRAMES_Y_3, 0.0, ALL_FRAMES_3, ANIM_RATE);
            llSetTexture(llList2Key(texture3, count), HIDDEN_FACE);
            llSetTimerEvent(TIMER);
        }
    }

    timer()
    {
        //???
        //llSetTexture(llList2Key(texture,count), SHOWN_FACE);
        //++count;
        //count %=llGetListLength(texture);
        //llSetTextureAnim(ANIM_ON | LOOP, SHOWN_FACE, FRAMES_X, FRAMES_Y, 0.0, ALL_FRAMES, ANIM_RATE);
        //llSetTexture(llList2Key(texture,count), HIDDEN_FACE);
    }
}

Edit: Yep, 3 list with different frame numbers. Textures will loop by timer until i hit next button to loop another list :)

 

 

Edited by Tattooshop
Posted (edited)

Maybe I don’t understand what you’re trying to do, but I’m not sure why you need three lists.  If the gifs are built into the textures properly, with all the frames on a single sheet as one texture, then you would only need one list. The frames data can be included in a single, strided, list.  For example, [“UUID”, 4, 2, 8, “UUID”, 2, 2, 4, etc]
 
For texture animations like that (combined into one texture), the frames X & Y should be the total frames across and down on the texture ..  that’s how the size of each frame is determined by the system.

if you’re using texture that are a single frame of the animation..  then you could use two lists, one with all texture UUIDs, the other with a series of index pairs indicating which UUID to start and stop on within the texture list.

Edited by DoteDote Edison
  • Like 1
Posted (edited)
2 hours ago, DoteDote Edison said:

Maybe I don’t understand what you’re trying to do, but I’m not sure why you need three lists.  If the gifs are built into the textures properly, with all the frames on a single sheet as one texture, then you would only need one list. The frames data can be included in a single, strided, list.  For example, [“UUID”, 4, 2, 8, “UUID”, 2, 2, 4, etc]
 
For texture animations like that (combined into one texture), the frames X & Y should be the total frames across and down on the texture ..  that’s how the size of each frame is determined by the system.

if you’re using texture that are a single frame of the animation..  then you could use two lists, one with all texture UUIDs, the other with a series of index pairs indicating which UUID to start and stop on within the texture list.

Thanks for the answer! Ok I made one list of all textures. But how can I make the script recognize that I need to play the first four textures after pressing button 1, the next 4 textures from the list after pressing button 2, and so on? And how to make it see which number to use as the number of frames horizontally and which one is vertical and what is the total number of frames? And what goes in timer event? :)

 

integer SHOWN_FACE = 2; // Shown face number (to display)
integer HIDDEN_FACE = 0; // Hidden face number (to preload)

list texture1 = [

    // CONFIGURATION //

    // UUID GIF LIST:

    "cb7e2af3-8849-8f2d-b210-7abca03e3bca", 4,2,8,
    "6ae33bf3-9217-9046-5827-28774f63253d", 4,2,8,
    "d8a470ec-6856-0603-9a68-94f27248555f", 4,2,8,
    "c2668d35-03e4-03b1-3e09-5cab249cc6aa", 4,2,8,

    "e8a6c9ef-b460-7fea-309e-12ceb4888b55", 2,2,4,
    "c153f141-0222-1a9e-e3d2-00694ab5d2cb", 2,2,4,
    "ef59b79c-e586-0158-e6b0-8c86114bd6bf", 2,2,4,
    "1d60bb24-b2b6-3dec-b873-6311392dea16", 2,2,4,

    "c3511757-3584-93c5-655a-3cdd68b7f2fb", 5,2,10,
    "8c8bfb5b-42b0-6d22-4c61-6e343a850ebb", 5,2,10,
    "9b784a25-9626-b878-a58f-5c8cf63c01dd", 5,2,10,
    "a1dc904f-06ec-ff9b-0a85-d334b5556589", 5,2,10

];

    state_entry()
    {
        llListen(-54321, "", "", ""); // Listen to anybody saying anything on channel -54321 
    }

    listen(integer channel, string name, key id, string msg)
    {
        if (msg == "gif1")
        {

        }
        else if (msg == "gif2")
        {

        }
        else if (msg == "gif3")
        {

        }
    }

    timer()
    {
        //llSetTexture(llList2Key(texture,count), SHOWN_FACE);
        //++count;
        //count %=llGetListLength(texture);
        //llSetTextureAnim(ANIM_ON | LOOP, SHOWN_FACE, FRAMES_X, FRAMES_Y, 0.0, ALL_FRAMES, ANIM_RATE);
        //llSetTexture(llList2Key(texture,count), HIDDEN_FACE);
    }

 

Edited by Tattooshop
Posted

Lists are built on an index system, starting with index 0 (zero). The first item is located at index 0, the second at index one 1, third index 2, and so on. And since you are creating the script and list, you already know what type of data you’ve stored at each index (UUID, integeger, etc).

To get a set of data, such as texture UUID, framesX integer, framesY integer... use llList2Key(). The index you request is based on the stride of the list (items that are a set).. Remember, computer counting starts at 0 instead of 1, so multiplying gifNumber (0) by the number of items in a set (4) will return the first UUID of the gif. To get the next item in the list - in the same set - add 1 after the  multiplication (The location of the item in the set “plus” the location of next item). The third item would be + 2.

The next set would be gifNumber (1) times (4), returning the 5th item in the list, which is the first item of the second set of data.
key uuid;

integer framesX;

integer framesY;

integer frames;

integer gifNum = 0;

uuid = llList2Key(textures, (gifNum*4)+0);

framesX = llList2Integer(textures, (gifNum*4)+1);

framesY = llList2Integer(textures, (gifNum*4)+2);

frames = llList2Integer(textures, (gifNum*4)+3);

 

  • Thanks 1
Posted
On 9/19/2020 at 10:56 AM, DoteDote Edison said:

Lists are built on an index system, starting with index 0 (zero). The first item is located at index 0, the second at index one 1, third index 2, and so on. And since you are creating the script and list, you already know what type of data you’ve stored at each index (UUID, integeger, etc).

To get a set of data, such as texture UUID, framesX integer, framesY integer... use llList2Key(). The index you request is based on the stride of the list (items that are a set).. Remember, computer counting starts at 0 instead of 1, so multiplying gifNumber (0) by the number of items in a set (4) will return the first UUID of the gif. To get the next item in the list - in the same set - add 1 after the  multiplication (The location of the item in the set “plus” the location of next item). The third item would be + 2.

The next set would be gifNumber (1) times (4), returning the 5th item in the list, which is the first item of the second set of data.
key uuid;

integer framesX;

integer framesY;

integer frames;

integer gifNum = 0;

uuid = llList2Key(textures, (gifNum*4)+0);

framesX = llList2Integer(textures, (gifNum*4)+1);

framesY = llList2Integer(textures, (gifNum*4)+2);

frames = llList2Integer(textures, (gifNum*4)+3);

 

Thank you so much! It works now! :D

 

You are about to reply to a thread that has been inactive for 1535 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...