llDeleteSubString and prefix
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
07-28-2008 11:52
ok need a bit of help I have this trying to do it with a prefix of jy "auto by av's 1st and last name" works well on the default prefix but when you use jy its not working right. Now here is the kicker lol how would one work in a way to delete the prefix as well? if(cmd == "owner"  { targetName = llDeleteSubString(message,0,6); llSensor(targetName, NULL_KEY, AGENT, sensor_radius, PI); }
|
|
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
|
07-28-2008 13:34
where is the prefix even mentioned in the code? If you would poste full script it would be more of a help.
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-28-2008 13:39
I'm not quite sure what you're hoping the function will return. But the 0 and 6 are inclusive, so string test = "0123456789";
llSay(0, llDeleteSubString(test, 0,6)); will return 789. Hope this helps.
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
more of the code lol
07-28-2008 14:20
Not posting the full script lol but string prefix = "."; Command(string message, key id) { if(llGetSubString(message, 0, llStringLength(prefix) - 1) == prefix || llGetSubString(message, 0, 0) == "*"  ***** Hiden Area For My Eyes Only ******* if(id == llGetOwner()) { if(cmd == "owner"  { targetName = llDeleteSubString(message,0,6); llSensor(targetName, NULL_KEY, AGENT, sensor_radius, PI); } else { some thing } }
|
|
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
|
07-28-2008 14:49
lol i dont get it what is this script supposed to do. Do u want to get rid of the prefix and only get the avatar name or do u wanna use first letters of avatars name and surname for prefix like u mentioned in first pos or somthing. Define more accuratly pls.
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
oppps sorry
07-28-2008 15:04
yes I'm trying to find out I would remove not only the command message but what ever the prefix is set to. Being once they change from . to jy
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-28-2008 16:25
Let me try to get this straight in my mind.
My Amethyst collar has a default prefix of . -- that is, if I reset it, then it responds, for example, to a chat command of .nadu by putting me in the nadu position.
However, the normal practice is to change your prefix to your initials, so my collar might be expected to respond to iznadu. However, since that would confuse domestic arrangements and scripted devices no end in our household, it in fact responds to innanadu (and I think I could use 5 letters for my prefix if I wanted).
Are you trying to cover something like this? You want to strip out the first however many letters it is of a chat command (the prefix) so you are left with the command (nadu or tower or whatever), and you don't know beforehand how long the prefix is?
If so, I think I would do it this way:
string prefix; string mycommand; string message;
integer end = llStringLength(prefix)-1;
mycommand = llDeleteSubString(message, 0, end);
|
|
Jenn Yoshikawa
Registered User
Join date: 14 Nov 2007
Posts: 91
|
tytytytytytytyty
07-28-2008 16:49
Thank you so much hehe  )
|
|
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
|
07-28-2008 22:38
Aha now i understand  . You can use llSubStringIndex to index command or u can kinnda use the algorithm of prefix command to acctualy eliminate it from final text. but i thing first one will be better for using. And dont forget to make lsl only check first word of chat cuz someone might just call someones name or say a specific command.
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
07-29-2008 03:50
From: Urrong Urnst Aha now i understand  . You can use llSubStringIndex to index command or u can kinnda use the algorithm of prefix command to acctualy eliminate it from final text. but i thing first one will be better for using. And dont forget to make lsl only check first word of chat cuz someone might just call someones name or say a specific command. Well, since now we know that this script's supposed to be, let's try to work out what it needs to do. If someone says something, my collar needs to check, at a minimum and not necessarily in this order, i)is this someone to whom we listen; are they talking to me; and what are they telling me to do? "is this someone to whom we listen?" is easy enough -- just look at a lockable door script if you don't know how to do it. "Are they talking to me?" is where the prefix comes in. "What do they want me to do, and do I know what they're talking about?" Well, I would imagine we've got prolly two sorts of commands to check -- one that will have to be hard-coded in the script (something to let me out of whatever position I'm in, something to give a notecard, and so on) and one to trigger an animation. That could be hard coded, but I'd do it by looking in the collar's inventory and using the names of the anims there to build a command list. Now, I suspect from what Jenn's said earlier in this thread, that this collar will let my dominant make me do things to third parties, like give them a kiss. So, someone we listen to says, "izkiss Urrong Urnst" we need to look at the first string and check, are the first few characters my prefix? Are the characters between that and the first space a command I understand? If they are, and it's something that potentially involves a third party ( like a kiss), is there anything after izkiss? If not, he wants me to give him a kiss. If there are, who does he want me to kiss, and will they give me permission to animate them (we assume that if he wants me to kiss him, he's given permission to animate him too)? In either case, where is person I'm supposed to be kissing, so I can go over to them before I trigger the kiss anim?
|