Jump to content

Working example of Mesh texture change script


DannyAeon
 Share

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

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

Recommended Posts

Hello I seem to not be able to find a working example of what I need. I am completely new to scripting. I have read multiple pages with similar scripts and mostly bits and peices of scripts that should go toghether, but I'm not sure how to peice them toghether. 

I have a simple mesh with two faces where I need  to change "Face 1" and "Face 2" to a matching set of textures. 

I am going to build an HUD worn by the owner made of 5 prims, 4 being buttons. Each prim button needs to apply a different set of textures. For the moment I would like the scrpt to work from a worn HUD and change textures on a rezzed mesh object on the floor.

As mentioned before I can't structure and peice the bits of scripting found on these pages to the correct format for a working script. With a working example I believe I can study it and add it to my four buttons by changing texture uuids. Can someone please help? Thank You.

After a bit of reasearch It seems I need the following:

 

Set mesh texture on two faces.

http://community.secondlife.com/t5/Mesh/quot-Mesh-Texture-Changer-quot-on-one-multitexture-mesh-object/td-p/1652669

Texture changer with HUD

http://community.secondlife.com/t5/LSL-Scripting/Texture-changer-via-HUD-for-worn-object/td-p/1752027

Use llGetOwner

http://community.secondlife.com/t5/LSL-Scripting/Hud-texture-changer/td-p/1659509

 

  • Thanks 1
Link to comment
Share on other sites

Hello I seem to not be able to find a working example of what I need. I am completely new to scripting. I have read multiple pages with similar scripts and mostly bits and peices of scripts that should go toghether, but I'm not sure how to peice them toghether. 

I have a simple mesh with two faces where I need  to change "Face 1" and "Face 2" to a matching set of textures. 

I am going to build an HUD worn by the owner made of 5 prims, 4 being buttons. Each prim button needs to apply a different set of textures. For the moment I would like the scrpt to work from a worn HUD and change textures on a rezzed mesh object on the floor.

As mentioned before I can't structure and peice the bits of scripting found on these pages to the correct format for a working script. With a working example I believe I can study it and add it to my four buttons by changing texture uuids. Can someone please help? Thank You.

After a bit of reasearch It seems I need the following:

 

Set mesh texture on two faces.

http://community.secondlife.com/t5/Mesh/quot-Mesh-Texture-Changer-quot-on-one-multitexture-mesh-object/td-p/1652669

Texture changer with HUD

http://community.secondlife.com/t5/LSL-Scripting/Texture-changer-via-HUD-for-worn-object/td-p/1752027

Use llGetOwner

http://community.secondlife.com/t5/LSL-Scripting/Hud-texture-changer/td-p/1659509

 

Link to comment
Share on other sites

I hope I didn't create the impression that I need a step by step walk through for creating a working HUD, its not needed.  Correctly formated working example of just the scripts is all I need, afterwards I believe I can study them, change them and add them to my prims and mesh myself. 

The following scripts would have been alot of help if only they were formated correctly, and not examples of what needs to be changed. 

Its important for a experienced scripter to keep in mind someone that is new to scripting dosen't see the code the way that you do, it is completely alien for that person. A person that is new to scripting can't seperate what is actual code from comments or text that needs to be replaced by numbers. 

Providing working examples is how i best learn from something new I'm trying to learn. In this case they would be correctly formated working examples of scripts.

simple transmitter:

default{    state_entry()    {        llListen(-67890,"","","");    }    touch_start(integer total_number)    {        llTextBox(llDetectedKey(0)," \n Enter a texture key",-67890);    }        listen(integer channel, string name, key id, string msg)    {        llRegionSay(-12345,msg);    }}

 The second is an equally simple-minded texture changer:

default{    state_entry()    {        llListen (-12345,"","","");    }    listen(integer channel, string name, key id, string msg)    {        llSetTexture(msg,ALL_SIDES);    }}

 

Link to comment
Share on other sites

  • Moles

