Jump to content

Timer question in texture swap HUD


Randall Renoir
 Share

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

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

Recommended Posts

Greetings all.  (pardon my poor explanation of this issue--its a bit complicated--at least to me!),

I'm working on a Emoji HUD.  Students will use the HUD during discussions to help facilitate communication   I used an existing texture swap script as a base and managed to get it so that I'd have not issues with students accidentally changing each other's emojis, but the part that is stumping me is as follows.  Ideally, I'd want to have it so that a student might click on their HUD to display above their heads, say, a LMAO emoji, and then have it disappear after perhaps 5 seconds so that they would not appear to be Laughing their Asses Off for 15 minutes.  However, when I tried to get that to work by adding in a llSetTimerEvent(5.0) the script complied, but then clicking on that emoji choice resulted in the emoji showing up for only a split second.  

I also tried doing it another way based on a script I found that added a float Timer = 5.0; at the top of the script, and then added in the timer coding, but when I try it that way I consistently get a scripting error on that line.  I've pasted in the script below as it stands now, sans timer.   Could anyone get me started in the right direction?  Thanks for any attempts at lessening my ignorance!!  (image attached of the HUD (only two sample emojis on it for now and Display (neither attached to an avatar in case that helps!)

 

 

SCRIPT from button on HUD:

default
{

    touch_start(integer total_number) {

        llSay(-1356,"1");

    }

}

 

SCRIPT from Emoji Display above avatar's head:

default
{
    state_entry()
    {
        llListen(-1356,"","","");
    }
    
    on_rez(integer message) {
     llResetScript();   
    }
    
    listen(integer channel, string name, key id, string message){
        if(llGetOwnerKey(id)==llGetOwner()){
    //if the uuid of the object that sent the message is the same as the uuid of the owner of the object containing this script     
////TO FIND A UUID OF A TEXTURE SELECT IT WHILE ITS ON A PRIM AND HIT  CTRL-ALT-V then HIT  CTRL-ALT-SHIFT-T this will return the textures UUID and put it here to control it on any prim without having to add textures.

key tex1 = "6c92d507-7480-574c-f538-a081343906b5";////// CHANGE THIS UUID
key tex2 = "44265cd9-4e17-20f7-91b9-d803d16275f8";////// CHANGE THIS UUID
key tex3 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex4 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex5 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex6 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex7 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex8 = "3ab7e2fa-9572-ef36-1a30-d855dbea4f92";////// CHANGE THIS UUID

                 if(message=="1")
        { llSetTexture(tex1,4);

        }        
                if(message=="2")
        { llSetTexture(tex2,4);
        }
                if(message=="3")
        { llSetTexture(tex3,4);
        }
                if(message=="4")
        { llSetTexture(tex4,4);
        }
                if(message=="5")
        { llSetTexture(tex5,4);
        }
                if(message=="6")
        { llSetTexture(tex6,4);
        }
                if(message=="7")
        { llSetTexture(tex7,4);
        }
                if(message=="8")
        { llSetTexture(tex8,4);
 }                           
}}}
 

Emoji HUD and Display.png

Link to comment
Share on other sites

I suggest you post the script that had the timer but then resulted in the emoji vanishing too fast and somebody might then spit what you've got to tweak.

Looking at the formatting in what you have posted, it is going to be tricky to spot things like mismatched braces, are you able to reformat the code to get a more standard indentation?

Link to comment
Share on other sites

6 minutes ago, Profaitchikenz Haiku said:

I suggest you post the script that had the timer but then resulted in the emoji vanishing too fast and somebody might then spit what you've got to tweak.

Looking at the formatting in what you have posted, it is going to be tricky to spot things like mismatched braces, are you able to reformat the code to get a more standard indentation?

