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
Amatsuka
Newbie


Joined: 02 Oct 2010
Posts: 2

PostPosted: Sat Oct 02, 2010 8:07 am   

Trying to write an alias that will change the perspective of a sentence.
 
So, what I'm attempting to do is have an alias wherein I can type out something in first person which will then be turned into three, at least crude, but grammatically correct sentences. One is to be shown to the target of the action, one to myself, and one to whoever else is observing as a third party. I have it more or less progressing well except for the small matter of verbs. Specifically, short of making a huge list of verbs to check for (super impractical and tedious), I don't know how to identify them so I can append 's' or 'es' to the end.

For example: I tumble backwards, startled and soon sprawled across the floor. Looking up, I laugh back at him and begin to pick myself up.

This should come out something like:

  • What you will see: You tumble backwards, startled and soon sprawled across the floor. Looking up, you laugh back at him, and begin to pick yourself up.
  • What your target will see: Player1 tumbles backwards, startled and soon sprawled across the floor. Looking up, Player1 laughs back at you and begins to pick herself up.
  • What bystanders will see: Player1 tumbles backwards, startled and soon sprawled across the floor Looking up, Player1 laughs back at Player2 and begins to pick herself up.


Obviously since I haven't figured it out yet, it's coming out like, "Player1 tumble backwards, startled and soon sprawled across the floor. Looking up, Player1 laugh back at you and begin to pick herself up." Any help would be appreciated. Thank you.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Oct 02, 2010 4:15 pm   
 
The only way I can see this being accomplished is a list, unfortunately. I mean, you could do something which would mark or identify a verb in the sentence for changing, but there are still words which are exceptions that you'll have to worry over.

In any case, you can change the alias to parse your input for a key symbol, something you wouldn't normally type in it, in order to identify something which needs to be changed across perspectives. I'd use an asterisk * for normal S verbs and maybe a ^ for ES verbs. Attach the * or ^ directly to the verb, and then add the following to your alias:

Code:

