How Do I...
Keep data in a script that goes thru: 1-taking the object with the script; 2: re-rezzing it like puppeteer scripts are able to?
In case you are forced to reset the script, use the object's Description with llSetObjectDesc() to store (a limited amount of) persistent data. In case the character limit enforced by Description not enough, use the description attribute of linked prims.
Alternatively, just do not reset the script and all internal variables, state, etc. will remain the same after re-rezzing.
...Display dynamic text on a screen via script?
...Activate/Deactivate "light" settings and adjust a prim's "glow" setting with a typed command?
...create a script that will tell me the names of my online friends?
...get a script to read from another file; IE: a notecard?
...give someone a folder full of inventory items?
...specify which folder I want the inventory items to end up in?
...make a gun?
...find out if land is no-build/no-script, etc?
...get the length of a string?
...get the arc for a sensor that senses straight ahead?
....and also the arc for a sensor that scans around and above its task (but not underneath it) without changing the task's orientation? (Specifically, when nobody's around to see a critter, I want to it to sleep to keep from lagging the server without making the critter look wrong from afar.)
To do this you will need more than one prim. The first, set the radius to PI. The second set the radius to PI_BY_2, then you figure out which face the sensor is coming out of and tilt it up. Have the sensor facing up send a llLinkedMessage to the first prim when no_sensor() is triggered which will make the main script do ++no_avatar. When the main script gets no_sensor, have it do ++no_avatar. Do the same for sensor() event, except have it do --no_avatar. Once no_avatar reaches 2, you can do whatever after that. My suggestion is to make this a handler script, and have it turn off whatever script is in the critter. If you need some help, please feel free to contact me, Ace Reikaz.
...edit around with an avatars profile?
You can't through LSL.
...make a texture semi transparent for the avatar body so the underlying texture can be semi visible?
(Need more information.) You may just want to edit the avatar's clothing texture itself. (Still needs more information) In viewer 2, there is now a tattoo layer, and support for transparent clothing, making invisaprims obsolete.
....and also the arc for a sensor that scans straight below its task?
. For a reduced arc, use a smaller value
for the arc parameter
. To use the sensor in a different direction
than east (forward), rotate
the prim in that direction.
...make magical holes in walls that you can walk through?
. You can make holes in box prims by modifying its hollow under the Object tab in the Edit menu.
You can also use llSitTarget
to jump through walls.
...make my script communications secure?
See Script security
...create a script that generates a random number?
integer rand(integer max)
float f_max = (float)max;//we do this typecast explicitly (otherwise the compiler just fills it in for us.
if(max != f_max)//max was an integer that couldn't be made into a float nicely.
return (integer)(max * llFrand(1.0));//multiply max by a rand float with a 0->1 range.
return (integer)llFrand(f_max);//the convert was clean so make LSL do the work.
This is a function that is called by: rand(50), which would return a random integer between 0 and 49 inclusive.
...make a script that changes the color of an item?
...make an invisiprim?
for an example script. - Joker Opus
Note: invisiprims are now obsolete, viewer 2 allows transparent textures to be applied to the avatar.
... get the direction an agent is facing (not the direction of the head)?
in a sensor or attachment.
... have object A tell object B its position and rotation, and have object B replicate the positioning and rotation, aside from a small offset on the local Z axis?
Get position with llGetPos
rotation with llGetRot
, cast them to strings, use llSay
to communicate them, then in B's listener cast the message back to vector
, adjust it and set it with llSetPos
... move multiple linked prims at once without them going out of sync?
Take a look at llMessageLinked
for low-lag communications for linked prims.
... make a lift/elevator?
It's possible to use llSetPos
to make a non-physical lift, but most people prefer physical ones (if the lift is 31 prims or less, of course). Try llMoveToTarget
for dampened physical movements.
... modify a script while running?
There's no way to save a script while keeping it running (except if the script is copied into your inventory).
... remove spam comments from the LSL wiki?
Try editing the page.
... make an object move away from avatars, maintaining a minimum distance from all -- similar to a dangling carrot or running away like a scared animal. ...
for the general principle, though not a specific method.
... do the equivalent of an HTML A(nchor) in the object text? I want to make a portion of the text hovering over an object, set with llSetText(), clickable so that I can do something like, show the profile of the owner of the object, when I click his name. etc. ...
Although this is not technically possible, although you could have an invisible cube overlapping the llSetText() with a touch event, however this is unreliable, because the llSetText()'s text moves based on camera position (and I think it depends on resolution). Also, you might just consider making the SetText
box touchable instead of dealing with an unreliable method.
... have an object create a new prim and link it to itself so it can grow. And unlink and delete a prim of itself...
Before I invest a lot in second life I would like to know how a script could dynamically create and remove new prims. I am interested SL for organic simulation.
You should check out llRezObject
and the SelfReplication
page. There is helpfull information and examples as well as a few good pointers to prevent you from getting banned.
... make a script write a line to a notecard inside the same object?
You cannot write to a notecard using a script.
... change the texture on one side of an object?
Edit the object, if it is more than one prim check Edit linked parts and choose the prim you are texturing. Click on the texture tab, click the Select Texture radio button, click on the side to texture and choose the texture to apply to it.
Through scripting, you can use llSetTexture
and specify the face of the prim.
... how do I change the texture on one face of a prim "on touch" of any avatar? I would like like to make a prim that has one texture on five sides that does not change and one face that can switch between two textures when touched.
This will change the touched faces texture, you have to replace texture with the name of the texture. You'll have to add more to make it do exactly what you want it to though.
... attach an object to an avatar who is not yet the owner of this object? Unfortunately, there seem to be no change-event fired if I give the object to the avatar. Otherwise, the object could attach itself, after it was given to its new owner. If I first rez the object, I cannot attach it, as it is not yet owned by the avatar.
You cannot attach an object that you do not own. Once you have given the object to the avatar, when they first rez it, the on_rez
event is fired and the changed
event is fired with CHANGE_OWNER
, you could use either to then attach the object to the avatar. Purchasing the object will also fire the changed
event with CHANGE_OWNER
... make my avatar's skin semi-transparent? It doesn't work with a transparent texture, because there seems to be another "skin-layer" beneath the usually visible skin. Is it generally possible?
You can't really do that, the tattoo skins you use are layered on top of the base skin, if you get a full skin and apply it you will see that most of the skin sliders in edit appearance no longer work. In fact, most tatoos you come by are mostly transparent appart from the tatoo itself, so you can't make your avatar slightly transparent.
... check to see if the owner of a script is in mouselook?
Simply use this code in the script:
... preload an animation as it is possible with llPreloadSound() for sounds? I want to synchronize the animations of several avatars, so I need to make sure that all animations are downloaded to the clients.
There is no need to preload them to synchronize them, an example of how to do this is the Dance Machine
... script one of the menus that pop up in the upper right hand corner of the client with buttons?
... trigger a touch_start event while a loop is executing?
There are two solutions:
1. Create a separate script that handles the touch_start event. That is, if the touch_start event has to do something completely unrelated to what is done in the loop or elsewhere in the loop script. If you do need to communicate with the script that's doing the loop, use llMessageLinked() in the touch script, and a link_message event in the loop script. Note that the link_message event won't be triggered until the loop has finished! If the touch_start event needs to be triggered (almost) instantly, try solution 2.
2. Use a timer event instead of a FOR-loop. Inside the timer, build in a counter that counts up every iteration, and if it reaches a certain value, the timer stops itself with llSetTimerEvent(0). If you use this solution, the touch_start event will be handled at the end of the code inside the timer event:
... make it so that an object, when rezzed, can be moved by anyone by default? I need this for a chess set....
... set the objects sale price that's in the General Tab of an Object Via a script?
counter = 1;
llSay(0, "Mary had a little lamb..."); // We do this while we're waiting for the timer event to kick in
llSay(0, "Mary had a little lamb...");
if (counter >= 10) llSetTimerEvent(0); // 10 repeats
llSay(0, "... she kept in her back yard.");
llSetTimerEvent(0); // Only add this line if you want to make the touch_start event stop the loop
not possible but you can alter the pay popup with llSetPayPrice
...retrieve data such as the total number of logged-in residents? (like displayed on the login screen)
not possible via LSL (as my knowing). If you want to see if a certain group of residents are logged-in, look at the script on the mentors page.