JDroo Posted September 23, 2017 Share Posted September 23, 2017 (edited) So I'm working on a script, and I've hit a road block of sorts. So what I'm wanting to do is, I have a listener set up, I want to type the name of any named texture in the objects inventory and than have it set that texture as the objects texture.So simply typing "smile" would than find the texture named smile in the contents and know to use that texture, and than set it. But I don't want to hard code any of the names in, I want to make it so anyone can add their own images to it, and simply type what they named the texture in chat for it than display the texture on the prim Currently I have it just set to show any texture no matter what I type using "gTexture = llGetInventoryName(INVENTORY_TEXTURE,(integer)llFrand( llGetInventoryNumber(INVENTORY_TEXTURE)));" Tho my script is a bit more complex than just this bit, currently it can set animation x and y frames if the texture can be an animated texture, it can set the scale of the prim also, all by how I named the textures. So in theory it will be an emoter that will display images or animated images on just typing in local chat, and if it detects any of the words that trigger the emote it will change the prim to match accordingly. know i could easily just add a listen for each item, but I'd really like to make it be a bit more mod friendly for peeps that want to add their own images to the contents of the object. any help or pointers would be a great help. or point me to existing scripts for examples on what to do. Edited September 23, 2017 by JDroo Link to comment Share on other sites More sharing options...
KT Kingsley Posted September 23, 2017 Share Posted September 23, 2017 Is this the sort of thing you're looking for? if (llGetInventoryType (chat_text) == INVENTORY_TEXTURE) 1 Link to comment Share on other sites More sharing options...
Qie Niangao Posted September 23, 2017 Share Posted September 23, 2017 3 hours ago, JDroo said: ... it can set animation x and y frames if the texture can be an animated texture, it can set the scale of the prim also, all by how I named the textures. Do I understand correctly that the texture names encode both the chat trigger text and these animation and scaling parameters? So the wearer would need to say something like "smile 32x44s1.0t0.75" or whatever the texture name must be to code those parameters? Or is the idea that the chat trigger only needs to match part of the texture name? Assuming the latter, you might want to match for a non-negative llSubStringIndex(chat_text, texture_name_token) for every texture in inventory, where texture_name_token is the "smile" part of however "smile 32x44s1.0t0.75" is encoded. (Actually, if that's correct, I might instead pre-parse all the texture names into a list of match-tokens, so then I could llListFindList(texture_token_list, [chat_text]) for direct matches.) Where this could start getting expensive is matching tokens that could appear anywhere in extended chat text, rather than just one chatted word. It's do-able, certainly, but one starts thinking about leveraging the viewer's built-in Gesture text-matching somehow. Link to comment Share on other sites More sharing options...
Rachel1206 Posted September 23, 2017 Share Posted September 23, 2017 (edited) Get some inspirations from this older wiki sample: Touch Texture Switch by Bobbyb30 Swashbuckler. Edited September 24, 2017 by Rachel1206 Link to comment Share on other sites More sharing options...
JDroo Posted September 23, 2017 Author Share Posted September 23, 2017 (edited) the textures are named something like "smile.anim;3;2;10;0.32525;0.22957;0.01000" so the texture is named smile.anim, cause it's a texture that can be animated, the 3, and 2, are the x and y frames for the animation, the 10 is the speed it plays at, the "0.32525;0.22957;0.01000" are <0.32525,0.22957,0.01000> the scale I want the prim to be, that stuff ALL works, I don't need help with that part, I just need to know how to make the script know the name of the texture, right now I'm just grabbing the random inventory number, but I'm not sure how to do it by name, I'm guessing I need to make a list or something of the contents? [it would be called "smile.static;0.32525;0.22957;0.01000" if it was not animated and would exclude the frames and speed for animation] so in the case of "smile.anim;3;2;10;0.32525;0.22957;0.01000", I want to filter it down to just "smile" than be able to type "smile" in open chat and the prim than to grab that texture and use it as an emote. Edited September 23, 2017 by JDroo Link to comment Share on other sites More sharing options...
JDroo Posted September 23, 2017 Author Share Posted September 23, 2017 11 hours ago, Rachel1206 said: Get some inspirations from this older wiki sample: Touch Texture Switch by Bobbyb30 Swashbuckler. This wont work, those are hard coded textures, they would need the UUID's embedded in the script, not really close to what I'm doing. Link to comment Share on other sites More sharing options...
JDroo Posted September 23, 2017 Author Share Posted September 23, 2017 12 hours ago, KT Kingsley said: Is this the sort of thing you're looking for? if (llGetInventoryType (chat_text) == INVENTORY_TEXTURE) that returns an integer tho...right? Link to comment Share on other sites More sharing options...
Rolig Loon Posted September 23, 2017 Share Posted September 23, 2017 You could of course create a list of the texture names in inventory and then just loop through them, asking integer idx = llSubStringIndex (llList2String(AllTextures,i),"smile"); if (~idx) { //This one's a keeper } Link to comment Share on other sites More sharing options...
Innula Zenovka Posted September 23, 2017 Share Posted September 23, 2017 (edited) 54 minutes ago, JDroo said: that returns an integer tho...right? Yes, in that it will return TRUE or FALSE, so you know whether chat_text is the name of a texture in the object's inventory or not. However, based on what you've now said about your naming convention, I think I would do something like this (there's more economical ways to do it but I'm trying to give a clear example). First, I'd create two lists and populate them thus: list lNames; list lTextures; default { state_entry() { integer counter; integer max = llGetInventoryNumber(INVENTORY_TEXTURE); do { string str = llGetInventoryName(INVENTORY_TEXTURE,counter); list temp = llParseString2List(str,["."],[]); lNames += [llList2String(temp,0)];//the part of the texture name before the full point. lTextures += [str];//the whole name of the texture } while(++counter < max); } Then in the listen event, listen(integer channel, string name, key id, string message) { integer index = llListFindList(lNames,[llToLower(message)]);//look for whatever I've just heard in the Names list if(~index){ //index > -1, so I've found it there string strTexture = llList2String(lTextures,index); //find the corresponding entry in the full texture list //do stuff } } That should do it, I think Edited September 23, 2017 by Innula Zenovka 1 Link to comment Share on other sites More sharing options...
JDroo Posted September 23, 2017 Author Share Posted September 23, 2017 31 minutes ago, Innula Zenovka said: Yes, in that it will return TRUE or FALSE, so you know whether chat_text is the name of a texture in the object's inventory or not. However, based on what you've now said about your naming convention, I think I would do something like this (there's more economical ways to do it but I'm trying to give a clear example). First, I'd create two lists and populate them thus: list lNames; list lTextures; default { state_entry() { integer counter; integer max = llGetInventoryNumber(INVENTORY_TEXTURE); do { string str = llGetInventoryName(INVENTORY_TEXTURE,counter); list temp = llParseString2List(str,["."],[]); lNames += [llList2String(temp,0)];//the part of the texture name before the full point. lTextures += [str];//the whole name of the texture } while(++counter < max); } Then in the listen event, listen(integer channel, string name, key id, string message) { integer index = llListFindList(lNames,[llToLower(message)]);//look for whatever I've just heard in the Names list if(~index){ //index > -1, so I've found it there string strTexture = llList2String(lTextures,index); //find the corresponding entry in the full texture list //do stuff } } That should do it, I think Omg, thank you, you got it! it works perfectly! Link to comment Share on other sites More sharing options...
JDroo Posted September 23, 2017 Author Share Posted September 23, 2017 1 hour ago, Innula Zenovka said: That should do it, I think it does work, is there a way to make it listen for the word no matter where it is in the sentence? Link to comment Share on other sites More sharing options...
Innula Zenovka Posted September 24, 2017 Share Posted September 24, 2017 Try listen(integer channel, string name, key id, string message) { list temp = llParseString2List(llToLower(message),[" "],[]);//break the message down into a list of the component words integer max = -llGetListLength(max); //negative indices start from the beginning of the list, so llList2String(temp,max) is the 1st word in the sentence integer index; do {//loop through the message, word by word index = llListFindList(lNames,[llList2String(temp,max)]);//is the word to be found in the lNames list? if(~index){//yes, it is max = -1;//so stop looking string strTexture = llList2String(lTextures,index); //find the correspondent entry in the full texture list //do stuff } } while(++max); } 1 Link to comment Share on other sites More sharing options...
JDroo Posted September 24, 2017 Author Share Posted September 24, 2017 (edited) 12 minutes ago, Innula Zenovka said: Try listen(integer channel, string name, key id, string message) { list temp = llParseString2List(llToLower(message),[" "],[]);//break the message down into a list of the component words integer max = -llGetListLength(max); //negative indices start from the beginning of the list, so llList2String(temp,max) is the 1st word in the sentence integer index; do {//loop through the message, word by word index = llListFindList(lNames,[llList2String(temp,max)]);//is the word to be found in the lNames list? if(~index){//yes, it is max = -1;//so stop looking string strTexture = llList2String(lTextures,index); //find the correspondent entry in the full texture list //do stuff } } while(++max); } It's giving me a function call mismatch type or number or arguments error on integer max = -llGetListLength(max); changed it to integer max = -llGetListLength(temp); and it fixed it Edited September 24, 2017 by JDroo Link to comment Share on other sites More sharing options...
JDroo Posted September 24, 2017 Author Share Posted September 24, 2017 Thanx for all the help! I learned allot. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted September 24, 2017 Share Posted September 24, 2017 Sorry tor the typo. As you rightly saw, I meant integer max = -llGetListLength(temp); Link to comment Share on other sites More sharing options...
Rachel1206 Posted September 24, 2017 Share Posted September 24, 2017 11 hours ago, JDroo said: This wont work, those are hard coded textures, they would need the UUID's embedded in the script, not really close to what I'm doing. Ohh the link reference was wrong, this is the correct one: http://wiki.secondlife.com/wiki/Simple_Texture_Changer_(for_inventory)(more_than_one_side).lsl Now, even if hard coded in an example, you just change source code according to your wishes, task ahead. Link to comment Share on other sites More sharing options...
Recommended Posts
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