default
{
    state_entry()
    {
        llListen(-1356,"","","");
    }
    on_rez(integer message)
    {
        llResetScript();
    }
    listen(integer channel, string name, key id, string message)
    {
        if(llGetOwnerKey(id)==llGetOwner())
        {
            //if the uuid of the object that sent the message is the same as the uuid of the owner of the object containing this script
            ////TO FIND A UUID OF A TEXTURE SELECT IT WHILE ITS ON A PRIM AND HIT  CTRL-ALT-V then HIT  CTRL-ALT-SHIFT-T this will return the textures UUID and put it here to control it on any prim without having to add textures.

            key tex1 = "6c92d507-7480-574c-f538-a081343906b5";////// CHANGE THIS UUID
            key tex2 = "44265cd9-4e17-20f7-91b9-d803d16275f8";////// CHANGE THIS UUID
            key tex3 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
            key tex4 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
            key tex5 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
            key tex6 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
            key tex7 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
            key tex8 = "3ab7e2fa-9572-ef36-1a30-d855dbea4f92";////// CHANGE THIS UUID

            if(message=="1")
            {
                llSetTexture(tex1,4);

            }
            if(message=="2")
            {
                llSetTexture(tex2,4);
            }
            if(message=="3")
            {
                llSetTexture(tex3,4);
            }
            if(message=="4")
            {
                llSetTexture(tex4,4);
            }
            if(message=="5")
            {
                llSetTexture(tex5,4);
            }
            if(message=="6")
            {
                llSetTexture(tex6,4);
            }
            if(message=="7")
            {
                llSetTexture(tex7,4);
            }
            if(message=="8")
            {
                llSetTexture(tex8,4);
            }
        }
    }
}

Link to comment
Share on other sites

All you really need is a timer event that displays TEXTURE_BLANK ( == "5748decc-f629-461c-9a36-a35a221fe21f") on face 4 when it's triggered. Set the timer with llSetTimerEvent(5.0); at the end of your listen event, so that it's tripped after you receive any of the messages.  Then remember to turn it off again in the timer event itself with llSetTimerEvent(0.0);

Now for some cleanup.  All of your if statements except the very first one should be else if statements, since you don;t need to test every single one of them every time.  You'll discover before long that it's possible to write this whole script with about half the number of lines of code, but that's for another day. ;)

Edited by Rolig Loon
Link to comment
Share on other sites

9 hours ago, Innula Zenovka said:

If the OP wants to make the emoji vanish, wouldn't it be better to display TEXTURE_TRANSPARENT  rather than  TEXTURE_BLANK ?

 

Good point.  I suppose the OP can decide whether he wants an empty sign or a missing one.   Now he can do either.  Thanks.

  • Like 1
Link to comment
Share on other sites

Catwa-HUD-Guide.jpg.f995fb98227d3efb67a25b2856dd4904.jpg

If you buy a top of the line mesh avatar with a Catwa bento head, you get facial expressions. That's one of the HUDs for them.

