Jump to content

Wanted: Menu-based Opacity Script


Lucky Effingham
 Share

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

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

Recommended Posts

I am honestly clueless when it comes to scripting.

 

Now that's out of the way, I am simply looking to script a series of tongues for a head. I would love for it to be scripted so when the person clicks on the head, a menu comes up giving them the option of what tongue wants to be out, if any. There are 5 different tongues, so that would make 6 options (one being to not show any of them).

 

Ideally, I would need this script to be copy and transferrable.

Ideally, I would also love for this to be for free, but I know that hardly anyone likes working for free. I have a small budget at the moment, so if I have to pay for it, I'd love for it to be relatively cheap.

 

Is there anyone willing to take this up for me, or at least a point in the right direction?

Link to comment
Share on other sites

Where does the opacity come in?  Do you mean all but the chosen tongue - if any - should be made transparent, leaving just one/none showing?  Assuming that's the case this is very simple if the tongues are each one prim and all linked.  Alternatively it is simple if you have one tongue and want the sculpt-map for it changed on selection.

Free is quite possible if you'd like to give me more details.  I'll post the script back here.

Link to comment
Share on other sites

Yes, I mean all but the chosen tongue would be completely transparent. The tongues are all one prim, and are linked to the head. I guess it would be really easy to do it so the map changes, but I don't really favor doing it that way incase someone wants to use a different tongue?

Link to comment
Share on other sites

This script assumes the whole attachment (head + 5 tongues) is meant to be transparent, except when a tongue is selected.  It also assumes that the head is the root prim and the 5 tongues are child-prims nos. 2 - 6 (iel make sure any other prims in the object are higher link-numbers).  Put this script in the head (root prim) for it to work.