$params=%replace( %params, " ", "|")
#LOCAL $phrase
#FORALL $params {#IF (!%iskey( $phrase, %i)) {#SWITCH (%left( %i, 1)="*") {#ADDKEY $phrase %right( %i, 1) 1}
   (%left( %i, 1)="^") {#ADDKEY $phrase %right( %i, 1) 2}
   {#ADDKEY $phrase %i 0}}}


This should work with the rest of your script now, except that you can use an #IF statement to determine if the value of your word is 0 (no change), 1 (add an s for certain perspectives) or 2 (add an es for certain perspectives). Let me know if you need help integrating this idea further.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Oct 04, 2010 1:24 pm   
 
I'm afraid I don't see how you, as a player, can change what your target and bystanders see. I assume this is an emote. Unless your mud has built-in code to handle perspectives, you cannot send one emote message to your target and a different one to bystanders. Are you instead trying to change what _you_ see, depending on whether you are the actor, target, or bystander of a particular emote message?

As Chamenas said, this is not an easy problem. Figuring out which words are verbs, which are subjects, and which are direct or indirect objects is complicated. In the general case, it requires a full-fledged lexer. Even to support this on the server end requires quite a bit of code, even for straight commands when they already know what the verb, the actor, and the target are. Server-side support for perspective within emotes is usually done by having users encode markup within their emote commands to identify the target and/or the verb. Parsing the full range of possible emotes on the client side will be very difficult, if the server is not already supporting it.
Reply with quote
Amatsuka
Newbie


Joined: 02 Oct 2010
Posts: 2

PostPosted: Wed Oct 06, 2010 1:24 am   
 
I'm sorry for not explaining myself fully, but thank you for the help so far. Essentially the mud does have support and this alias would be meant to interact with commands already in place to design what is essentially an emote, but which has code behind it for damage and effects. Normally you would set up each perspective yourself using different variables for a target's pronouns and name or yours. Using my previous example, it'd look something like:

%n tumbles backwards, startled and soon sprawled across the floor. Looking up, %e laughs back at %N, and begins to pick %sself up.

The problem with this is that it's time consuming and doesn't allow for much spontaneity. My idea was to do something from the client side that could be used to make setting one up almost as natural as emoting. I chose to do it in first person and with male pronouns so that there is less ambiguity when converting the string.

The way I imagine it might work (as I've thought about it a little more since my original post) is if I list clues as to a way which the alias might identify a verb in a first person phrase. So, 'I' for example will typically be followed by a verb that will need to be modified. Depending on how it's conjugated, it won't need to be and, at the moment, I only foresee problems with verbs which need 's' and 'es' added to the end. If I can find them, I think it'll be entirely possible.

I'm still having a little trouble with periods, so ignore that, but maybe posting what I've finished will help:

Code:
//Syntax: social <stat> <type> <first person string>
//Setting up variables
$PeriodInLimbo=0
$WordCount=0
$AttackStat=%1
$AttackType=%2
$AttackString=%-3
$ModAttackString=$AttackString
$TotalWords=%numwords($Attackstring)
$AttackerPerspective=""
$TargetPerspective=""
$BystanderPerspective=""

//Setting up social attack stat and type
custom social set 0 stat $AttackStat
custom social set 0 type $AttackType

//Interperating attack string
#While ($WordCount<=$TotalWords) {

  //Searching for troublesome periods to remove from string for intepertation.  ModAttackString is so AttackString isn't tainted when periods are removed.  That's important in the case of multiple periods in a string.
  #if "."=%rightback(%word($AttackString,$Totalwords-$WordCount),1) {
    $ModAttackString=%replace(AttackString,".","")
    $PeriodInLimbo=1
  } {$ModAttackString=$AttackString}
  #if $Wordcount>0&&$Wordcount<$TotalWords {
    $AttackerPerspective=%insert(" ",$AttackerPerspective,end)
    $TargetPerspective=%insert(" ",$TargetPerspective,end)
    $BystanderPerspective=%insert(" ",$BystanderPerspective,end)}

  //This part is taking a word from the original string, checking to see if it matches whatever the section is looking for (this one is looking for the word "I")
  #switch ("I"=%word($ModAttackString,$Totalwords-$WordCount)) {

      //This is where I'm summoning the periods back before they're lost forever
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }

      //This builds up the perspectives, one word at a time, if the keyword is found ("I").
      $AttackerPerspective=%insert("you",$AttackerPerspective,end)
      $TargetPerspective=%insert("$n",$TargetPerspective,end)
      $BystanderPerspective=%insert("$n",$BystanderPerspective,end)}
    ("My"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("your",$AttackerPerspective,end)
      $TargetPerspective=%insert("$s",$TargetPerspective,end)
      $BystanderPerspective=%insert("$n's",$BystanderPerspective,end)}
    ("my"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("your",$AttackerPerspective,end)
      $TargetPerspective=%insert("$s",$TargetPerspective,end)
      $BystanderPerspective=%insert("$s",$BystanderPerspective,end)}
    ("Me"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("you",$AttackerPerspective,end)
      $TargetPerspective=%insert("$n",$TargetPerspective,end)
      $BystanderPerspective=%insert("$n",$BystanderPerspective,end)}
    ("me"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("you",$AttackerPerspective,end)
      $TargetPerspective=%insert("$n",$TargetPerspective,end)
      $BystanderPerspective=%insert("$m",$BystanderPerspective,end)}
    ("Mine"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("yours",$AttackerPerspective,end)
      $TargetPerspective=%insert("$s",$TargetPerspective,end)
      $BystanderPerspective=%insert("$n's",$BystanderPerspective,end)}
    ("mine"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("yours",$AttackerPerspective,end)
      $TargetPerspective=%insert("$s",$TargetPerspective,end)
      $BystanderPerspective=%insert("$s",$BystanderPerspective,end)}
    ("He"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$E",$AttackerPerspective,end)
      $TargetPerspective=%insert("you",$TargetPerspective,end)
      $BystanderPerspective=%insert("$N",$BystanderPerspective,end)}
    ("he"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$E",$AttackerPerspective,end)
      $TargetPerspective=%insert("you",$TargetPerspective,end)
      $BystanderPerspective=%insert("$E",$BystanderPerspective,end)}
    ("His"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$S",$AttackerPerspective,end)
      $TargetPerspective=%insert("your",$TargetPerspective,end)
      $BystanderPerspective=%insert("$N's",$BystanderPerspective,end)}
    ("his"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$S",$AttackerPerspective,end)
      $TargetPerspective=%insert("your",$TargetPerspective,end)
      $BystanderPerspective=%insert("$S",$BystanderPerspective,end)}
    ("Him"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$M",$AttackerPerspective,end)
      $TargetPerspective=%insert("you",$TargetPerspective,end)
      $BystanderPerspective=%insert("$N",$BystanderPerspective,end)}
    ("him"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$M",$AttackerPerspective,end)
      $TargetPerspective=%insert("you",$TargetPerspective,end)
      $BystanderPerspective=%insert("$M",$BystanderPerspective,end)}
    ("Himself"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$Mself",$AttackerPerspective,end)
      $TargetPerspective=%insert("yourself",$TargetPerspective,end)
      $BystanderPerspective=%insert("$Mself",$BystanderPerspective,end)}
    ("himself"=%word($ModAttackString,$Totalwords-$WordCount)) {
      #if $PeriodInLimbo=1 {
        $AttackerPerspective=%insert(".",$AttackerPerspective,end)
        $TargetPerspective=%insert(".",$TargetPerspective,end)
        $BystanderPerspective=%insert(".",$BystanderPerspective,end)
        $PeriodInLimbo=0 }
      $AttackerPerspective=%insert("$Mself",$AttackerPerspective,end)
      $TargetPerspective=%insert("yourself",$TargetPerspective,end)
      $BystanderPerspective=%insert("$Mself",$BystanderPerspective,end)

  //This next part is adding words that don't match any of the keywords the script is looking for without modification.
      }
  {$AttackerPerspective=%insert(%word($AttackString,$Totalwords-$WordCount),$AttackerPerspective,end)
  $TargetPerspective=%insert(%word($AttackString,$Totalwords-$WordCount),$TargetPerspective,end)
  $BystanderPerspective=%insert(%word($AttackString,$Totalwords-$WordCount),$BystanderPerspective,end)}

  //This is just a counter to keep track of what word is being processed in the string
  $WordCount=$WordCount+1
}