The number of people in SL who buy all these features (they're not cheap) and can puppeteer well enough to use them convincingly is small. 

  • Confused 1
Link to comment
Share on other sites

Well, dang!  I integrated some of the great advice, but the script still hates me.  lol.   Any further thought?  Here is the script as it stands.   When the HUD is clicked, the Emoji will still pop up, but only for a split second.  Any thoughts?  I do greatly appreciate the help!!

default
{
    state_entry()
    {
        llListen(-1356,"","","");
    }
    
    on_rez(integer message) {
     llResetScript();   
    }
    
    listen(integer channel, string name, key id, string message){
        if(llGetOwnerKey(id)==llGetOwner()){
    //if the uuid of the object that sent the message is the same as the uuid of the owner of the object containing this script     
////TO FIND A UUID OF A TEXTURE SELECT IT WHILE ITS ON A PRIM AND HIT  CTRL-ALT-V then HIT  CTRL-ALT-SHIFT-T this will return the textures UUID and put it here to control it on any prim without having to add textures.

key tex1 = "6c92d507-7480-574c-f538-a081343906b5";////// CHANGE THIS UUID
key tex2 = "44265cd9-4e17-20f7-91b9-d803d16275f8";////// CHANGE THIS UUID
key tex3 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex4 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex5 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex6 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex7 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
key tex8 = "3ab7e2fa-9572-ef36-1a30-d855dbea4f92";////// CHANGE THIS UUID

               if(message=="1")
        { llSetTexture(tex1,4);        
        }        
                else if(message=="2")
        { llSetTexture(tex2,4);
        }
                else if(message=="3")
        { llSetTexture(tex3,4);
        }
                else if(message=="4")
        { llSetTexture(tex4,4);
        }
                else if(message=="5")
        { llSetTexture(tex5,4);
        }
                else if(message=="6")
        { llSetTexture(tex6,4);
        }
                else if(message=="7")
        { llSetTexture(tex7,4);
        }
                else if(message=="8")
        { llSetTexture(tex8,4);
 }                           


{llSetTimerEvent(5.0);

 llSetTexture(tex8,4); 

}
 {llSetTimerEvent(0.0);

}
}
 }
 }

Link to comment
Share on other sites

3 hours ago, Randall Renoir said:

 

string tex1 = "6c92d507-7480-574c-f538-a081343906b5";////// CHANGE THIS UUID
string tex2 = "44265cd9-4e17-20f7-91b9-d803d16275f8";////// CHANGE THIS UUID
string tex3 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
string tex4 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
string tex5 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
string tex6 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
string tex7 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
string tex8 = "3ab7e2fa-9572-ef36-1a30-d855dbea4f92";////// CHANGE THIS UUID
key owner_id;

default
{
    state_entry()
    {
        owner_id = llGetOwner();
        llListen(-1356,"", owner_id, "");
    }
    on_rez(integer start_param)
    {
        llResetScript();
    }
    listen(integer channel, string name, key id, string message)
    {
        if(message=="1")
        {
            llSetTexture(tex1,4);
        }
        else if(message=="2")
        {
            llSetTexture(tex2,4);
        }
        else if(message=="3")
        {
            llSetTexture(tex3,4);
        }
        else if(message=="4")
        {
            llSetTexture(tex4,4);
        }
        else if(message=="5")
        {
            llSetTexture(tex5,4);
        }
        else if(message=="6")
        {
            llSetTexture(tex6,4);
        }
        else if(message=="7")
        {
            llSetTexture(tex7,4);
        }
        else if(message=="8")
        {
            llSetTexture(tex8,4);
        }
        llSetTimerEvent(5.0);
    }
    timer()
    {
        llSetTimerEvent(0.0);
    }
    changed(integer ch)
    {
        if(ch&CHANGED_OWNER)
        {
            llResetScript();
        }
    }

}

 

 

Edited by steph Arnott
Link to comment
Share on other sites

Randall - Two things:

1) In state_entry, there is no llSetTimerEvent(0.0) 

2) I think  5 seconds is just not long enough for the texture to appear visible, sometimes it can take 20 seconds for a texture to change from grey to clear , so during testing, I would extend the display period to perhaps 60 seconds, and even more, and establish a minimum time

I suggest adding a line in the timer function to say "timer entry" in local chat, then run the script and observe the behaviour, particularly how long it takes for the texture to properly appear, and from that observation, determine how many seconds you want to put in the call to llSetTimerEvent()

Steph's suggestion is properly indented and will probably work, but it might be less obvious to you why her script would work and yours would not. She is also trying to show you that global assignments of things like emoji UUIDs should be made at the head of the script, not within an individual state.

However, I think her script differs from yours in too many areas for you to be able to see why yours is failing, so I have amended your script to illustrate what I mean. Because the formatting and indentation wasn't standard I can't see precisely if I have got the braces matching, so do not assume you can simply copy and paste this into SL and have it working straight away. Get your script working first, then take Steph's suggestion as a template and shift things like the texture assignments up to the global area.

 

