Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion Goto page Previous  1, 2
Xerakon Posted: Thu Jul 05, 2012 11:56 pm
Capturing Information To Place into Interactive Database
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sat Jul 07, 2012 6:34 pm   
 
Recentcomms:

Code:

2012/07/06 19:24:11 : Channel 0 :          Weequaydude : Inform if you wish it done.
2012/07/06 21:10:16 : Channel 0 :          Weequaydude : LYlek tentacles and krayt hides for sale.
2012/07/06 21:53:23 : Channel 0 :          Weequaydude : Lylek tentacles and Krayt hides for sale.
2012/07/07 09:40:17 : Channel 101 :                 Nova : It's ready. Mind taking delivery by drone?
2012/07/07 09:40:28 : Channel 101 :         A Human male : Hello, miss Nova.
2012/07/07 09:40:33 : Channel 101 :                 Nova : Hi
2012/07/07 09:40:45 : Channel 101 :         A Human male : Is Tinker around, by chance?
2012/07/07 09:40:50 : Channel 101 :                 Nova : Don't think so
2012/07/07 09:40:58 : Channel 101 :         A Human male : Alright. Thanks anyways.
2012/07/07 09:43:25 : Channel 101 :                 Nova : Drone out
2012/07/07 09:46:14 : Channel 101 :         A Toong male : Reverend?


Using commsfrom for nova, a human male, and a toong male, didn't output anything.

Commsfrom XML:
Code:

<alias name="commsfrom" id="386">
  <value><![CDATA[$wantedname = %params
#FORALL @messagelog {
  #IF (%i.name = $wantedname) {#SHOW %format("&s : Channel &s : &20s : &s", %i.time, %i.channel, %i.name, %i.message)}
  }]]></value>
</alias>
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Jul 08, 2012 3:25 am   
 
Looks like a case issue - there are no posts from nova, only Nova. Just change your condition to (%upper(%i.name) = %upper($wantedname)). Converting them both to uppercase removes any case sensitivity.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 10:18 am   
 
Hey guys,

Bringing this one back to see if it can help me with my current project.

For the SWR that I'm on, we have several ways of communication.

Code:

([Galactic Empire]){Imperial Army}<Sergeant>[Demeter]: On-comms.
CommNet 1598 [A being in modified black scouttrooper armor]: Check
Bob says 'Do your job.'


What I'm looking to do, is wrap all of these up into a database. Needs to have the following:

- Each entry is sorted into the person's name or identifier.
- Entries are then sorted by time/date.
- After a name or identifier has a record/database, a clickable link will appear on their name to bring up everything I have recorded from them in the past, into a different window.

These are the basics. I'm not sure if this is something that should be consolidated into one database, or if a different database should be generated for each person, but I feel like it should be pretty easy to use the script already worked on in this topic, then find a way to add the linking function.

Thanks!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jul 31, 2012 1:51 pm   
 
The database itself does not need to be sorted, just the output. This should be easy enough to do in a single database. In fact, the database you have already set up and the 'commsfrom' alias is almost everything that you need for this. The 'commsfrom' alias already displays the messages in time order. The only things that may be missing are the triggers to put the other formats of comms into the database, and the trigger to insert the MXP for the clickable link. Do you need help with the other triggers to put comms into the database? It will probably be easiest to write a separate trigger for each style of comms output, but the code should be similar to the trigger you already have.

You need a trigger to capture and modify the line that you want to insert the clickable link in. I'm not sure what lines you want the link to show up in, so I will assume for now that it will be lines like "Bob says 'blah'". This will make it easy, because it guarantees that the name has at least one entry in the database (the message this is triggering on Smile ) I will assume the name of the window you want the output in is named Comms. The trigger should look something like this (untested!):
Code:

#TRIGGER {(*) (says '*')} {
  #SUB {%concat("<send '#EXECWIN Comms {commsfrom ", %1, "}'>", %1, "</send> ", %2)}
}

Make sure this trigger has a higher priority number (i.e. runs after) the trigger which captures the message into the database, so that the new message is included in the output. The commsfrom alias and the @messagelog variable may need to be moved to a new module outside of your main window so that the Comms window can see them.

If you want the clickable link to appear in places other than the comms messages, it will be slightly trickier, because you will have to test whether the name has any comms. You will have to describe the lines where you want the clickable link to appear.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 3:41 pm   
 