You're almost there.  Look at the syntax for llSetTexture.  You'll see that tyhe parameter that you now have set to ALL_SIDES is used to designate which face you want to apply your texture to.  So, if you want the texture on face 1, change ALL_SIDES to 1, and so on.  Easy peasy.

Beyond that, the only thing you'll probably want to do is add a bit of dialog so you can specify the face by clicking a button instead of having to dismember the script every time.  You could use the llTextBox system that you already have, but since you have a predictable set of well-known face numbers to work with, llDialog is a better choice.  Study the syntax of that function and the examples in the LSL wiki to write your own dialog menu.

Then you're done.  :smileywink:

  • Thanks 1
Link to comment
Share on other sites

I see that those two scripts were put up as an illustration by the very competent Rolig Loon so my comments below are in no way criticism but maybe it will help to have some words around what's going on?  I'm going to fail here because i'm not going to write full scripts though so my apologies straight away.

Communications in these scripts occurs over channels, when something is "said" on a channel, it will be heard by any script "listening" on that channel, depending on whether the script is listening to all, just the owner or other factors.

The simple transmitter starts by listening on channel -67890 to everything, everyone.  (More on this later).  So any script transmitting on that channel will be heard.

The transmitter then gets triggered by a touch that picks up the key of the person who touched it llDetectedKey(0) and asks them to enter a UUID for the texture in a textbox.  When the user presses "ok" on that textbox dialog, the text is sent to anything listening on -67890.  Great!  This script is listening on that channel so...

The listen event is triggered and the parameter "msg" is the UUID that the user entered in the textbox.  The content of the listen is to send a message to the whole region on channel -12345 and it sends the msg parameter which is the user entered UUID.  Fine so far.


Now to the receiving script:-

This starts by listening on channel -12345, to anything, everyone, the "","","" part of the script listen filter (see llListen in the LSL API for more on this).

When this script hears the incoming message on that channel, the msg part of the incoming message is that UUID that the user entered that was "said to region" from the transmitter script, so within the listen event, the function to set the texture llSetTexture is called and the texture as passed by the variable msg, is set on all sides.