integer Listener;CloseListen(){	llSetTimerEvent(0.0);	if(Listener){		llListenRemove(Listener);		Listener = 0;	}}default{	listen(integer ChannelIn, string FromName, key FromID, string Message){		// Make everything transparent except the chosen prim		CloseListen();		llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);		if("<None>" != Message){			llSetLinkAlpha(1 + (integer) Message, 1.0, ALL_SIDES);		}	}	timer(){		CloseListen();		llOwnerSay("Menu timed-out, click again to reactivate it");	}	touch_end(integer HowMany){		// Display menu if touched by owner		if(llDetectedKey(0) == llGetOwner()){			CloseListen();			integer ChannelMenu = -(integer) (llFrand(999999999.99) + 1);			Listener = llListen(ChannelMenu, "", llGetOwner(), "");			llDialog(llGetOwner(), "Please select the tongue to display", ["4", "5", "<None>", "1", "2", "3"], ChannelMenu);			llSetTimerEvent(30.0);		}	}}

 

Link to comment
Share on other sites

It will as it is, but it's not a huge change.  I didn't realise it was a sculpted head as well, thought it was a transparent sphere for them to click on.  ... Correcting to head (root prim)- and, if chosen, tongue are opaque, other prims are transparent.

 

integer Listener;CloseListen(){	llSetTimerEvent(0.0);	if(Listener){		llListenRemove(Listener);		Listener = 0;	}}default{	listen(integer ChannelIn, string FromName, key FromID, string Message){		// Make everything transparent except the chosen prim		CloseListen();		llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES);		if("<None>" != Message){			llSetLinkAlpha(1 + (integer) Message, 1.0, ALL_SIDES);		}	}	timer(){		CloseListen();		llOwnerSay("Menu timed-out, click again to reactivate it");	}	touch_end(integer HowMany){		// Display menu if touched by owner		if(llDetectedKey(0) == llGetOwner()){			CloseListen();			integer ChannelMenu = -(integer) (llFrand(999999999.99) + 1);			Listener = llListen(ChannelMenu, "", llGetOwner(), "");			llDialog(llGetOwner(), "Please select the tongue to display", ["4", "5", "<None>", "1", "2", "3"], ChannelMenu);			llSetTimerEvent(30.0);		}	}}

 

(The only change is that the line "llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);" - that is, make everything transparent - has changed to "llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES);" - don't change the root prim.

Link to comment
Share on other sites

The head is multiple prims, sadly so is there an easy way to adjust so only the tongues are going transparent?

Starting to think having it change sculpt maps for the tongue itself would be easier.

Aah I'm so sorry I seem to be terrible at describing things in full detail :smileysad:

Link to comment
Share on other sites

At least half the problem is that it is virtually impossible to describe your requirements from a standing start.  That's why 'waterfall' software development - talk to the customer, go away and spend ages writing what they asked for - was replaced with agile, iterative, techniques - discuss, demonstrate, adjust, repeat.  We're homing in on a solution :-)

 This is a slightly more complicated script but it is also more flexible.  The essential difference is that you MUST give the individual tongue-prims unique names and change the list at the top of the script to show those, eg; ["<None>", "Serpent", "Fire", ... etc ... ].  While that is slightly harder for you it has two advantages - you don't have to care about the link-numbers any more and those names are used in the menu instead of just the numbers 1, 2, 3, etc.

 

// Select A Prim //// ============= //// Menu-based script to display one of a list of prims// Prims to displayed can be named anything that will fit in a menuinteger Listener;list Names = ["<None>", "1", "2", "3", "4", "5"];	// <==== Change this, must be short enough to show in menu with 'none' firstlist Prims;integer Shown;CloseListen(){	// Stop timer, stop listening, discard listen-handle	llSetTimerEvent(0.0);	if(Listener){		llListenRemove(Listener);		Listener = 0;	}}default{	listen(integer ChannelIn, string FromName, key FromID, string Message){		// Make any shown prim transparent		CloseListen();		if(0 < Shown){			llSetLinkAlpha(llList2Integer(Prims, Shown), 0.0, ALL_SIDES);		}		// Find the chosen prim and display it if not '<None>'		Shown = llListFindList(Names, [Message]);		if(0 < Shown){			llSetLinkAlpha(llList2Integer(Prims, Shown), 1.0, ALL_SIDES);		}	}	state_entry(){		// Find the prims with the names in the menu-list		llOwnerSay("Initialising, please wait ...");		integer Counter;		Prims = Names;		for(Counter = 1; Counter <= llGetNumberOfPrims(); Counter++){			Shown = llListFindList(Names, [llGetLinkName(Counter)]);			if(-1 < Shown){				Prims = llListReplaceList(Prims, [Counter], Shown, Shown);				llSetLinkAlpha(Counter, 0.0, ALL_SIDES);			} 		}		Shown = 0;		// Not-found warnings		for(Counter = 1; Counter < llGetListLength(Names); Counter++){			if(1 > llList2Integer(Prims, Counter)){				llOwnerSay("Prim name '" + llList2String(Names, Counter) + "' not found, please check spelling and capitalisation");			}		}		llOwnerSay("Ready");	}	timer(){		// Automatically close the listener if there is no menu response within the time limit		CloseListen();		llOwnerSay("Menu timed-out, click again to reactivate it");	}	touch_end(integer HowMany){		// Display menu if touched by owner		if(llDetectedKey(0) == llGetOwner()){			CloseListen();			integer ChannelMenu = -(integer) (llFrand(999999999.99) + 1);			Listener = llListen(ChannelMenu, "", llGetOwner(), "");			llDialog(llGetOwner(), "Please select the tongue to display", Names, ChannelMenu);			llSetTimerEvent(30.0);		}	}}

 

There is now a state_entry() event-handler.  When you add the script to the head you will see the message "Initialising, please wait ..." and the script will then find the prims with the names you gave in the list, which is why you don't have to worry about the link-numbers yourself.  When that extra step is complete you will see a message telling you if any named prims were not found and then "Ready".  If any prims are not found check the names, spellings and capitalization or all sorts of things might go wrong!

The single prim that is selected, if any, is now remembered and just that one switched between opaque and transparent,

Link to comment
Share on other sites

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