Hey Rahab, thanks for the quick response! Pretty much anywhere I see the name would be good, as I'd like to be able to click on their name if someone mentions them and bring up what that person has said. Going to start to work on this and see how far I get without bugging ya'll. =)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jul 31, 2012 4:21 pm   
 
To get get the clickable link everywhere the name appears in mud text, you will need a stringlist of the names in the comms database. Add this line to all triggers which are adding comms to @messagelog:
Code:
#ADDITEM lognames $name

Modify that appropriately if the name is in some variable other than $name.

The following trigger should then replace all instances of one of the names with the appropriate MXP code:
Code:

#TRIGGER {({%q|%s})({@lognames})({%q|%s})} {
  #SUB {%concat(%1, "<send '#EXECWIN Comms {commsfrom ", %2, "}'>", %2, "</send> ", %3)}
}

You should also make this trigger Repeat Within Line, so that if Bob and Bubba both appear in the same line, they will both be substituted. I would have included that in the code above, but I can't recall the exact name of that option in the command line form of #TRIGGER. I think there is also be a better option for specifying a word break other than {%q|%s}, but I can't remember it and can't find it in the documentation. The reason I put that in there is so that the trigger won't match "Bob" to something like "Bobbing along".
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 4:45 pm   
 
Ah, gotcha. Thank you!

Having a bit of an issue sorting this out.. I think I'm using too many ~'s. Can you help me sort out this symbol jumble?

Code:

([Galactic Empire]){The New Order}<Executor>[A hooded figure in crimson and black robes]( deeply ): Very well.

~(~[~(*)~]~)~{~(*)~}~<~(*)~>~[~(*)~]( (*) ): (*)


I need to get to only the words inside the various symbols so that it'll fill the variables correctly.

Thanks!
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 5:25 pm   
 
NVM, Got it.

Code:

~(~[(*)~]~)~{(*)~}~<(*)~>~[(*)~]~( (*) ~): (*)


See, progress. =)
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Jul 31, 2012 5:32 pm   
 
You can just use %q for a word boundary, it's equivalent to \b in regex.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 6:55 pm   
 
Ah, thanks Daern.

Okay, I've got the majority of it figured out. Having issues capturing say triggers, however, as there are so many variations possible.

Code:

Zarkonian crisply says 'I need to rest. Excuse me.'
Kdywook says, in an unfamiliar dialect 'Hwg xqk xsibvlq, Z viv un numfx xpa.'
A masked being encased in black and silver armor coarsely says 'Likely.'
A masked being in drab robes says 'I wonder if it was Skye.'


As you can see, there are several variations:
1-word name, tone, message
1-word name, no tone, message
1-word name, language, message,
many-words name, no tone, message
etc.

Is there an easy way to sort all of this out, or is it better to just forget this method of communication?
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 7:37 pm   
 
Code:

#TRIGGER {({%q|%s})({@lognames})({%q|%s})} {
  #SUB {%concat(%1, "<send '#EXECWIN Comms {commsfrom ", %2, "}'>", %2, "</send> ", %3)}
}

This crashed CMUD. Not sure what the issue was, but the screen simply froze and went non-responsive.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jul 31, 2012 8:06 pm   
 
Oh, darn, I think the problem with the trigger is that it is putting it into a loop. I'll think about that some more.

Is there a specific list of adverbs that can be used in the says, besides 'coarsely', or can people use any adverb phrase they want? Do the adverbs always end in 'ly'? If people can add any adverb phrase they want and they don't have any identifying features (like all ending in 'ly'), it will be difficult to separate the charactar name/description from the adverbs. Other than the adverbs, it is actually fairly straightforward.

Another alternative for capturing says would be to only capture those whose names are already in the database. You could add new names into @lognames to ensure that you start capturing their says messages. The pattern for this would be:
Code:
^({@lognames})%q*%qsays%q*'(*)'

Unfortunately, if "A masked being" ends up in @lognames, then this would count "A masked being encased in black and silver armor" and "A masked being in drab robes" as "A masked being". Again, we have the problem of automatically separating the adverbs from the name. If there is no way to identify the adverbs, it may not be practical to capture says.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jul 31, 2012 8:09 pm   
 
On second thought, it might be practical if you deliberately eliminate messages from "A masked being" and other unidentifiable figures.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue Jul 31, 2012 8:19 pm   
 
