Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Custom prefix

Evan Oud
Registered User
Join date: 18 Apr 2005
Posts: 30
03-12-2006 14:54
Hey this might be a dumb question, right now I have made something that to use it you have to use a command before what you want it to do, like for example you have to type /2 bot fly the word bot is the prefix, I have this working but I am wanting to make it where the user can customize the command, insted they could do like /2 b fly or what ever they want to put. I've tried a few things with no luck. Anyone? Thanks!
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
03-12-2006 16:14
How do you want the user to customize it?

Here's what I would do:
1. Let the user say something like "/2 phrase bot foo" to change the bot phrase to foo.

The script receives "phrase bot foo" in its listen event's message parameter. The script then runs llParseString2List(message, [" "], []) on the string, resulting in a list that I'll call myList. The script runs llList2String(myList, 0), which returns "phrase". The "phrase" command would take two additional parameters, the prefix to change and what to change it to. llList2String(myList, 1) returns "bot" and llList2String(myList, 2) returns "foo".

Your script can have a global variable called gMagicPhrase, in which "bot" was previously stored. Your script compares llList2String(myList, 1) to gMagicPhrase, if they match, then it stores llList2String(myList, 2) in gMagicPhrase.
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Evan Oud
Registered User
Join date: 18 Apr 2005
Posts: 30
03-12-2006 17:24
Hey, see like that sounds like what I want. I want the user to be able to customize that. So insted of "/2 bot fly" it could "/2 foo fly" by using a command to change it, like "/2 bot prefix foo" would change it to foo. But im not entirely sure how to do this? Any example scripts?


Thanks in advanced!

Evan-
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
03-12-2006 18:06
Here is the basis of the listen handler I use, in psuedo-code. It listens for commands in the form

<itemname> <command> [<arguments>...]

CODE

gItemName="robot";

listen (string message)
{
list lWords=(List2String(message))
if lWords[0]==gItemName;
{
string command=lWords[1];
string arg1 = lWords[2];

if command=="foo" do stuff
else if command=="bar" do other stuff
}
}




Then you just need a handler to change gItemName from "robot" to whatever the user wants.

CODE

if command=="prefix"
{
gItemName=arg1;
}


Add sanity checking and whatever failsafes you like, and there you go; a voice activated object that lets you redefine the prefix it listens for.
Evan Oud
Registered User
Join date: 18 Apr 2005
Posts: 30
03-12-2006 18:40
Problem solved! Thanks everyone!