Jump to content

Credo Rolland

Resident
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Credo Rolland

  1. You can also set things up like so: if ( ~llListFindList(yourList, [incoming message]) ){do this} The reason I don't do it that way in the previous example is to avoid searching the list again in every branch of the if tree. In cases where you only need to get a list index once...it's actually more efficient than: step = llListfindList(); if (step != -1)......
  2. It seems to me like you need to simply set up an integer at the top of the listen() event that gets initialized with the current tool every time listen() is triggered. Don't forget that list indexes begin with 0. Notice in this example script at the top of the listen() event. step = llListFindList(steps, ........... list steps = ["axe","hammer","rubber chicken"]; list actions = ["chops a tree.", "drives a nail.", "laughs really hard."]; integer step = 0; integer lastStep = -1; default { on_rez(integer num) { llResetScript(); } state_entry() { llListen(0,"",NULL_KEY,""); llSay (0, "Pick a tool. Axe, hammer, or rubber chicken."); } listen(integer chan, string name, key id, string msg) { step = llListFindList(steps, [llToLower(llStringTrim(msg, STRING_TRIM))]); llOwnerSay ((string)step); string sayMe = ""; if (step > -1) { if (step == 0) { //Don't forget...lists start with an index of 0 rather than one. sayMe = ""; if (lastStep != -1) { sayMe = "/me puts down the: "+(string)llList2String(steps,lastStep)+".\n"; } sayMe += name+" picks up a battle axe and yells, \"There can be only one!\""; llSay(0, sayMe); llSay(0, name+" "+llList2String(actions, step)); lastStep = step; } else if (step == 1) { sayMe = ""; if (lastStep != -1) { sayMe = "/me puts down the: "+(string)llList2String(steps,lastStep)+".\n"; } sayMe += name+" can't seem to find the hammer but this nail gun should work!\n"+ "Ooops, it's out of nails. Those rolls from the school cafateria will do the job!"; llSay(0, sayMe); llSay(0, name+" "+llList2String(actions, step)); lastStep = step; } else if (step == 2) { sayMe = ""; if (lastStep != -1) { sayMe = "/me puts down the: "+(string)llList2String(steps,lastStep)+".\n"; } sayMe += name+" pulls out a rubber chicken."; llSay(0, sayMe); llSay(0, name+" "+llList2String(actions, step)); lastStep = step; } } } }
  3. Here's a couple examples of how I typically do this.... First, there are cases where you have no obvious delimiters or anything in the field to help you. In that case, you'll need some sort of routine to seek out some sort of index on which characters to take, and which to leave alone. ~llSubStringIndex(source string, string to match) can help you find a starting point if there is some kind of text pattern in there to look for. From there you can use llGetSubString() to pull it out. Of course there's almost always more than one way and this might not be the best, but it works for me and I typically take this approach below. The trick for me is to use some sort of delimiter character when possible. I can be some character, or spaces, or even sets/groups of characters. In this case I use a colon. 1. If possible, keep your information separated with some sort of delimiter. 2. Parse the field of text you want to work with into a list. In this case I'm getting info form the script name instead of the object name or description, but happen to have it in front of me right now so it's easy to cut and paste... I'll be grabbing info from a script named something like this: +:-:CMG:0.1:100:10:0:0:200:1:MiniGuns:GunCtrl v1.3 //Parse the script name into a list so it's easier to work with. list tank = llParseString2List(llGetScriptName(),[":"], [""]); //Grab the script number and Display Name. string str = llStringTrim(llList2String(tank, 9), STRING_TRIM); if ((string)((integer)str) == str) { bulletCounter = [(integer)str]; str = llStringTrim(llList2String(tank, 10), STRING_TRIM); bulletCounter += [str,-1]; llOwnerSay("Script Number: "+(string)llList2Integer(bulletCounter,0)); llOwnerSay("Gun(s) Display Name: "+llList2String(bulletCounter, 1)); } else { bulletCounter = [1,"Bullets",-1]; llOwnerSay("Script Name Error: Please make sure this script is named properly. Each GunCtrl Script should have a unique Number and Name. "+ "Trying a Default of: "+llList2CSV(bulletCounter)); }
  4. OK, to me, even though it might be different 'under the hood'....if something doesn't have a physics bounding box, add mass, or accept collisions, and objects can pass through it, it's in a sense 'phantom'. I'll stop stinking up the place now. One day I'll learn my lesson about forums and social media (and doubly so when using a small portable device). BTW, I just now got another dozen pop-up notifications telling me about 'new threads' and 'new replies' that are not so 'new'. It's much easier to sort out on my PC that it's ancient content than it was on my little android tablet.
  5. I just got a dozen notifications pop up on it as if it's an active question. Either way, old threads never really die as people do web searches looking for answers every day, so no biggie. If it were a problem they'd auto lock inactive threads after some amount of time. No? I'm pretty sure I found ways to do it but I can't log in to get the details right now....I'll have to log in to double check, but yes....I have mixed mesh/prim builds with phantom prim parts on it. I.E. rockets with bog standard SL cones and animated textures to simulate plazma.....the rest of the ship is bound to aa simple physics mesh but these were tacked on later...and you can fly right through the cones. I wouldn't know about an all prim build as I've not tried that, but I don't see why it would not work since all the child links give you a choice between convex hull, prim, or none.
  6. Can you set the prim in question to not have a physics shape at all? It's been a while but I seem to remember that if it's not the root prim you can set it phantom. I'm on a tablet and not logged in to check so I forget how to do it in scripts, but in the editor one can edit a link and choose between prim, convex hull, and none. I'd give that a try (set the trouble prim to none for physics shape)....and if it helps look into how to set these things from a script if you need it. Do phantom prim stil apply mass?
  7. Here's my goto method that I threw together after getting tired of typing the same cast tests along with sorting out signs and stuff over and over. It can test for signed and unsigned integers and/or floats. You get to specify what type of numbers you want it to accept or reject on the fly. It checks each character of a string to see if: 1. It can be cast into an integer that matches itself. if ((string)((integer)string) == string) 2. It checks for periods and minus signs....if it hits one it sets a bit. 3. It checks the bit to make sure we don't already have a . or - registered in the string. If so it breaks and returns 0. 4. If it comes across a string that has just a minus or period alone but no numbers, it returns 0. 5. It checks to make sure the minus sign (if present) is the first character in the string, if not it returns zero. 6. It takes the three simple bits obtained above and formats the return in a way where you can easily specify the type of number you're checking for (negative or unsigned [positive] integers and/or floats). The function returns 0 if it hits a character in the string that's not a minus, period, or 0-9, otherwise it returns one of these integers... 141, 277, 166, or 326. This makes it easy to simply check a single bit to see if your string passes your specified test. Simply copy the function below into the header of your script. From then on you can use it throughout your code in the form of isNumber(string)&bit. //Is a given 'string' representing an integer or float? //Example tests: //if (isNumber(string) & 1) to test if it's an integer of either sign. //if (isNumber(string) & 2) to test if it's a float of either sign. //if (isNumber(string) & 4) to test if it's either a float or an integer of either sign. //if (isNumber(string) & 8) to test for a positive integer. //if (isNumber(string) & 16) to test for a negative integer. //if (isNumber(string) & 32) to test for a positive float. //if (isNumber(string) & 64) to test for a negative float. //if (isNumber(string) & 128) to test for a positve integer or float. //if (isNumber(string) & 256) to test for a negative integer or float. integer isNumber(string input) { integer i = 0; integer c = 0; integer l = llStringLength(input); string s; while (c < l) { s = llGetSubString(input,c,c); if ( ( (string)((integer)s) == s ) || ( s == "-" ) || ( s == "." ) ) { //Test for possible negative integers. if (s == "-") { if (~i & 4) i = 4|i; //If it's not already tagged, flip the 3rd bit if it's a negative sign. else { i = 0; return i; } //If we come across more than one negative in the string fail. } else if (s == ".") { if (~i & 2) i = 2|i; //If it's not already tagged, flip the 2nd bit if it's a period. else { i = 0; return i; } //If we come across more than one period in the string fail. } else i = 1|i; //Flip the first bit if it otherwise passed the ((string)((integer)string) == string) test. //AFAIK, thats just 0 - 9 in lsl. ++c; } else { return 0; } } //if there's a minus sign in here somewhere, make sure it's the first character in the string. if ( (i & 4) && (llGetSubString(input,0,0) != "-") ) { i = 0; return i; } //Now take our three bits and expand them so the user can have lots of test switches avilable. if (i == 1) i = 141; //010001101 A positive integer. else if (i == 5) i = 277; //100010101 A negative integer. else if (i == 3) i = 166; //010100110 A positive float. else if (i == 7) i = 326; //101000110 A negative float. else if (i == (2|4|6)) i = 0; //just got periods and/or negative signs but no numbers....so //000 return i; }
  8. Late post here but it might help someone doing a search: Since 2005 I've found that one viewer just doesn't cut it for me. It all depends on what I'll be doing when I log in. For building I really like Phoenix and FireStorm. They have great copy/paste functions in the building editor that come in handy. They make it super easy to see link numbers in a linkset, and the list goes on. Imprudence and Dolphin 1 and 2 have many of the nifty building features as well, but don't yet do mesh that I know of. For running vehicles, playing shooters, and doing lots 'moving around' I'm torn. I want mesh, so that limits me to Phoenix (Cool Viewer does mesh, I don't see it on the TPV list anymore?) or something newer based on the V3 code as far as I know. The odd thing for me is that for Pheonix to render at its best...all maxed out, I have to step back to older ATI drivers (11.6) for my 5570 card. For the V3 stuff...I'm better with the latest ATI drivers. It's a juggling act. I have pretty dated hardware (4X AMD Phenom II and 5570 ATI on a cheap bottlenecked DDR2 MB), but even so, I can't get over how smoothly and beatifully Nirans viewer is working for me. The nice thing about this viewer is it splays out all the rendering controls and you can gradually enable/disable or otherwise adjust things until you find what agrees with your hardware. So far it's the smoothest V3 based viewer on my system. At first I had to work at it a bit to find what works best for my video card...but once I found it man is it sweet! I still run SL on some older single core XP 32 bit computers as well. I.E. an ancient Pentium M laptop with Intel Graphics. Phoenix works there, but I'm not going to be driving any VICE combat jets at 40FPS on that rig I'll assure you! More like low to medium settings and barely walking around. At the end of the day...I find I use more than one viewer. Part of it depends on what video drivers I happen to have loaded at the moment (different things I do besides SL work better if I swap drivers). Part of it depends on what I'll be doing in SL. As of June 2, 2012...My personal faves are: Phoenix or Firestorm for building. Nirans for playing the game Others out there worth looking into as well. http://wiki.secondlife.com/wiki/Third_Party_Viewer_Directory Try them all and see which one fits your hardware and your fancy As for the NVIDIA VS ATI delima. I'm stumped. Open GL is open GL right? I've had a long chain of mid-level GPUs over the years...both brands. They both rock. I often have to hen-pick the best drivers with either brand GPU. Case in point...11.6 ATI drivers do Phoenix great with my ATI 5570. The latest ATI drivers and the same app is a disaster. Oh well, happy hunting
×
×
  • Create New...