Code:

You say 'hi'
'hi' you say.
You happily say 'hi'
'hi' you happily say.
You happily say, in Weequay 'hi'
'hi' you happily say, in Weequay.


These are the main ways that things are said. It can also change to ask or exclaim with question marks or periods.

There are like 297 tones to choose from, and while the majority of them end in -ly, not all of them do. If it comes down to it, I'd hedge it down by adding the -ly and allowing a few past, cause almost no one uses the non -ly's.

After speaking to another cmud user here, he said he uses something like with MUSHclient, I think, and that it should be about the same for CMUD. Whatcha think?

Code:

^(.*)(say|ask|exclaim)(.*)\'(.*)\'(.*)$

and

^\'(.*)\'(.*)(say|ask|exclaim)(.*)$
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Aug 01, 2012 2:28 am   
 
Those are regular expressions. They should work if you set the Triggers to be regular expression triggers.

In fact if you actually have a list of the tones, then you can do it perfectly, without including the tones in the names. Just put all of the tones into a stringlist variable named @tones. Here is a pair of zscript patterns that I think should match all of the say variations you list:
Code:


^(.*)\s?(@tones|)\s(say|ask|exclaim)(.*)\'(.*)\'(.*)$
^\'(.*)\' (.*)\s?({@tones|)\s(say|ask|exclaim)(.*)$
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Wed Aug 01, 2012 2:02 pm   
 
Code:

tone list
Complete list of speaking tones:

1.   abashed       2.   abrupt        3.   absent minded 4.   accusing     
5.   aggravated    6.   aggressive    7.   amused        8.   angry         
9.   annoyed       10.  annoying      11.  anxious       12.  apologetic   
13.  appreciative  14.  approving     15.  argumentative 16.  arrogant     
17.  ashamed       18.  audacious     19.  awed          20.  awkward       
21.  bashful       22.  belligerent   23.  bickering     24.  bitter       
25.  blunt         26.  bored         27.  boyish        28.  brash         
29.  brave         30.  breathless    31.  bold          32.  brisk         
33.  broken        34.  calm          35.  careful       36.  casual       
37.  caustic       38.  cautious      39.  cheerful      40.  clear         
41.  clever        42.  coarse        43.  cold          44.  commanding   
45.  competitive   46.  concerned     47.  condescending 48.  confident     
49.  confused      50.  cordial       51.  coughing      52.  courageous   
53.  coy           54.  curious       55.  cursing       56.  curt         
57.  craven        58.  crisp         59.  cruel         60.  cryptic       
61.  cynical       62.  dark          63.  dazed         64.  deep         
65.  defensive     66.  defiant       67.  dejected      68.  demure       
69.  dim           70.  disappointed  71.  disapproving  72.  disenchanted 
73.  disgusted     74.  dismissive    75.  disrespectful 76.  distracted   
77.  distant       78.  dizzy         79.  dominant      80.  domineering   
81.  dreamy        82.  droning       83.  drunken       84.  dry           
85.  dubious       86.  dull          87.  embarrassed   88.  emphatic     
89.  encouraging   90.  enraged       91.  envious       92.  exasperated   
93.  excited       94.  expectant     95.  exuberant     96.  faint         
97.  fearful       98.  firm          99.  flat          100. flirtatious   
101. foolish       102. forlorn       103. frank         104. fretful       
105. frustrated    106. fuming        107. furious       108. gasping       
109. gent          110. girlish       111. gleeful       112. glum         
113. gruff         114. grand         115. grateful      116. grave         
117. greedy        118. grim          119. growling      120. grumpy       
121. grunting      122. guttural      123. happy         124. halting       
125. harsh         126. haughty       127. heartless     128. heroical     
129. hesitant      130. hissing       131. hopeful       132. humourous     
133. hurried       134. hushed        135. hyper         136. impatient     
137. incoherent    138. incredulous   139. indistinctive 140. innocent     
141. inquisitive   142. insistent     143. insolent      144. irritated     
145. jealous       146. jitter        147. joking        148. jubilant     
149. knowing       150. laconic       151. laughing      152. lazy         
153. lewd          154. light         155. lithe         156. livid         
157. loud          158. loving        159. lustful       160. mad           
161. majestic      162. maniacal      163. mechanical    164. meek         
165. melodical     166. menacing      167. merry         168. messy         
169. mindless      170. mischievous   171. miserable     172. mocking       
173. monotonous    174. moody         175. mournful      176. muted         
177. mysterious    178. nasal         179. negative      180. nervous       
181. nonchalant    182. obnoxious     183. obscured      184. obstinate     
185. ominous       186. passionate    187. passive       188. pathetic     
189. patient       190. pausing       191. peaceful      192. pedantic     
193. persistent    194. pious         195. placid        196. playful       
197. pointed       198. polite        199. pompous       200. posh         
201. positive      202. preeminent    203. proud         204. psychotic     
205. questioning   206. quick         207. quiet         208. rabid         
209. reckless      210. regretful     211. remorseful    212. resentful     
213. resigned      214. respectful    215. rude          216. sad           
217. sarcastic     218. scared        219. scoffing      220. scornful     
221. seductive     222. serene        223. serious       224. sexy         
225. shamed        226. sharp         227. sheepish      228. shrewd       
229. shy           230. sighing       231. sinister      232. skeptical     
233. sleazy        234. sleepy        235. slick         236. slimy         
237. slow          238. sly           239. smooth        240. smug         
241. snarky        242. snide         243. sniping       244. snotty       
245. sobbing       246. soft          247. solemn        248. somber       
249. soothing      250. sorrowful     251. sour          252. spineless     
253. spiteful      254. squeaky       255. stubborn      256. submissive   
257. suggestive    258. surprised     259. suspicious    260. staggering   
261. stammering    262. stern         263. stupid        264. stuttering   
265. suave         266. sudden        267. sweet         268. sympathetic   
269. tactful       270. tearful       271. teasing       272. tender       
273. tentative     274. tepid         275. terse         276. thick         
277. thin          278. thoughtful    279. threatening   280. timid         
281. tired         282. triumphant    283. undecipherable 284. understanding
285. uneasy        286. unhappy       287. vacant        288. warm         
289. wary          290. weak          291. weary         292. wheezing     
293. whining       294. wise          295. wistful       296. worried       
297. wry           


