Please continue this tutorial with Variables. Each event handler handles one particular type of event and the parameters in the event handler provide the script with the specific details of the event. The details will differ with the event, but the idea is always the same. There are many events (about 38 different ones) and most of them have one or more parameters (that's those things like "integer num_detected" that follow them in the parenthesis). But before fully explaining how that works, we need to learn some other things, so we won't elaborate on that yet. That's the purpose of the phrase "integer num_detected" between the parentheses following touch_start. In case your script really needs to respond separately to each touch, SL will tell you how many touches an execution of the touch_start event handler represents. So are worn objects treated differently by scripts or somethingThis is. They work perfectly on a rezzed object of reasonable distance though.
Instead, it may combine two or more of the touches into one event. Ive went through several simple show/hide scripts (that listen for a chat command, not a fan of touch commands), but none of them work on a worn objects.
SL SHOWHIDE ON TOUCH SCRIPT CODE
But if multiple users click on your object at approximately the same time, SL may not invoke your code for each one separately. If a user clicks on your object many times, the touch_start event handler code will generally get executed many times, once for each click. But if you get a bunch of your friends together and have them all touch the object as rapidly as they can, sometimes you will see TotalTouches incrementing by more than one. If you test this by yourself, chances are that TotalTouches will always be incrementing by one. Each time the touch_start event handler is called, the sim server initializes num_detected to be the number of times the object was touched since the previous execution of touch_start. The variable set above default (global variable) called TotalTouches counts the total number of times our object is touched. One last useful tip : by setting the channel parameter to a negative number, you prevent avatars from issuing a direct command over the chat, and only the control script will be useable.Default
Its parameters (channel and commands) should be the same as those of the ShowHide script. That way, you can make all your poseballs appear or disappear at the same time by touching the control. You can also set the color of said text in the parameters.Ī second script (ShowHide control) is designed to be placed in an object (like a cube or a poster) to "toggle" the show and hide commands for objects in range that have the first script. Currently the script is limitted to setting only the root prim's text (could be done in a different way but, well.). Due to some limitation, the floating text, if any, to be set above the root prim has to be entered in the script too. The channel number, as well as the SHOW and HIDE commands are customizable via easy parameters at the start of the script. If you plan to have this functionnality on objects with partial transparency on some faces, a way more subtle means to do this is required. Do not use it however for things more complicated, like a house or a tent, because the mechanism the script uses to make the object disappear will alter the alpha (transparency) setting of all faces of all prims in the object, and will make them fully opaque again when reappearing. This script is very simple but proves useful for hiding simple things like pose balls. It also takes "care" of hiding and showing the text above the object (but see details below). Its job is to make an entire object (a whole link-set) disappear or appear upon "hearing" a command on a private channel. Here is a little script I quickly put together.