//Setting up attacker's perspective
custom social set 0 self $AttackerPerspective

//Setting up target's perspective
custom social set 0 target $TargetPerspective

//setting up bystanders' perspective
custom social set 0 bystanders $BystanderPerspective
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Oct 06, 2010 1:53 am   
 
I still think using an explicit marking system is your best bet.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Wed Oct 06, 2010 6:24 am   
 
What chemenas and Rahab said.

Properly parsing sentences will be very difficult to do, thanks to the complexities of the English language. Too many words change meaning and function in a sentence, depending on context.

With an explicit marking system, as chemenas suggested, you'd type:

%n *tumbles backwards, startled and soon sprawled across the floor. Looking up, %e *laughs back at %N, and *begins to pick %sself up.

And the script then knows to change those words marked with the * character, depending on the perspective.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Oct 06, 2010 12:17 pm   
 
I have to agree. In fact, with your example sentence, you are not catching a verb. "sprawled" should actually be "sprawls", and is a second verb in the first sentence, just as "begins" is a second verb in the second sentence. "Tumbles" and "laughs" might be caught because of their placement after the subject, but catching "sprawls" and "begins" is a lot more difficult. Without a more complicated lexer (what you have so far is actually the simple beginnings of a lexer), the only easy way to catch the verbs is with markup.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
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