default
{
    state_entry()
    {
        llListen(-1356,"","","");
        llSetTimerEvent(0.0);	// make sure nothing is scheduled until we want it to run
    }
    
    on_rez(integer message) {
     llResetScript();   
    }
    
    listen(integer channel, string name, key id, string message){
        if(llGetOwnerKey(id)==llGetOwner())
        {
    //if the uuid of the object that sent the message is the same as the uuid of the owner of the object containing this script     
////TO FIND A UUID OF A TEXTURE SELECT IT WHILE ITS ON A PRIM AND HIT  CTRL-ALT-V then HIT  CTRL-ALT-SHIFT-T this will return the textures UUID and put it here to control it on any prim without having to add textures.

        key tex1 = "6c92d507-7480-574c-f538-a081343906b5";////// CHANGE THIS UUID
        key tex2 = "44265cd9-4e17-20f7-91b9-d803d16275f8";////// CHANGE THIS UUID
        key tex3 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
        key tex4 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
        key tex5 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
        key tex6 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
        key tex7 = "0c0bdbe7-ca2b-0201-10c8-ddf69ef2108a";////// CHANGE THIS UUID
        key tex8 = "3ab7e2fa-9572-ef36-1a30-d855dbea4f92";////// CHANGE THIS UUID

               if(message=="1")
        { llSetTexture(tex1,4);        
        }        
                else if(message=="2")
        { llSetTexture(tex2,4);
        }
                else if(message=="3")
        { llSetTexture(tex3,4);
        }
                else if(message=="4")
        { llSetTexture(tex4,4);
        }
                else if(message=="5")
        { llSetTexture(tex5,4);
        }
                else if(message=="6")
        { llSetTexture(tex6,4);
        }
                else if(message=="7")
        { llSetTexture(tex7,4);
        }
                else if(message=="8")
        { llSetTexture(tex8,4);
 	}                           

		llSetTimerEvent(60.0);	// now specifiy how long in seconds the texture is to persist
        } // END OF test for speaker == owner

  }
  
  timer()
  {
      llWhisper(0, "Timer entry");	// only during testing and devel;opment
      llSetTimerEvent(0.0);	// stop any further triggers
      llSetTexture(tex8,4); // tex8 is the default, or change to whatever the desired default texture is to be
  }

}

 

Edited by Profaitchikenz Haiku
Changed my mind
Link to comment
Share on other sites

1 hour ago, Profaitchikenz Haiku said:

[...] She is also trying to show you that global assignments of things like emoji UUIDs should be made at the head of the script, not within an individual state.

So that's true of actual global variables, but these are only ever used inside the listen() event, so keeping them scoped to that event is better form and will slightly reduce the script memory footprint. There are LSL pre-processors, though, that could take them as up-front symbol definitions and splice them into the code as literals before compiling; however they get into the source, literals are the most efficient representation. (Of course if the script were anything serious, we'd replace that whole sequence of conditionals with a simple a-list lookup, pairing message with associated texture key, but that's slightly more advanced than we need here.)

Also, there seem to be only eight emojis, so it would be practical to get around the download delay of a newly-shown texture using an 8-sided mesh painted with 100% transparent textures, one per face, and linking a copy of that static mesh to everybody's head-mounted emoji or (better) at the front of the classroom where everybody will have that single copy (invisibly) in view.

Link to comment
Share on other sites

7 minutes ago, Qie Niangao said:

So that's true of actual global variables, but these are only ever used inside the listen() event,

I put them there for convience. Also even though they are a UUID they are in a string format. The script is as crude as it gets and the OP is already struggling so i decided so seperate those strings so the body could be clearly seen.

Link to comment
Share on other sites

7 hours ago, Profaitchikenz Haiku said:

 

Firstly you changed it back to a key when they are in a string format. Secondly, you do not need a timer zero at the start because it serves no purpose. The fact that the channel is never closed before detatch is never addressed.

The script is a beginners attempt and as such it needed to be simplistic so i seperated the UUID strings so the main was uncluttered. Also i put the ID filter in for a valid reason, at the moment the whole channel is being evaluated.

Edited by steph Arnott
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2037 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
 Share

×
×
  • Create New...