(for the next part, i'm going to assume that your root prim is the main hud prim and thus link number 1 and so your buttons will be 2, 3, 4, 5.)

So this all works and as a very simple upgrade, what you need to do is determine in your hud which button was pressed.  You can do this with llDetectedLinkNumber and then in the touch_start, send the number such as llRegionSay(-12345,(string)llDetectedLinkNumber(0));

Then, in your receiving script, in the listen event you need to perform some checks to see whether msg is "2", "3", "4", "5" and then call llSetTexture(LINK_SET,uuid as appropriate, face) where the UUID is the one you need in double quotes and the face is the number of the face on the mesh to set the texture on.

If you can get this working then you're off to a good start and that's where i'd suggest you begin.

There are some caveats with Rolig's initial demo though which need to be changed eventually and the ones that come to mind are as follows (again, no criticism here, Rolig posted a quick and dirty working EXAMPLE, not final solution):-

ANY script that uses the same channels will interfere.  Two users in the same sim will be changing each others mesh.  Either use the random number generator to pick random channels and hope for the best or derive the channel frome something like the owners key.

The listens never get closed.  The llListen could be moved to the touch_start event and closed after a timeout or in the listen event.  There's a good example of writing dialog boxes here which goes through this sort of thing in detail and is well worth working through http://wiki.secondlife.com/wiki/Dialog_Menus

Some may prefer to name buttons instead of using link numbers, result is the same, just gets easier in more complex objects where you may add/remove prims and thus don't have to worry about the link order and thus buttons pressed.

llRegionSay could be replaced by llRegionSayTo which is more secure because you can specify that the message is said to the scope of the region but only to specified objects or if the item is worn, to all objects worn by the avatar when you specify the avatar key.

Just to add that I don't see anything wrong with the formatting of those scripts and again, I apologise for not delivering what you asked for exactly but my suggestion would be to use exactly what Rolig wrote, make that work and confirm for yourself that it does work, then do as I suggested above and see if you can make llDetectedLinkNumber work to send the touched prim number to your other script and use "if" condition to set texture based on the incoming number.

If you can do this bit as your next learning, then come back and lets deal with what comes next :matte-motes-sunglasses-1:

  • Like 1
Link to comment
Share on other sites

The scripts you have will work and I don't see a problem and you didn't name a problem. 

However, some statements for this case:


- You know what a texture key is? Right click on a texture in your viewers inventory and choose "copy asset uuid". Now you have a "texture key" In your clipboard and can paste it into teh textbox teh transmitter script will pop up.

- ALL_SIDES means all faces so if you want to change one face then put the # here instead. No, not face 1 and 2 its face 0 and 1. A mesh has max 8 faces thats 0 to 7.

- Make 2 transmitters and let them send on different channels: -12345 and -12346 for example.
  in the listen event of the receiver you can check the channel:

if  (channel == -12345) llSetTexture(msg,0);else llSetTexture(msg,1);

 That should give a start for experiments.

 

Link to comment
Share on other sites

@Nova Convair

You are very kind to try and help.

But I did mention what the problem was, 

1: I am completely new.

2: I cannot for the life of me take pieces of scripting and structure them and format them together to make a working script.

If I new how one transmitter worked I would be happy to make 2. 

@Dyna Mole

I was aware I was almost there, I thought some one could actually show me what to change. I was hoping to find working scripts ot this simple function, writing a dialog is beyond what I was hoping to get help for.

I feel like Im trying to learn how to drive a car, with out ever seen a car before by taking a kit of car parts and studying how to put that car together. 

If I could see a working car and study that I'm sure I could learn how to drive a car a lot sooner, maybe install a radio afterwards.

Does that make sense? lol Hence new. But that's the funny thing if I could see a working script I could be able to decipher it better.

I understand if you wouldn't want to do the work for me you could say by putting this simple script together, but that's really the only way I'm gonna study and learn how it works. I have already spent months how to create nice enough mesh objects people might wanna buy. That was exausting enough.

There's no need to learn how to build a car when I just need to lean how to drive it. I've looked at the marketplace there are no simple scripts cheap enough for such a simple task. The scrips on the marketplace are like Lamborghinis, when all I need is a Volkswagen beetle to go by groceries with.

Thank You everyone for your help, but I think I need to pay someone to make me these simple working scripts. Maybe this hasn't been considered or realized by residents who wonder why user retention is so low, but the scripting aspect of creation for second life is too steep, even more so than creating mesh in my opinion.

Link to comment
Share on other sites

You have reached exactly the right conclusion.  You posted a question here, in a forum that is meant for scripters to share ideas and moan about things that don't work right.  If you are a scripter or are interested in learning how to script, this is a great place to ask.  If you're expecting a finished script or even a quickie that you can tweak, though, you are quite right to post in the InWorld Employment forum instead, so that you can attract the attention of a scripter for hire.

Scripting is a challenge in any language, not just LSL.  Steep learning curves are part of the scripting landscape, not just in SL. Please come back again if you want to start climbing. 

Link to comment
Share on other sites


DannyAeon wrote:

Does that make sense? lol Hence new. But that's the funny thing if I could see a working script I could be able to decipher it better.

Those that Rolig posted work.

A general purpose script that does what you want, needs to have all kinds of configuration options to do linknumbers and faces and such.  They can be quite complex to understand too, more than the scripting in some cases.

Link to comment
Share on other sites


Rolig Loon wrote:

You have reached exactly the right conclusion.  You posted a question here, in a forum that is meant for scripters to share ideas and moan about things that don't work right.  If you are a scripter or are interested in learning how to script, this is a great place to ask.  If you're expecting a finished script or even a quickie that you can tweak, though, you are quite right to post in the InWorld Employment forum instead, so that you can attract the attention of a scripter for hire.

Scripting is a challenge in any language, not just LSL.  Steep learning curves are part of the scripting landscape, not just in SL.
Please come back again if you want to start climbing. 

I would be happy to start climbing if I saw a mountain before me, not a scattered web of rocks and pebbles too far apart to hopelessly try and reach.

In anything that I have tried to ever learn in my life I always looked for working examples. 

In the Mesh creation forum people who are helpless and want to learn are helped with so called quickie tutorials with very difficult or complicated aspects about Mesh to try and learn on there own, and I see this happen over and over again.

But no, when it comes to scripting you gotta pay up for even just a quickie.

I was happy to help people in the Mesh creation forum with the things I have learned about mesh creation, but next time I should probably just point someone to the Inworld Employment forum so that they can attract the attention of a 3D modeler for hire.

Link to comment
Share on other sites


DannyAeon wrote:


[ .... ] In anything that I have tried to ever learn in my life I always looked for working examples. 

In the Mesh creation forum people who are helpless and want to learn are helped with so called quickie tutorials with very difficult or complicated aspects about Mesh to try and learn on there own, and I see this happen over and over again.  [ .... ]


But you posted my simple working examples, and Dyna told you exactly what small steps you'd need to take to apply them to your situation.  Sassy went into significantly more detail. You should have enough to get a working script going, or at least something that you could post back here and ask for help with.  Anything more would have meant writing the script for you. That's not what the scripting forum is for.

Link to comment
Share on other sites

I dsen't seem fair that when you do a search for Mesh creation on Google you get an endless see of helpful video tutorials, but when it comes to LSL Scripting it's almost hopeless for someone thats new to scripting.

Thanks everyone for you help, but I'll continue to try and lean on my own.

Link to comment
Share on other sites


DannyAeon wrote:

...

I was happy to help people in the Mesh creation forum with the things I have learned about mesh creation, but next time I should probably just point someone to the Inworld Employment forum so that they can attract the attention of a 3D modeler for hire.

 After looking at your posting history and seeing how much you've contributed to the Mesh forum, I can offer you the following:

 

No one has ever learned to either drive nor construct a car by looking at show room models.

  • Like 1
Link to comment
Share on other sites


LepreKhaun wrote:


DannyAeon wrote:

...

I was happy to help people in the Mesh creation forum with the things I have learned about mesh creation, but next time I should probably just point someone to the Inworld Employment forum so that they can attract the attention of a 3D modeler for hire.

 After looking at your posting history and seeing how much you've contributed to the Mesh forum, I can offer you the following:

 

No one has ever learned to either drive nor construct a car by looking at show room models.

Its true I have no history as DannyAeon, ("AS" being the keyword).

LepreKaun I am sorry about the HUD tutorial you tried to post before. I was pretty exited to follow an learn from it until it got derailed. A real shame. 

The Lamborghini reference was meant as the expensive HUD scripts with all kinds of bells and whistles that I don't need, available on the marketplace. Thats why I mentioned all I really needed was a Volkswagen beetle, something simple.

My current strategy is looking at working scripts for the individual portions of the scripts I need and then comeback and modify Ms Loons scripts. Its gonna take me awhile but I think Ill eventually get it. I also found this LSLEditor scripting thingy that helps with pointing out syntax errors, very helpful. This following tutorial might actually leapfrog me to the script setup I need.

For anyone in my unfortunate situation the following is a really great tutorial, I wonder why tutorials like these are so hard to find.

 

Tutorial: How to make a scripted mesh female tanktop with a HUD.

http://oddy.nl/?p=824

Link to comment
Share on other sites


DannyAeon wrote:

I dsen't seem fair that when you do a search for Mesh creation on Google you get an endless see of helpful video tutorials, but when it comes to LSL Scripting it's almost hopeless for someone thats new to scripting.

Thanks everyone for you help, but I'll continue to try and lean on my own.

https://www.google.co.uk/#q=lsl+script+library

Learning scripting is NOT the same as learning mesh or photoshop. Apples and Oranges.

Any form of programming is learning a language, syntax rules (grammar), functions (vocabulary), variables, constants and so on.

Just about each function in LSL has an example in the wiki, there are no shortcuts.  I can follow a set of blender tutorials to accomplish a task, blindly clicking certain things to achieve an end result and repeat that over and over if necessary.  Scripting is different because you to know the functions, what they take, what the errors are and how to interpret them and more importantly apply what you know to fix them.  This is learned bit by bit.  There's still plenty of LSL that I don't know (or have much interest in such as all the vehicle stuff and much of the physics.  I just don't know that vocabulary in the language).

You have to start by doing, right at the beginning and people here will help, as we have done.  You have working scripts from Rolig to being with and suggestions have been made where to go from there.

As I said, go through the dialog tutorial that I linked because it introduces a number of elements one after the other and discusses an initial functional script and then explains what's wrong with it and goes on to improve it until it's finished.

The other reason why finished scripts won't always help you is that some people write very obtuse code and there are also so many different ways to achieve the same result, each with pros and cons.  The examples you have been given are ways to step foward but it seems that you don't want to try at all?

Link to comment
Share on other sites


DannyAeon wrote:

 

For anyone in my unfortunate situation the following is a really great tutorial, I wonder why tutorials like these are so hard to find.

 

Tutorial: How to make a scripted mesh female tanktop with a HUD.


Sorry to rain on the parade but that's not a great method anymore.  For a 2013 script, that's using a script per HUD button which hasn't been necessary for several years.  A single script can accomplish the same just as easily, i've already described how to do that with llDetectedLinkNumber();

The script also uses a static channel and thus if you re-use the same script for someone else or another object of your own, you'll end up with people changing other people's objects or their own incorrect object.  I've already described two methods to avoid this in my earlier write up.

That's not really doing anything that you don't already have with the first method from Rolig (which needs more work anyway).

Link to comment
Share on other sites

All I needed were these simple scripts. 

When I used to be at Cloud Party they had an abundance of working scripts, since they were correctly formatted and working I was able to spot patterns and take code from their syntax library and add some extra functions. I don't have any scripting experience, but still I managed. I do have some logic in my thinking but that only helps when I see patterns and properly formatted code. 

I just don't see the code they way an experienced person does. Telling me how to work with something as complicated as scripting is NOT the same as showing me how. But again thanks for the help, I'll try to find working scripts to study.

Link to comment
Share on other sites

I still don't understand the problem. You keep referring to needing properly formatted code and workng example.

 

Rolig's first two scripts already are working and properly formatted and I gave you a full detailed breakdown about what they do

 

Every response so far comes back with how something else is a better platform, better tutorials, how nobody here I send willing to help, I'm a bit confused to be honest.

 

You have what you asked for, now instead of contemplating how great Cloud Party was or whatever, start again and read the answers here.

Link to comment
Share on other sites

What people are pointing out to you is that you're trying to enter high school when you haven't completed grade school.

What you want would be so simple in your own eyes if you learn the basic theories instead of trying to achieve a practical first.

 

My suggestion is you forget about learning scripting if you don't want to spend a lot of time studying the basic theories first.  You're better off trading your mesh services with someone who's willing to offer their scripting services.  And again, this particular forum is not for that.  This one is: http://community.secondlife.com/t5/Wanted/bd-p/Wanted

  • Like 1
Link to comment
Share on other sites

  • 3 years later...
On 01.05.2014 at 11:09 PM, Dyna Mole said:

You're almost there.  Look at the syntax for llSetTexture.  You'll see that tyhe parameter that you now have set to ALL_SIDES is used to designate which face you want to apply your texture to.  So, if you want the texture on face 1, change ALL_SIDES to 1, and so on.  Easy peasy.

Beyond that, the only thing you'll probably want to do is add a bit of dialog so you can specify the face by clicking a button instead of having to dismember the script every time.  You could use the llTextBox system that you already have, but since you have a predictable set of well-known face numbers to work with, llDialog is a better choice.  Study the syntax of that function and the examples in the LSL wiki to write your own dialog menu.

Then you're done.  :smileywink:

Thanks for tip!

  • Thanks 1
Link to comment
Share on other sites

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