Jump to content

Eth3l

Resident
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Eth3l

  1. You're welcome. The "Blue menu" is called a dialog box. It's very similar to our "Listener" unit. I created a slightly modified version of the "Listener" script to give you an idea about this one. I hope this helps! integer gListenerA; integer gChannelA = -5; string gTextureName01 = "Texture name 01"; string gTextureName02 = "Texture name 02"; string gTextureName03 = "Texture name 03"; default { // touch the object and it will create a listener touch_end(integer n) { // get the UUID of the person touching this prim // we will need this when we call the dialog box key userKey = llDetectedKey(0); // set up listener gListenerA = llListen(gChannelA, "", userKey, ""); // store the dialog message & list of options string dialogMessage = "Choose color please."; list dialogOptions = ["color_01", "color_02"]; // create the dialog llDialog(userKey, dialogMessage, dialogOptions, gChannelA); } // listen at channel gChannelA (-5) listen(integer channel, string name, key id, string message) { if (message == "color_01") { string textureName = gTextureName01; integer faceId = 1; llSetTexture(textureName, faceId); } else if (message == "color_02") { string textureName = gTextureName02; integer faceId = 2; llSetTexture(textureName, faceId); } else { llOwnerSay("unknown texture name => " + message); } } } REFERENCES =========== http://wiki.secondlife.com/wiki/LlDialog http://wiki.secondlife.com/wiki/LlDetectedKey
  2. Hello there Britt32 Beck! I wrote some utility scripts for you. I hope these will set you on the right track. TASK 01: FIND FACE IDS =================== If you want to change texture on a face of an object, first you need to find out the ID of the target face. If you paste the following code to an object & click on any of the faces, the script will output the ID of the face. You will need to use this ID when you write the texture applier script. default { touch_end(integer n) { integer face = llDetectedTouchFace(0); llOwnerSay("face id => " + (string)face); } } TASK 02: SET UP LISTENERS ======================= Okay, once you find out which face ids you're targeting its time to write the script which actually receives your commands, thus the names (or ids) of the textures (you want to apply) and the faces you want to use for those textures. If your objects are not linked you need to set up "Listeners" in each object so they can receive commands from an object which sends the instructions to them. The core idea is to set up a "Listener" on a specific channel and send information from a "Sender" to that channel with special commands designed to make your object behave in a way you wish to (in this case, commands relate to the texture you want to apply). Once you receive the "message" in the "Listener" you set up conditions, to make sure things work out the way expected. If you paste the following code to an object & click on the object, it will create a listener for you & display notices. Next, if you type into your chat window: /-5 t1 You essentially say, send this message at channel -5 and say t1. t1 doesn't make a lot of sense from the first glance (because I made it up) but it represents a shorter version for texture_01. Anyway if you keep sending messages to this channel, it should display the feedback in your "debugger" window. integer gListenerA; integer gChannelA = -5; string textureName01 = "Texture name 01"; string textureName02 = "Texture name 02"; string textureName03 = "Texture name 03"; default { // touch the object and it will create a listener touch_end(integer n) { gListenerA = llListen(gChannelA, "", llGetOwner(), ""); llOwnerSay("listening at channel => " + (string)gChannelA); } // listen at channel gChannelA (-5) listen(integer channel, string name, key id, string message) { if (message == "t1") { llOwnerSay("apply texture => " + textureName01); } else if (message == "t2") { llOwnerSay("apply texture => " + textureName02); } else { llOwnerSay("unknown texture name => " + message); } } } TASK 03: TEXTURE NAMES ====================== Okay, so (hopefully) now you can detect faces ids and you have some basic understanding of how listeners may work. It's time to take a look at texturing with LSL. Luckily, it's quite simple, to apply a texture to an object you will need to know two things, the name of the texture you want to apply and the face id of the object. If you want to make this one work, you need to place the texture you want to apply to the inventory of the object, and you need to change the textureName variable to match your texture's name. default { touch_end(integer n) { string textureName = "Concrete 03"; integer faceId = 0; llSetTexture(textureName, faceId); } } TASK 04: BRINGING ALL TOGETHER ============================= So now you should know: - how to detect faces, - how to set up listeners on specific channels - how to change textures on an object All we miss is to combine everything together and create a sender object which sends the commands to your listener object. Plus we need to extend your listener to apply the textures, but that's easy. integer gListenerA; integer gChannelA = -5; string gTextureName01 = "Texture name 01"; string gTextureName02 = "Texture name 02"; string gTextureName03 = "Texture name 03"; default { // touch the object and it will create a listener, touch_end(integer n) { gListenerA = llListen(gChannelA, "", llGetOwner(), ""); llOwnerSay("listening at channel => " + (string)gChannelA); } // listen at channel gChannelA (-5) listen(integer channel, string name, key id, string message) { if (message == "t1") { string textureName = gTextureName01; integer faceId = 1; llSetTexture(textureName, faceId); } else if (message == "t2") { string textureName = gTextureName02; integer faceId = 2; llSetTexture(textureName, faceId); } else { llOwnerSay("unknown texture name => " + message); } } } STEP 01 ======= Place the face detector script to the object you want to texture. Find out the face ID you're targeting by touching the object. Write down the face ID. STEP 02 ======= Replace the face detector script with the listener script and extend it with the texture applier (llSetTexture) function. Make sure your object has the required textures in it's inventory & you properly pasted the names of each texture to the gTextureName* variables. STEP 03 ======= Create a "Sender" object which sends commands to your "Listener" or "Listeners". integer gChannelA = -5; default { touch_end(integer n) { llRegionSay(gChannelA,"t1"); } } SUM ==== And that's it basically. Of course we're just scratching the surface here, and there are many many aspects of these scripts we could (and should) improve since they're not so efficient. But my goal was to provide you with enough information to get started with some experimentation of your own. So if you're looking for further advices post your code on the forums and the community with help you out. Cheers Eth3l REFERENCES: =========== http://wiki.secondlife.com/wiki/LlSetTexture http://wiki.secondlife.com/wiki/LlListen http://wiki.secondlife.com/wiki/LlDetectedTouchFace http://wiki.secondlife.com/wiki/LlRegionSay http://wiki.secondlife.com/wiki/LlOwnerSay
  3. please add the URL your working with. or create an example url so I can test it.
  4. Hi there, I wrote some example scripts for you, so you can better monitor your memory use. I hope these examples get you closer to write more efficient code. Cheers. V1 == - displays the target function's memory use. V2 == - displays the target function's memory use & - displays max memory limit. V2 == - sets the memory limit - displays the target function's memory use & - displays the predefined memory limit. // V1 // == testFunction() { key objOwnerKey = llGetOwner(); key objTriggerKey = llDetectedKey(0); if (objOwnerKey == objTriggerKey) { llOwnerSay("owner UUID: " + (string)objOwnerKey); } } default { touch_end(integer n) { llScriptProfiler(PROFILE_SCRIPT_MEMORY); testFunction(); llScriptProfiler(PROFILE_NONE); llOwnerSay("Memory used: " + (string)llGetSPMaxMemory() + " bytes."); } } // V2 // == testFunction() { key objOwnerKey = llGetOwner(); key objTriggerKey = llDetectedKey(0); if (objOwnerKey == objTriggerKey) { llOwnerSay("owner UUID: " + (string)objOwnerKey); } } default { touch_end(integer n) { llScriptProfiler(PROFILE_SCRIPT_MEMORY); testFunction(); llScriptProfiler(PROFILE_NONE); llOwnerSay("Memory used: " + (string)llGetSPMaxMemory() + " bytes."); llOwnerSay("Memory limit: " + (string)llGetMemoryLimit() + " bytes."); } } // V3 // == testFunction() { key objOwnerKey = llGetOwner(); key objTriggerKey = llDetectedKey(0); if (objOwnerKey == objTriggerKey) { llOwnerSay("owner UUID: " + (string)objOwnerKey); } } default { touch_end(integer n) { llSetMemoryLimit(5000); llScriptProfiler(PROFILE_SCRIPT_MEMORY); testFunction(); llScriptProfiler(PROFILE_NONE); llOwnerSay("Memory used: " + (string)llGetSPMaxMemory() + " bytes."); llOwnerSay("Memory limit: " + (string)llGetMemoryLimit() + " bytes."); } }
  5. Hi there, ~{NOTE}~ ======== This script will make your object able to change it's color every 2nd sec. If you touch it once it will trigger the color-changing functionality, and if you touch it again it will reset itself. it will respond to your commands only. I hope this helps. PS: u can modify the speed of the color switching function by editing the gap variable. cheers. ~{USER GUIDE}~ ============== 1. right-click on the object. 2. edit. 3. choose the content tab. 4. click: new script. 5. open the script (called 'New Script'). 6. paste the code below. 7. save. 8. left click on the object to trigger the script. float gap = 2.0; integer counter; default { touch_end(integer n) { key objOwnerKey = llGetOwner(); key objTriggerKey = llDetectedKey(0); if (objOwnerKey == objTriggerKey) { state timer_state; } } } state timer_state { state_entry() { llSetTimerEvent(gap); } timer() { if (counter == 0) { llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES); counter = 1; } else if (counter = 1) { llSetColor(<0.067, 0.067, 0.067>, ALL_SIDES); counter = 0; } } touch_end(integer n) { key objOwnerKey = llGetOwner(); key objTriggerKey = llDetectedKey(0); if (objOwnerKey == objTriggerKey) { state default; } } state_exit() { llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES); llSetTimerEvent(0.0); counter = 0; } }
  6. Eth3l

    script

    Hi there, ~{NOTE}~ ======== This script will make your object spin if you touch it once and make it stop if you touch it again + it will respond to your commands only. I hope this helps. PS: u can modify the rotation speed by editing the speed variable. cheers. ~{USER GUIDE}~ ============== 1. right-click on the object. 2. edit. 3. choose the content tab. 4. click: new script. 5. open the script (called 'New Script'). 6. paste the code below. 7. save. 8. left click on the object to trigger the script. integer switch = 0; float speed = 3.14; default { touch_end(integer n) { key objOwnerKey = llGetOwner(); key objTriggerKey = llDetectedKey(0); if (objOwnerKey == objTriggerKey) { if (switch == 0) { llTargetOmega(llRot2Up(llGetLocalRot()), speed, 1.0); switch = 1; } else { llTargetOmega(llRot2Up(llGetLocalRot()), 0, 1.0); switch = 0; } } } }
  7. Hello there, I read this book when I started with LSL way back in 2016. It's has a lot of examples & sample projects written by professionals. Some of the examples won't work as-is. But for the most part, it perfectly delivers the core philosophy of LSL. Plus, to get good in the language, you need to practice anyway. I'd recommend reading this book if you want to get the most out of your LSL scripts. Cheers!
  8. Hello there Well if you ask me, the most important thing is to understand your scripts can cause problems if they're not written with best practices in mind. As a programmer, it is your responsibility as well to provide the best experience to SL users in your LSL programs. There are a lot of SL experts on the forums so feel free to post your source or the problematic parts you're struggling with. Community members will help you out. The authors of " Scripting Your World: The Official Guide to Second Life Scripting " mentions if you understand how channel communication works you can get very good at solving problems in LSL. It is also important to note that a huge number of lag issues caused by improperly written scripts working with channels. So that could be a good reason to go and master your skills in the topic. Once you understand how to use channels efficiently & safely you may play around with states, since for the most part, it's best to split your code into different "phases" based on certain circumstances with state control. todo: play around with channel-related functions: http://wiki.secondlife.com/wiki/Listen tinker with states, and events: http://wiki.secondlife.com/wiki/State http://wiki.secondlife.com/wiki/Touch http://wiki.secondlife.com/wiki/Timer http://wiki.secondlife.com/wiki/On_rez http://wiki.secondlife.com/wiki/Sensor Good luck!
×
×
  • Create New...