Is there a trigger that can pull these from the mud and input them into the variable in the event that more are added or changed?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Aug 01, 2012 4:24 pm   
 
Yes, there is a way to grab that by a trigger. Unfortunately that list gives the adjectival forms of the words. It looks like if you set the tone to "happy", the say will come out "happily". So simply grabbing the list won't be enough--you need to change those forms into the adverbial form. It might be possible to automate this conversion, as well, except for a few odd cases.

The trigger would need to be a regular expression trigger. The pattern would be:
Code:
^\d\. (.*)(\s+\d\. (.*)(\s+\d\. (.*)(\s+\d\. (.*))?)?)?

I believe the relevant words would be captured in %1, %3, %5, and %7. You would have to test each one to see whether the string is %null before adding it to the database, because those last three values are optional (because the last line may not have them all).

This trigger could go into a class (let's name it toneclass) which is normally disabled. Set up another trigger with a pattern of
Code:
Complete list of speaking tones:
which enables the class and sets @tones to "", getting it ready for the capture trigger. In addition, inside the class, create another trigger which has a pattern matching your prompt; this trigger should do the translation of all the words in @tones into adverb forms, and then disable the class.

The algorithm for translating the adjective into an adverb is:
IF word ends in "y" AND is more than 3 letters long AND the second-to-last letter is not a vowel THEN change the "y" to "ily"
ELSE IF word ends in "le" THEN change "le" to "ly"
ELSE IF word ends in "ll" THEN add "y"
ELSE IF word ends in "ic" THEN add "ally"
ELSE add "ly"

I'm afraid I don't have time right now to convert this into zscript.

[edit]Technically, that first line should read "AND has more than one syllable" instead of "AND is more than 3 letters long". Unfortunately, there is no easy way to detect multiple syllables. "more than 3 letters long" will work for everything except a few oddballs like "spry". I suppose you might be able to detect multiple syllables by whether there are any vowels before the second-to-last letter.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Wed Aug 01, 2012 5:15 pm   
 
Before you posted, I did some screwing around and came up with this:

Code:

^(%d)~.(%s)(%w)(%s)(%d)~.(%s)(%w)(%s)(%d)~.(%s)(%w)(%s)(%d)~.(%s)(%w)(%s)


Yours looks more optimized. What do the question marks at the end represent?
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Wed Aug 01, 2012 6:01 pm   
 
Also, I don't have the slightest clue how to work on that conversion, other than the capitalized letters.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Aug 01, 2012 8:11 pm   
 
The question marks mean "zero or one of the thing immediately preceding". In each case, the thing immediately preceding is contained in a set of parentheses. Basically, by putting in the question marks, it means that the second, third, and fourth number/word pair are optional and might not appear. [edit]Note that this was a regular expression trigger pattern, so the trigger would have to be marked as a regular expression trigger. There isn't any good way to do the equivalent for a zscript pattern in this case.[/edit]

I'll try to remember to give some code for the adj/adv conversion when I get home.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Aug 02, 2012 12:47 am   
 
Okay, let's see. Here is a snippet of code to convert an adjective, $adj, into an adverb, $adv. I have actually tested it, and it even works on spry. Very Happy
Code:

#SWITCH (%ends($adj, "le")) {$adv = %concat(%leftback($adj, 2), "ly")}
  (%ends($adj, "ll")) {$adv = %concat($adj, "y")}
  (%ends($adj, "ic")) {$adv = %concat($adj, "ally")}
  (%ends($adj,"y") AND !%match($adj, "*{a|e|i|o|u}y$") AND %match($adj, "*{a|e|i|o|u}*")) {$adv = %concat(%leftback($adj, 1), "ily")}
  {$adv = %concat($adj, "ly")}



Be sure to put a blank line after the last line of this code (#SWITCH is finicky about formatting, unfortunately).
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Thu Aug 02, 2012 6:14 am   
 
I'm getting the fired but did not compile error.

Code:

#SWITCH @//LotjShared/Comms/tones (%ends($adj, "le")) {$adv = %concat(%leftback($adj, 2), "ly")}
  (%ends($adj, "ll")) {$adv = %concat($adj, "y")}
  (%ends($adj, "ic")) {$adv = %concat($adj, "ally")}
  (%ends($adj,"y") AND !%match($adj, "*{a|e|i|o|u}y$") AND %match($adj, "*{a|e|i|o|u}*")) {$adv = %concat(%leftback($adj, 1), "ily")}
  {$adv = %concat($adj, "ly")}
 
#T- TonesClass


Only thing I changed was to add in the variable after the switch command.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Aug 02, 2012 2:09 pm   
 
The snippet I gave works on a single word at a time, held in the variable $adj, and puts the single resulting adverb into $adv. The @tones variable is an entire list of adjectives. You need to loop through the adjectives one at a time, put each one through my conversion code, store all the resulting adverbs, and at the end stuff all the adverbs back into @tones. One way of doing the loop would be:
Code:

$adverbs = ""
#FORALL @//LotjShared/Comms/tones {
  $adj = %i
  $adv = ""
  // INSERT MY CODE HERE FOLLOWED BY A BLANK LINE

  #ADDITEM $adverbs $adv
}
#VAR //LotjShared/Comms/tones $adverbs

Is there a specific reason you are using a full path to the @tones variable?
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Thu Aug 02, 2012 9:54 pm   
 
Code:

$adverbs = ""
#FORALL @//LotjShared/Comms/tones {
  $adj = %i
  $adv = ""
#SWITCH @//LotjShared/Comms/tones (%ends($adj, "le")) {$adv = %concat(%leftback($adj, 2), "ly")}
  (%ends($adj, "ll")) {$adv = %concat($adj, "y")}
  (%ends($adj, "ic")) {$adv = %concat($adj, "ally")}
  (%ends($adj,"y") AND !%match($adj, "*{a|e|i|o|u}y$") AND %match($adj, "*{a|e|i|o|u}*")) {$adv = %concat(%leftback($adj, 1), "ily")}
  {$adv = %concat($adj, "ly")}
 
#T- TonesClass

  #ADDITEM $adverbs $adv
}
#VAR //LotjShared/Comms/tones $adverbs


Ensured that there was a space in there. The trigger fires and compiles now, but isn't correct. I'm getting such as...

uneasy becomes uneasyly
undecipherable becomes undercipherablely

Not sure why.

And I use the full path because I thought that's what's needed to go from each window to a module?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Aug 03, 2012 1:54 am   
 
You didn't take @//LotjShared/Comms/tones out of the #SWITCH command.

No, you don't need to specify a full path to get to a variable in a shared module. A simple @tones will usually suffice if you have only one variable with that name.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net