| |
| Scripting Discuss scripting and programming for SL and other platforms |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Kitten Fuzz ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() *SLU Supporter* ![]() ![]() ![]() ![]() | Okay, this is probably a very easy fix. I got this script from here -- Winter Seale As you can see, the texture-changer script here is able to be used only if included with the resize script provided. I don't need a resize script, but I do want a texture-changer script, one that changes the texture of certain child prims (but not all of them). It's easy to convert, isn't it? To be placed in the root prim: Code: // This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/
// or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
// Winter Seale 2008 - winterseale.com
string MENU_NAME = "Select a color:";
string MO_BACK = "Back";
list RETURN_MENU = [ "-", "-", MO_BACK ];
list MENU_OPTIONS = [
// Menu Name|Texture Name/UUID
"Gray|1a93fa41-85ce-4d64-14a0-c04db47c9d9a",
"Greenish|3b76d89b-2d96-796b-fc33-bdacd2df8fa5",
"Rose|6d59c124-2327-c423-6c5d-52f8989dda17"
];
integer LM_RESET_SECRIPTS = 101;
integer LM_SCALE_MESSAGE = 102;
integer LM_CAN_COLOR_CHANGE = 103;
integer LM_SHOW_COLOR_DIALOG = 104;
integer LM_SET_COLOR = 105;
integer LM_SHOW_MAIN_DIALOG = 106;
integer CHANNEL = -114757314;
list options_dialog;
list options_texture;
rebuild_options() {
integer count = llGetListLength( MENU_OPTIONS );
integer ii;
for ( ii = 0; ii < count ; ii ++ ) {
list pieces = llParseString2List( llList2String(MENU_OPTIONS,ii), ["|"], [] );
options_dialog += [ llList2String(pieces,0) ];
options_texture += [ llList2String(pieces,1) ];
}
}
integer listenhandler;
// Rebuild our listener and turn it off. Should really only be done
// on owner change.
reset_listener() {
llListenRemove(listenhandler);
listenhandler = llListen( CHANNEL, "", llGetOwner(), "");
llListenControl( listenhandler, FALSE );
}
show_dialog() {
list menu = RETURN_MENU + options_dialog;
llDialog(llGetOwner(), MENU_NAME, menu, CHANNEL);
llSetTimerEvent(60);
llListenControl( listenhandler, TRUE );
}
send_linked(integer command, string options ) {
integer dest = LINK_SET;
if ( command == LM_CAN_COLOR_CHANGE || command == LM_SHOW_MAIN_DIALOG ) {
dest = LINK_THIS;
}
llMessageLinked( dest, command, options, NULL_KEY );
}
default {
state_entry() {
rebuild_options();
reset_listener();
send_linked(LM_CAN_COLOR_CHANGE,"");
}
changed(integer mask) {
if ( mask & CHANGED_OWNER ) {
reset_listener();
}
}
link_message(integer sender_num, integer command, string message, key id) {
if ( command == LM_RESET_SECRIPTS ) {
llResetScript();
}
else if ( command == LM_SHOW_COLOR_DIALOG ) {
show_dialog();
}
}
listen( integer channel, string name, key id, string message ) {
integer sel_index = llListFindList( options_dialog, [message] );
if ( sel_index != -1 ) {
send_linked( LM_SET_COLOR, llList2String(options_texture,sel_index) );
show_dialog();
}
else if ( message == MO_BACK ) {
send_linked( LM_SHOW_MAIN_DIALOG, "" );
}
}
timer() {
llListenControl( listenhandler, FALSE );
llSetTimerEvent(0);
}
} Code: // This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/
// or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
// Winter Seale 2008 - winterseale.com
integer LM_RESET_SECRIPTS = 101;
integer LM_SCALE_MESSAGE = 102;
integer LM_CAN_COLOR_CHANGE = 103;
integer LM_SHOW_COLOR_DIALOG = 104;
integer LM_SET_COLOR = 105;
default {
link_message(integer sender_num, integer command, string message, key id) {
if ( command == LM_RESET_SECRIPTS ) {
llResetScript();
}
else if ( command == LM_SET_COLOR ) {
llSetTexture( message, ALL_SIDES );
}
}
} |
| | |
| |
| | #2 (permalink) |
| Kitten Fuzz ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() *SLU Supporter* ![]() ![]() ![]() ![]() | For reference -- the core resizer: Code: // This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/
// or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
// Put this script in the root prim of your item
// CUSTOMIZABLE VALUES
// change here to set the desired scale change +- from the base of 1.0
// eg. 0.2 will make the scale 0.8 or 1.2 respectively
float scale_step = 0.2;
// eSimple srl 2008 - www.esimple.it - www.virtuy.com
// Ploreho design 2008 - www.ploreho.com
// Modified by Winter Seale 2008 - winterseale.com
// -- Got rid of constant listen/remove listen code and changed to using listencontrol to turn the handle on and off
// -- Got rid of all the magic numbers.
// -- Moved repeated code to functions
// -- Changed it to handle optionally having a color change script dropped in.
// -- I also changed the formatting to match my own scripts =p
// DO NOT CHANGE BELOW THIS LINE
integer LM_RESET_SECRIPTS = 101;
integer LM_SCALE_MESSAGE = 102;
integer LM_CAN_COLOR_CHANGE = 103;
integer LM_SHOW_COLOR_DIALOG = 104;
integer LM_SET_COLOR = 105;
integer LM_SHOW_MAIN_DIALOG = 106;
string DEFAULT_SCALE = "d";
integer CHANNEL = -114757313;
// popup options
string MENU_NAME = "Choose the desired option:";
string DN_SIZE = "- Size";
string DF_SIZE = "Default";
string UP_SIZE = "+ Size";
list MENU_OPTIONS = [DN_SIZE, DF_SIZE, UP_SIZE ];
string COLOR = "Color";
string NOOP = "-";
list COLOR_OPTIONS = [ NOOP, COLOR, NOOP ];
integer listenhandler;
integer have_colors;
// Rebuild our listener and turn it off.
reset_listener() {
llListenRemove(listenhandler);
listenhandler = llListen( CHANNEL, "", llGetOwner(), "");
llListenControl( listenhandler, FALSE );
}
// Show change menu, optionally including color the option to change colors
// if a color change script was included. Time out after 60 seconds.
show_dialog() {
list options = [];
if ( have_colors ) {
options += COLOR_OPTIONS;
}
options += MENU_OPTIONS;
llDialog(llGetOwner(), MENU_NAME, options, CHANNEL);
llSetTimerEvent(60);
llListenControl( listenhandler, TRUE );
}
// Send link messages, using the numeric part to control what happens and
// the string part for arguments.
// All commands except LM_SHOW_COLOR_DIALOG go to the entire linkset. The
// dialog command only goes to the same prim as the core script.
send_linked(integer command, string options ) {
integer dest = LINK_SET;
if ( command == LM_SHOW_COLOR_DIALOG ) {
dest = LINK_THIS;
}
llMessageLinked( dest, command, options, NULL_KEY );
}
default {
state_entry() {
reset_listener();
have_colors = FALSE;
}
touch_end(integer total_number) {
if (llDetectedKey(0) == llGetOwner()) {
show_dialog();
}
}
listen(integer channel, string name, key id, string button) {
if ( button == DN_SIZE) {
send_linked( LM_SCALE_MESSAGE, (string)(1.0 - scale_step) );
show_dialog();
}
else if ( button == UP_SIZE ) {
send_linked( LM_SCALE_MESSAGE, (string)(1.0 + scale_step) );
show_dialog();
}
else if ( button == DF_SIZE ) {
send_linked( LM_SCALE_MESSAGE, DEFAULT_SCALE );
show_dialog();
}
else if ( have_colors && button == COLOR) {
llListenControl( listenhandler, FALSE );
send_linked( LM_SHOW_COLOR_DIALOG, "" );
}
}
// This is just here to reset things when this is sold...
changed(integer mask) {
if ( mask & CHANGED_OWNER ) {
// Strictly speaking, there's no reason to reset the listener, as the llMessageLinked will
// result in a full script reset. However, in case it somehow gets dropped this way the item
// won't be inert.
reset_listener();
llMessageLinked(LINK_SET, LM_RESET_SECRIPTS, "", NULL_KEY);
}
}
link_message(integer sender_num, integer command, string message, key id) {
if ( command == LM_RESET_SECRIPTS ) {
llResetScript();
}
else if ( command == LM_CAN_COLOR_CHANGE ) {
have_colors = TRUE;
}
else if ( command == LM_SHOW_MAIN_DIALOG ) {
show_dialog();
}
}
timer() {
llListenControl( listenhandler, FALSE );
llSetTimerEvent(0);
} |
| | |
| | #3 (permalink) |
| Kitten Fuzz ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() *SLU Supporter* ![]() ![]() ![]() ![]() | Okay, I think I've fixed it myself. If you'd like to look it over and tell me if I've got any annoying bugs (like infinite loops or something, whatever those are) please, please tell me. ![]() Code: // This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/
// or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
// Winter Seale 2008 - winterseale.com
string MENU_NAME = "Select a color:";
string MO_BACK = "Back";
list MENU_OPTIONS = [
// Menu Name|Texture Name/UUID
"Gray|1a93fa41-85ce-4d64-14a0-c04db47c9d9a",
"Greenish|3b76d89b-2d96-796b-fc33-bdacd2df8fa5",
"Rose|6d59c124-2327-c423-6c5d-52f8989dda17"
];
integer LM_RESET_SECRIPTS = 101;
integer LM_SCALE_MESSAGE = 102;
integer LM_CAN_COLOR_CHANGE = 103;
integer LM_SHOW_COLOR_DIALOG = 104;
integer LM_SET_COLOR = 105;
integer LM_SHOW_MAIN_DIALOG = 106;
integer CHANNEL = -114757314;
list options_dialog;
list options_texture;
rebuild_options() {
integer count = llGetListLength( MENU_OPTIONS );
integer ii;
for ( ii = 0; ii < count ; ii ++ ) {
list pieces = llParseString2List( llList2String(MENU_OPTIONS,ii), ["|"], [] );
options_dialog += [ llList2String(pieces,0) ];
options_texture += [ llList2String(pieces,1) ];
}
}
integer listenhandler;
// Rebuild our listener and turn it off. Should really only be done
// on owner change.
reset_listener() {
llListenRemove(listenhandler);
listenhandler = llListen( CHANNEL, "", llGetOwner(), "");
llListenControl( listenhandler, FALSE );
}
show_dialog() {
list menu = options_dialog;
llDialog(llGetOwner(), MENU_NAME, menu, CHANNEL);
llSetTimerEvent(60);
llListenControl( listenhandler, TRUE );
}
send_linked(integer command, string options ) {
integer dest = LINK_SET;
if ( command == LM_CAN_COLOR_CHANGE || command == LM_SHOW_MAIN_DIALOG ) {
dest = LINK_THIS;
}
llMessageLinked( dest, command, options, NULL_KEY );
}
default {
state_entry() {
rebuild_options();
reset_listener();
}
touch_end(integer total_number) {
if (llDetectedKey(0) == llGetOwner()) {
show_dialog();
}
}
changed(integer mask) {
if ( mask & CHANGED_OWNER ) {
reset_listener();
}
}
link_message(integer sender_num, integer command, string message, key id) {
if ( command == LM_RESET_SECRIPTS ) {
llResetScript();
}
else if ( command == LM_SHOW_COLOR_DIALOG ) {
show_dialog();
}
}
listen( integer channel, string name, key id, string message ) {
integer sel_index = llListFindList( options_dialog, [message] );
if ( sel_index != -1 ) {
send_linked( LM_SET_COLOR, llList2String(options_texture,sel_index) );
show_dialog();
}
else if ( message == MO_BACK ) {
send_linked( LM_SHOW_MAIN_DIALOG, "" );
}
}
timer() {
llListenControl( listenhandler, FALSE );
llSetTimerEvent(0);
}
} |
| | |
| | #4 (permalink) |
| Senior Member ![]() ![]() ![]()
:confusedcat:
| Most of these solutions propose a script in each prim but really if you are changing few enough that it isn't horribly inefficient you might as well be hardcoding the values and doing llSetLinkTexture. It's more work to prepare but I do it over hundreds of prims. |
| | |
| 1 User Agreed: |
![]() |
| Thread Tools | |
| Display Modes | |
| |
| |