Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 05-11-2003, 09:12 AM   #1
Shinji
New Member
 
Join Date: Jul 2002
Location: Okinawa, Japan
Posts: 7
Shinji is on a distinguished road
Send a message via AIM to Shinji
While working lightly on a LPMUD(TMI-2) specifically, I thought of writing something to search for emotes, much like the apropos command will search for functions that match a string you input to it.

So you would do: emoteapropos <whatever string>, and it would take your string and search all the emotes/temotes(souls on some muds) and return any emotes with matching content.

Emotes on the mud are stored in a mapping, but I have sorts that return all the keys of the emotes in a large array and vice versa for the values of the mapping.

My problem lies in several places, I can't figure out how to search an array with the inputted string from the user to even return whether or not their search would have found any matching emote. I also am not sure how I would have it return the key(name of the emote, first value in the mapping) if the inputted string from the user matched a value or values of one of the emotes.

Anyone think they can help me with this, or have actually done it, i'd appreciate a helping hand or more.
Shinji is offline   Reply With Quote
Old 05-11-2003, 12:55 PM   #2
kaylus1
 
Posts: n/a
[ deleted duplicate post ]
  Reply With Quote
Old 05-11-2003, 12:56 PM   #3
kaylus1
 
Posts: n/a
[code] int strsrch( string str, string substr | int char, int flag );[/quote]

Strsrch  searchs for the occurence of the string 'substr' inside the string 'str'. Or of second argument is a int it will search for that CHARACTER. You can't search for an empty string or null value. -1 is returned if there is no value.

Now to what you would do. You said you have one that returns all the keys of the emotes. What are the values, I know that on TMI-2 they have multiple values for each emote targeted and untarget.    i.e. smile has a .me   .room   .modifier... or something so are the values of those an array?

like

([ "smile" : ({ "You smile $m", "$n smiles $m", "happily"}) ])

or an a mapping in a mapping:

([ "smile" : ([ ".me":"You smile $m", ".room":"$n smiles $m", "happily" ]) ])

Whatever... anyways what you would want to do is create an array from all the keys of the mapping then do something similar. We'll just do a pretend function that assumes that the mapping is one key string and an array value

-------------------------
[code]
void aprop_emote(string srch)
{
mapping emotes = ([ ]); // Set the whole emote mapping to this
string *keys, *value, buf;
int i, j;

buf = "";
//Fake function for demo purposes
emotes = "/adm/daemons/emote_d"->get_emote_map();
keys = m_indices(emotes);
i = sizeof(keys);

while(i--)
{
   value = keys[i];
   j = sizeof(value);
   while(j--)
   {
       if(stringp(value[j]) &&
           strsrch(value[j], srch))
       {
           buf = sprintf("%s* %s emote matches.\n",
               buf, keys[i]);
           break;
       }
   }
}

if(buf == "") write("No matching emotes found.\n");
else write(sprintf("Matching emotes;\n%s", buf));
return;
}
[/quote]

Please don't mind if there are parentheses missing or such, I'm writing this quickly since I only have about 3 minutes to leave =) Eek!

I think that is what you are looking for, or close enough. You might have to change the one part to accomodate for mapping values instead of array values which would be simple..

Add an extra mapping then... say named xtra!

[code]
while(i--)
{
   xtra = keys[i];
   *value = m_indices(xtra);
   j = sizeof(value);
   while(j--)
   {
       if(string_p(xtra[value[j]]) &&
           strsrch(xtra[value[j]], srch))
       {
           buf = sprintf("%s* %s emote matches.\n",
               buf, keys[i]);
           break;
       }
   }
}
[/quote]
What this should basically do is this:

aprop_emote("grin");
---
Matching emotes:
* grin
* mgrin
* sheepish
* chagrine
* evil

since "grin" could be found in those imaginary emotes.

** BE FOREWARNED I'VE CAUGHT 3 TYPOBUGS ALREADY! HEH.

I just wrote this to give you an example, obviously you know enough about LPC to correct any mistakes and to fit it into your code.

Kaylus@Solice
  Reply With Quote
Old 05-25-2003, 05:05 PM   #4
Shinji
New Member
 
Join Date: Jul 2002
Location: Okinawa, Japan
Posts: 7
Shinji is on a distinguished road
Send a message via AIM to Shinji
Well, thanks, got it to work relatively well, had to combine temote and emotes mappings as well so the search was more thorough(target emotes). Alas in the end it was decided that the thing was a usage hog, considering the large ammount of emotes that are stored.
Shinji is offline   Reply With Quote
Reply


Thread Tools


Apropos for emotes? Help! - Similar Threads
Thread Thread Starter Forum Replies Last Post
Maximum Verbosity: Emotes Nutai Roleplaying and Storytelling 15 07-21-2005 02:15 AM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 07:06 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2022