Changing textures in a prim
|
|
Mordigant Recreant
Registered User
Join date: 18 Jan 2007
Posts: 19
|
03-29-2007 10:22
I need a simple script that will change an object's texture based on what a user inputs into the chat bar via a "channel"? command, but I know nothing about scripting. Please help.
Thanks!
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-29-2007 14:16
From: Mordigant Recreant I need a simple script that will change an object's texture based on what a user inputs into the chat bar via a "channel"? command, but I know nothing about scripting. Please help.
Thanks! It would depend exactly upon what you wanted to be able to type in as to how difficult thsi would be. At its simplist it would be something like this integer Channel = 45;
default { state_entry() { llListen(Channel,"",llGetOwner(),""); }
listen(integer channel, string name, key id, string message) { integer type = llGetInventoryType(message); if(INVENTORY_TEXTURE == type)llSetTexture(id,ALL_SIDES); } }
All the textures would need to be in the items inventory.
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
03-29-2007 14:20
Make that llSetTexture(message,ALL_SIDES);

|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-29-2007 15:00
From: Deanna Trollop Make that llSetTexture(message,ALL_SIDES);
 ROFL yep my apologies. bad newgy
|
|
Mordigant Recreant
Registered User
Join date: 18 Jan 2007
Posts: 19
|
03-30-2007 07:00
Thanks for the code. How do I modify it to make it actually work?
Let's say the operational words are "cool" for a texture called Cool, "angry" for a texture called Yell, and "love" for a texture called Kiss. How would I enter these into the code?
Thanks
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-31-2007 01:43
From: Mordigant Recreant Thanks for the code. How do I modify it to make it actually work?
Let's say the operational words are "cool" for a texture called Cool, "angry" for a texture called Yell, and "love" for a texture called Kiss. How would I enter these into the code?
Thanks Well the code posted, with the correction given previously, does work  As I said at its simplist it can be done as above. The simplist way would be to rename your textures. The otehr solution is a translation table between the trigger word and the texture :- integer Channel = 45;
list Names = [ "cool" , "angry" , "love" ]; list Textures = [ "Cool" , "Yell" , "Kiss" ];
default { state_entry() { llListen(Channel,"",llGetOwner(),""); }
listen(integer channel, string name, key id, string message) { integer index = llListFindList(Names,[message]); if(index >= 0) { string texture = llList2String(Textures,index); integer type = llGetInventoryType(texture); if(INVENTORY_TEXTURE == type)llSetTexture(texture,ALL_SIDES); } } }
|
|
Mordigant Recreant
Registered User
Join date: 18 Jan 2007
Posts: 19
|
04-03-2007 06:22
I entered the code with the translation table into my script and all my textures are in the object's inventory. However, the object's texture is not changing when I enter my code words. Any ideas on why it's not working?
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-03-2007 06:59
From: Mordigant Recreant I entered the code with the translation table into my script and all my textures are in the object's inventory. However, the object's texture is not changing when I enter my code words. Any ideas on why it's not working? Without seeing the script you have in place and exactly how and what you are typing not really. The obvious things to check :- Are you typing on the right channel ? its set to use channel 45 so try /45 cool Is the script actually running? (check that the running check box is checked) Try adding some llOwnerSay messages to debug whats going on :- integer Channel = 45;
list Names = [ "cool" , "angry" , "love" ]; list Textures = [ "Cool" , "Yell" , "Kiss" ];
default { state_entry() { llOwnerSay("Ready. " + (string)llGetListLength(Names) + "Textures available.\n. Use /" + (string) Channel +" trigger to activate."); llListen(Channel,"",llGetOwner(),""); }
listen(integer channel, string name, key id, string message) { llOwnerSay("Heard " + message); integer index = llListFindList(Names,[message]); if(index >= 0) { string texture = llList2String(Textures,index); integer type = llGetInventoryType(texture); if(INVENTORY_TEXTURE == type)llSetTexture(texture,ALL_SIDES); else llOwnerSay("ERROR : \"" + texture + "\" is not a valid texture");
} else llOwnerSay("ERROR : \"" + message + "\" is not a valid trigger word"); } }
If that still doesnt help drop a full mod copy on me in world and I'll look at it when I get on tonight.
|
|
Mordigant Recreant
Registered User
Join date: 18 Jan 2007
Posts: 19
|
04-03-2007 07:26
It works! Thanks!
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-03-2007 07:50
From: Mordigant Recreant It works! Thanks! YW, what was the cause (and solution) of the problem?
|