Jump to content

HUD Communication

Zeet Brandris

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

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

Recommended Posts

Hello !


i'm quite a noob with LSL, and I'm trying to build a HUD for my sim, that would control a titler people would set above their head. I have no problem doing this for a single line titler, but since I want peopel to be able to set various lines independently, I wanna make a HUD with 5 buttons, that each open a text box in which they could write the text they want on the corresponding line. I first thought about storing each value in a list, and to send the list through a listener in the titler prim but... Well, i'm lost, I haven't found a good solution to do that.


DOes anyone know about a web page treating about that kind of stuff ? I'm eager to learn !

Link to comment
Share on other sites

Even though you're creating several lines, the text in a titler is really only one string.  All your HUD will do is allow you to build that string in five parts and paste them together. Your final string will look like

string Full_text = line_one + "\n" + line_two + "\n"+ line_three + "\n" + line_four + "\n" + line_five;

There's no magic in writing a script that builds those lines.  Use llDetectedTouchST to detect what part of the HUD you have clicked on -- one part for each of five "buttons" -- and open a llTextBox when the owner clicks on one. Update your Full_text string each time you create a new piece,  and display it with llSetText.

Link to comment
Share on other sites

Well, thanks for your reply ! The thing is, I don't know how to edit only one part of a string (hence why I wanted to cut it in list parts :x


Oh, also, is there a simple way to store the content of a text box in a variable ? That whole channel stuff is tedious and I'm quite lost, it's super not intuitive... :'(


Aaand another, one, can there be more than one listen event in a script ?


I wish I could find a good tutorial about all that :(

Link to comment
Share on other sites

1. You don't need to edit one part of a string.  You are collecting the individual parts separately.  All you need to do is glue them together.

2. Yes, you can store the message that's returned from a text box is a string variable.  That's what each of the parts of the Full_text are, after all. 

3. No, you may not have more than one of any event in a single state in your script. That's not a matter to worry about here, since you only need one listen event.

There is no tutorial for something as specific as this.  At this level, you are talking about logic.  That's where the hard thinking is in any scripting project -- how to gather bits of information and what you have to do in orde to get the result you want. Translating the logic into a script is the easy part.  You can find tutorials about how to do that. If you haven't already worked through basic LSL tutorials yet, start here >>> http://wiki.secondlife.com/wiki/LSL_Tutorial


Link to comment
Share on other sites

"Is there a simple way to do something ?" 

"Yes there is." 


Well, thanks for the reply but that's not exactly helpful. The tutorials just explain the basics of how to color a prim with chat commands, I've known how to do that for years. I KNOW you can store the content of a text box to a variable, what I need to know is HOW.


I hope it's clearer this way... ? it's nice to talk about script logic but those tutorials dont talk about logic at all. it's all super basic stuff, and when you wanna try advanced stuff, well, you're on your own.

Link to comment
Share on other sites

Zeet Brandris wrote:

[ .... ]

it's nice to talk about script logic but those tutorials dont talk about logic at all. it's all super basic stuff, and when you wanna try advanced stuff, well, you're on your own.

Yes, that's quite true.  That's the way it is for all of us.  The mechanics are easy.  The logic -- the real scripting -- is the puzzle you have to figure out on your own.  When I have a particularly complicated script to write, I still find myself falling back on the technique I used when I was just beginning.  Get out a piece of paper and create a flow diagram.  You have a known destination, and you know what you are starting with. The diagram is a map of how you want the script to get from start to finish, step by step.  Forget commands and variables. Just make the map. 

Step 1: owner clicks a button.  Which button? We better remember which one, because five paths emanate from here, all doing the same thing but for different buttons.   

Step 2 (on each separate path): script asks owner for information. 

Step 3: owner provides information.  Is it too long? Did we give the owner a time limit, and has it expired?  More decision points.  What shall we do if we get one answer rather than another?

Step 4: Where do we put the information?  We're expecting up to 5 pieces of information.  Which one is this (which path are we on?)? Remember the button number?

Step 5: Add information to what the owner has already provided, putting it in the right order with information from other paths.

Our result is going to be a composite that looks like

    Whole Thing = part one + part two + part three + part four + part five

Step 6: Save the Whole Thing so we can add or change pieces later if the owner provides more.

Step 7: Display the Whole Thing.

Step 8: Wait for the owner to start at step 1 again.

So there's a really crude flow chart in words.  It looks better on paper.  This puzzle is linear.  It has no fancy loops.  Just push a button, collect an answer, put that answer in the proper order with other answers, and display it.

The rest is mechanical, and is specific to the language we are using.  If you have done the basic tutorials, you know about states and events.  Those are the framework.  You know we'll need buttons.  I suggested using llDetectedTouchST for that, and there is a wiki code example to show how that works.  You have decided that you want the buttons to trigger text boxes, so the wiki has a nice short example of how to create one and what to do with the result. (it's the "message" that arrives in the listen event.)  

The only mechanical trick to resolve here is knowing which possible text box sent the message (that was step 4 above), but if we simply remembered which button the owner clicked, we know which text box he wrote in.  So if we have remembered that he clicked button 1, this must be part one. we'll need a string variable with a distinctive name (part_one) to put the message in >>> part_one = message;

Finally, you want to display the composite (Step 5 above) in hover text, so you'll need llSetText, which you also find in the wiki.  You'll want to separate your five message parts on separate lines, for which you'll need a simple code, which I demonstrated in my first response.  

That's it.  You'll have a script with one state and three events -- state_entry, touch_start, and listen.  You'll have five global string variables -- part-one, part_two, part_three, part_four, and part_five -- plus one more for the composite string -- Whole_thing.

Now you are on your own. BUT ... when you have written something and tested it and have questions, bring it back here and post it, along with your specific questions.  We'll help you figure out what to do nerxt.

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...