Jump to content

Trying to make a drink appear depleted with face switching on mesh with timer


Glovercali
 Share

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

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

Recommended Posts

I'm not even sure how I can accomplish this but I cant seem to find a good script that would work, that's also modifiable to work with drink animations on a timed interval.

I just want the drink to appear like its being depleted for RP. Which I understand requires switching textures on one face to another but I don't know how to start it, alpha one texture then un-alpha the next and sync it to animation. While all being on a timer. Can someone help me?

Link to comment
Share on other sites

This depends a lot on how your cup is built and textured. If it was me, I'd make the cup semi-transparent and have the liquid be a cylindrical prim. then all you have to do is set the PRIM_SLICE parameter of the cylinder to what % the glass is full, and set its alpha to 0 when the glass is empty.

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

Hi, its mesh, will it still work? The liquid is slightly symmetrical but its tapered in towards the bottom. I am going to break up the texture set on the unlinked mesh to switch the textures of the liquid to look as if it is depleted but I'm not sure how to do that in scripting terms

 

9f43cf84bf2f01a7315dc84a5c82265a.png

Edited by Glovercali
Link to comment
Share on other sites

20 hours ago, Glovercali said:

Hi, its mesh, will it still work? The liquid is slightly symmetrical but its tapered in towards the bottom. I am going to break up the texture set on the unlinked mesh to switch the textures of the liquid to look as if it is depleted but I'm not sure how to do that in scripting terms

You won't be able to use PRIM_SLICE to trim the top off your mesh object, but you can change what texture appears on that material face (to swap among a set of specific appearances) or, if you've prepared your texture's alpha and the UV map right, to change the texture offset and set the liquid to an arbitrary height.

Link to comment
Share on other sites

Okay, these were all some awesome ideas on how to make my cup more functional. 

But something else was suggested to me and I thought I would give it a go. Turns out it was a pretty awesome effect and easy too, only issue is I cant seem to get the script to autostart on attach ..I'm still new to scripting so forgive me. 

 

The script is from outworlds, called the "prim animator"

Here is a snippet of it in action.

https://i.gyazo.com/028827a56f36d00f543b4dbe030468cb.mp4

Gives an awesome effect but to trigger the script, only seems to come from a listener(another script). I'm sure it can be auto-started on attach, As I've seen this a few times before with animation. Only had one script in the cup, not the 2 I seem to be having trouble with.

 

Can someone guide me on how to auto-start or trigger this script from within itself? Instead of listeners? I'd really appreciate it! 

 

Thank you so much in advance!

 

 // Prim animation compiler //
// Fred Beckhusen (Ferd Frederix) - http://www.outworldz.com
integer playbackchannel = 1; // The default llMessageLinked number
rotation calcChildRot(rotation rdeltaRot)
{
    if (llGetAttached())
        return rdeltaRot/llGetLocalRot();
    else
        return rdeltaRot/llGetRootRotation();
}

vector originalScale = <0.07497, 0.07508, 0.15847>;
 test()
 
 {
    vector currentSize = llGetScale();
    float scaleby = currentSize.x/originalScale.x;

     llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, <0.00000, -0.00011, -0.02649>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.44621, 0.89493>), PRIM_SIZE, <0.06172, 0.06172, 0.09056>*scaleby]);
     llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, <0.00030, 0.00020, 0.01624>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.16505, 0.98629>), PRIM_SIZE, <0.05943, 0.05554, 0.01968>*scaleby]);
     llSleep(5.000000);
     llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, <0.00000, -0.00011, -0.02979>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.03491, 0.99939>), PRIM_SIZE, <0.06172, 0.06172, 0.08397>*scaleby]);
     llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, <0.00030, 0.00020, 0.00842>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.18224, 0.98325>), PRIM_SIZE, <0.05943, 0.05554, 0.01968>*scaleby]);
     llSleep(5.000000);
     llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, <0.00000, -0.00011, -0.03174>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.03491, 0.99939>), PRIM_SIZE, <0.06172, 0.06172, 0.07994>*scaleby]);
     llSetLinkPrimitiveParamsFast(3, [PRIM_POSITION, <0.00030, 0.00020, 0.00586>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, 0.41469, 0.90996>), PRIM_SIZE, <0.05943, 0.05554, 0.01968>*scaleby]);
 
}
 

default{

     state_entry(){
        llSetMemoryLimit(llGetUsedMemory() + 512);
        }
 
    link_message(integer sender_num, integer num, string message, key id){
        if(num == playbackchannel){
            if(message == "test"){
                test();
            }
        }
    }
}

 

Edited by Glovercali
Link to comment
Share on other sites

To auto-start something on attach, you'll want to use the attach event.

You'll want to verify that the item is being attached, not detached (as the event will fire for both), so you'll need to verify if the key given with the event is valid - so, for example:

attach(key id)
{
	if(id) //is id a valid key (object is being attached)
    {
    	test(); //start running the 'animation'
    }
  	else
    {
    	//object is being detached - do something else.
    }
}

You can also do a little optimization to that script by combining some of those llSetLinkPrimitiveParamsFast into a single line using PRIM_LINK_TARGET, like so:

llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, <0.00000, -0.00011, -0.02649>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.44621, 0.89493>), PRIM_SIZE, <0.06172, 0.06172, 0.09056>*scaleby, PRIM_LINK_TARGET, 3, PRIM_POSITION, <0.00030, 0.00020, 0.01624>*scaleby, PRIM_ROTATION,calcChildRot(<0.00000, 0.00000, -0.16505, 0.98629>), PRIM_SIZE, <0.05943, 0.05554, 0.01968>*scaleby]);

 

Edited by Jenna Huntsman
Spelling lol
  • Like 1
Link to comment
Share on other sites

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