Jump to content

Sarah Glenelg

  • Content Count

  • Joined

  • Last visited

Community Reputation

4 Neutral

About Sarah Glenelg

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I got it - my string extraction was including a space so the script was looking for "SND07 " rather than "SND07". Just didn't notice the extra space in the debug message. Thanks Qie for solving this newbie error.
  2. Thank you for your suggestions. So I went to a sandbox and created simple prim with two sound files in it - SND07 and SND08. The simple script below worked fine: string soundnum; string sound; default { touch_start(integer total_number) { soundnum = "07"; sound = "SND"+soundnum; llSay(0, sound); llPlaySound(sound, 1.0); } But this slightly more complex script failed with debug error msg "Could not find sound 'SND07 '." string soundnum; string sound; string body = "CTRL SND07 This is the sound of a dog barking"; default { touch_start(integer total_number) { if (llSubStringIndex(body,"CTRL SND") != -1) { integer numIndex = llSubStringIndex(body, "SND"); string soundnum = llGetSubString(body, numIndex+3, numIndex+5); string sound= "SND"+soundnum; llSay(0,sound); llPlaySound(sound,1.0); } } } llSay(0,sound) shows 'SND07' in both cases. So it seems the issue is somehow connected to how I extract 'SND07' from the string 'body'.
  3. Hi there - I have a very simple issue that is foxing me. I have an object with some sound files in it - named SND01, SND02, SND03, etc. llPlaySound("SND01", 1.0) works fine. But if I have string sound="SND"+ soundnum (where say string soundnum="01") and then do llPlaySound(sound,1.0) I get a debug message saying "Could not find sound 'SND01'" even though SND01 is in the inventory of the object. Is it simply the case that one cannot use string variables in llPlaySound for the sound file name? Thanks
  4. Hi Ron - thanks very much for resolving this and getting the lines in the right order. All works like a treat now. You guys are great.
  5. Hello again. I have another project where I am trying to merge two scripts. I have revived an old project of mine which links an object (chatbot) in SL to an AI engine in Pandorabots after I found my original pandorabot was still active. In the SL script library I found a script for pandorabots (in 2 parts) that works fine. I have customised this script to pass some data about the avatar talking to the bot which will enhance the conversation. Currently it passes the avatar's name and location when the avatar first starts talking to the bot. You can test this by creating an object and putting in the two scripts (script1 and script2) as posted below. What I am attempting to do is to also collect the avatar's rez date. For this I have found another script in the library that can determine an avatar's age which included a RequestAgentData call and dataserver event to process the data. It would seem logical to do the dataserver process in touch_start before the call to the pandorabot but I get a syntax error whatever way I try this. I know I have this part of the script in the wrong place currently but at least it saves without any syntax errors. I have included the avatar age script as well which works perfectly fine by itself so you can see where I've pulled the age script from. Any suggestions how I can restructure my script to get this working. If you do create an object with these scripts in, then you can talk to the bot and hopefully you'll get some intelligent answers back - I'll do more work on that side of things once I've got this problem solved. After starting a conversation with the bot by touching it, typing 'testinit' (without quotes) will show the values of these initial variables so you would be able to see if any changes to the script worked. Thank you in advance for any suggestions. Script 1: // :CATEGORY:ChatBot // :NAME:Pandora_Chatbot // :AUTHOR:Destiny Niles // :CREATED:2010-01-10 05:20:56.000 // :EDITED:2013-09-18 15:38:59 // :ID:603 // :NUM:826 // :REV:1.0 // :WORLD:Second Life // :DESCRIPTION: // An ALICE base chatbot hosted at Pandorabots.com // // // Place these two scripts in an object. The first one is the listener for you to customize and control who it listens to. The second one is the actual engine itself. // :CODE: string mesg; key gOwner; list talkers; key Query; // added by SG for use with age calc integer uYr; // added by SG for use with age calc integer uMn; // added by SG for use with age calc integer uDy; // added by SG for use with age calc listen_to(key talker) { integer index = llListFindList( talkers, [talker] ); if ( index != -1 ) { talkers = llDeleteSubList(talkers, index, index); llMessageLinked(LINK_SET,0,"BYE",talker); } else { talkers = talkers + talker; string aviName = llDetectedName(0); string location = llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]) ,0); string region = llGetRegionName(); // The MessageLinked below is formatted to process the information in Pandorabots collected from SL - i.e. name and location. Trying to also include avatars rez day but this part not working yet. You can check this by saying in chat (after logging in by touching the prim containing these 2 scripts) "testinit" (without the quotes) llMessageLinked(LINK_SET,0,"CTRL1 "+aviName+". "+"CTRL2 "+(string)uYr+" "+(string)uMn+" "+(string)uDy+". " + "CTRL3 "+location+". "+"CTRL6 "+region+".",talker); } } default { state_entry() { gOwner = llGetOwner(); llListen(0,"",NULL_KEY,""); } on_rez(integer i) { llWhisper(0,"Owner say /chat or touch me"); llResetScript(); } touch_start(integer num_detected) { Query = llRequestAgentData(llDetectedKey(0),DATA_BORN); listen_to(llDetectedKey(0)); } dataserver(key QID,string Data) { if (QID == Query) { float YrDays = 365.25; float MnDays = YrDays / 12; // This is the user's birthdate. integer uYr = (integer)llGetSubString(Data,0,3); integer uMn = (integer)llGetSubString(Data,5,6); integer uDy = (integer)llGetSubString(Data,8,9); float uXVal = (uYr * YrDays) + (uMn * MnDays) + uDy; // This is today's date Data = llGetDate(); integer Yr = (integer)llGetSubString(Data,0,3); integer Mn = (integer)llGetSubString(Data,5,6); integer Dy = (integer)llGetSubString(Data,8,9); float XVal = (Yr * YrDays) + (Mn * MnDays) + Dy; // We calculate the difference between those two dates to get the number of days. integer DDiff = (integer)(XVal - uXVal); // llSay(0,"total days in SL:"+(string)DDiff); integer years = (integer)(DDiff/YrDays); // llSay(0,"years:"+(string)years); integer months = (integer)((DDiff - (years*365.25))/MnDays); // llSay(0,"months:"+(string)months); integer days = llRound((((DDiff - (years*365.25))/MnDays) - months) *MnDays); // llSay(0,"days:"+(string)days); } } listen(integer channel, string name, key id, string msg) { if (msg == "/chat") { listen_to(id); return; } if ((msg == "/reset") && (id == gOwner)) { llWhisper(0,"Resetting"); llResetScript(); } integer index = llListFindList( talkers, [id] ); if (index != -1) { mesg = llToLower(msg); llMessageLinked(LINK_SET,0,msg,id); } } } Script 2 // :CATEGORY:ChatBot // :NAME:Pandora_Chatbot // :AUTHOR:Destiny Niles // :CREATED:2010-01-10 05:20:56.000 // :EDITED:2013-09-18 15:38:59 // :ID:603 // :NUM:827 // :REV:1.0 // :WORLD:Second Life // :DESCRIPTION: // pandorabot script // :CODE: key requestid; string botid; string cust; string reply; string newreply; integer that_begin; integer that_end; integer cust_begin; list params; string SearchAndReplace(string input, string old, string new) { return llDumpList2String(llParseString2List(input, [old], []), new); } default { state_entry() { cust=""; botid="c058b3671e368866"; // this id is specific to SG's bot } on_rez(integer param) { llResetScript(); } link_message(integer sender_num, integer num, string msg, key id) { requestid = llHTTPRequest("http://www.pandorabots.com/pandora/talk-xml?botid="+botid+"&input="+llEscapeURL(msg)+"&custid="+cust,params,""); } http_response(key request_id, integer status, list metadata, string body) { if (request_id == requestid) { cust_begin=llSubStringIndex(body, "custid="); cust=llGetSubString(body, cust_begin+8, cust_begin+23); that_begin = llSubStringIndex(body, "<that>"); that_end = llSubStringIndex(body, "</that>"); reply = llGetSubString(body, that_begin + 6, that_end - 1); newreply = SearchAndReplace(reply, "%20", " "); reply = newreply; newreply = SearchAndReplace(reply,"&quot;","\""); reply = newreply; newreply = SearchAndReplace(reply,"&lt;br&gt;","\n"); reply = newreply; newreply = SearchAndReplace(reply, "&gt;", ">"); reply = newreply; newreply = SearchAndReplace(reply, "&lt;", "<"); llSay(0,newreply); } } } Avatar's age calc script key Query; default { on_rez(integer X) {llResetScript();} touch_start(integer X) { Query = llRequestAgentData(llDetectedKey(0),DATA_BORN); } dataserver(key QID,string Data) { if (QID == Query) { // The following variables are set to account for leap years and assume // the days evenly distributed amongst the 12 months of a year. float YrDays = 365.25; float MnDays = YrDays / 12; // This is the user's birthdate. integer uYr = (integer)llGetSubString(Data,0,3); integer uMn = (integer)llGetSubString(Data,5,6); integer uDy = (integer)llGetSubString(Data,8,9); float uXVal = (uYr * YrDays) + (uMn * MnDays) + uDy; // This is today's date Data = llGetDate(); integer Yr = (integer)llGetSubString(Data,0,3); integer Mn = (integer)llGetSubString(Data,5,6); integer Dy = (integer)llGetSubString(Data,8,9); float XVal = (Yr * YrDays) + (Mn * MnDays) + Dy; // We calculate the difference between those two dates to get the number of days. integer DDiff = (integer)(XVal - uXVal); llSay(0,"total days in SL:"+(string)DDiff); integer years = (integer)(DDiff/YrDays); llSay(0,"years:"+(string)years); integer months = (integer)((DDiff - (years*365.25))/MnDays); llSay(0,"months:"+(string)months); integer days = llRound((((DDiff - (years*365.25))/MnDays) - months) *MnDays); llSay(0,"days:"+(string)days); } } } Thanks
  6. Thanks Estelle, thats a good suggestion. I gave up on trying to merge the two scripts since I couldn't find a way for the script to 'sit' the avatar on the object for the teleport since clicking the dialog button wasn't the same as clicking on the object and the user had already clicked the object to bring up the dialog window.
  7. Thanks Molly for your input. In my situation, the vendors are franchised so I cant put any purchase options in my mannequins, the best I can do is to direct people to the vendor of interest. Qie, I do have a small sign at the base of the mannequin that has a teleporter in it but I noticed people click on the mannequin anyway so wanted to provide that option too. Thanks.
  8. Hi Qie - thank you for your detailed reply. As requested, I'll explain my application. I have just started a store in SL selling mainly ladies fashions. The store is on 3 levels and I probably have about 200 vendors. In the shop window I have some mannequins displaying some of the outfits. To save people time in walking around the store looking for the vendor for a particular featured outfit, I want to give them the option of teleporting to the vendor they are interested in. I have tried putting the teleporter script into the mannequin object itself which works fine but it is a bit abrupt in teleporting people when they clicked on the mannequin. So, I had the idea that when they clicked on the mannequin, a dialog box opens up, describing the outfit and its price and offering a button that will teleport them to the vendor if they clicked it - that way, the person has control over whether they want to be taken to the sales vendor or not. So I have the dialog script and the teleported script and thet is why I want to merge them together. Thanks
  9. Hi there - I can happily fiddle with scripts to adjust them to do what I need but I need some help on how to merge two scripts together. I have a dialog script that can display a button and execute a command when the button is pressed. What i would like it to do is to teleport the user to a location on the sim. I also have a simple teleport script that I would like to use here but I'm not sure how to merge the two scripts to get the desired result. Here are the two separate scripts - any suggestions welcome and thanks in advance for answering: Dialog script ------------------- integer gListener; // Identity of the listener associated with the dialog, so we can clean up when not needed default { touch_start(integer total_number) { // Kill off any outstanding listener, to avoid any chance of multiple listeners being active llListenRemove(gListener); // get the UUID of the person touching this prim key user = llDetectedKey(0); // Listen to any reply from that user only, and only on the same channel to be used by llDialog // It's best to set up the listener before issuing the dialog gListener = llListen(-99, "", user, ""); // Send a dialog to that person. We'll use a fixed negative channel number for simplicity llDialog(user, "\nFREE GIFT VENDOR IS ON TOP FLOOR", ["OK", "Cancel" ] , -99); // Start a one-minute timer, after which we will stop listening for responses llSetTimerEvent(60.0); } listen(integer chan, string name, key id, string msg) { if (msg == "OK") // [run the teleporter script] // Make the timer fire immediately, to do clean-up actions llSetTimerEvent(0.1); } timer() { // Stop listening. It's wise to do this to reduce lag llListenRemove(gListener); // Stop the timer now that its job is done llSetTimerEvent(0.0);// you can use 0 as well to save memory } } Teleporter script --------------------------- // Set your target position below (must be in same Sim): vector targetPos = <27,200,29>; //The target location in vector format <x,y,z> string floatText = ""; // change to "" if you want NO float text reset() { vector target; target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot()); llSitTarget(target, <0.0,0.0,-1.0,1.0>); llSetText(floatText,<1,1,1>,1.0); // llSetSitText("TO VENDOR"); // llSetClickAction(CLICK_ACTION_SIT); } default { state_entry() { reset(); } changed(integer change) { llSleep(0.2); //helps when SL is being laggy llUnSit(llAvatarOnSitTarget()); reset(); } }
  • Create New...