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


Joined: 15 Nov 2016
Posts: 6

PostPosted: Thu Nov 17, 2016 10:06 am   

I need help with writing a trigger I can't figure out how to accomplish it.
 
ok so here is a breakdown of what I want it to do: I want it to capture mobs off of scan function and here is a few different things that it needs to trigger off of.

west : a vyan sorceress, a palace valet
east : two palace valets
north : a vyan witch doctor,
a vyan shaman


Those above are the 3 examples I have seen the mud put out with correct spacing and all.
What I want to accomplish is I want it to put each of the mobs into a string list variable for whichever direction they are in.
so for west I would want a variable named scanwest with vyan sorceress and palace valet in it. same with north and east.
so basically north east south west up and down would all have their own stringlist variable for storing what it pulls off of the scan in that direction.
and if the scan is like it is east I want it to take the two word off of it and add 2 instances of the mob to the stringlist same goes for three four and five.
and if it is like the north where it put it on a seperate line I want it to add each of those mobs to it's corrisponding stringlist.
keep in mind that it could be the north one but with two of something and something else on another etc.
If someone could do this for me I would be super appreciative. I been trying to figure this out for days with no luck.
Thank you in advance.
Reply with quote
twiztidfate
Newbie


Joined: 15 Nov 2016
Posts: 6

PostPosted: Thu Nov 17, 2016 11:53 am   Update
 
east : two palace valets
it's suppose to remove the word two and the s off the end and add 2 instances of palace valet to it's corresponding stringlist

Please feel free to message me if you have any questions.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3658
Location: Pensacola, FL, USA

PostPosted: Thu Nov 17, 2016 1:22 pm   
 
Code:
<trigger priority="21180" id="2118">
  <pattern>^({north|south|east|west|up|down}) : (*)$</pattern>
  <value>#IF (!%ends( %trim( %line), ",")) {
  #STATE 0
  $dir=%1
  $mobs=%replace( %2, ", ", "|")
  #FORALL $mobs {}
  }</value>
  <trigger type="Within Lines" param="1">
    <pattern>(*)</pattern>
    <value>$dir=%t1
$mobs=%replace(%concat(%t2, " ", %line), ", ", "|")
#FORALL $mobs {}</value>
  </trigger>
</trigger>


Something like this should at least capture things into stringlists for you, but you need to further process in the forall for your desired results.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
twiztidfate
Newbie


Joined: 15 Nov 2016
Posts: 6

PostPosted: Fri Nov 18, 2016 12:23 am   
 
Thank you for the quick reply but I have been trying to figure this out for forever if I could of figured out what to put where I wouldn't of asked lol.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3658
Location: Pensacola, FL, USA

PostPosted: Fri Nov 18, 2016 3:24 am   
 
It's a process.
...and you would put that on the XML tab of a new trigger.
Overwrite whatever is there currently.

As to the #FORALL...
you need to teach it how to unpluralize things, and to recognize how many of them it has.
For this only the first and last word matter.
Teaching it to unpluralize things is likely too complicated, it would be easier to build a list of known values:

#ADDKEY unPlural {sorceresses} {sorceress}
#ADDKEY unPlural {valets} {valet}
#ADDKEY unPlural {shamen} {shaman}
#ADDKEY unPlural {wolves} {wolf}
#ADDKEY unPlural {octopii} {octopus}
#ADDKEY unPlural {geese} {goose}
and so on, for whatever mobs you will need to apply this to.
Yes, you will need to continually add to the list until all the mobs are there.... I can add an error checker so you can see if you have come across a new mob type.

Oi... this forall is getting ugly... Is there a line that signifies that you are starting to scan, before the output you have given?
So I can just put it all together as one piece.

Currently I have it outputting with #DBSHOW to look like:

west: vyan sorceress|palace valet
east: palace valet|palace valet
north: vyan witch doctor|vyan shaman
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
twiztidfate
Newbie


Joined: 15 Nov 2016
Posts: 6

PostPosted: Fri Nov 18, 2016 4:02 am   
 
Nope no line to signify it, you type scan to make it happen if that helps.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3658
Location: Pensacola, FL, USA

PostPosted: Fri Nov 18, 2016 4:44 am   
 
Okay, you want to get rid of everything you have for this so far... or disable it and whathaveyou.

Open the settings editor.
Create a new class.
Switch to the XML tab.
Paste the following over what is already there:

Code:
<class name="ScanTester" id="2116">
  <trigger priority="21180" id="2118">
    <pattern>^({north|south|east|west|up|down}) : (*)$</pattern>
    <value>#IF (!%ends( %trim( %line), ",")) {
  #STATE 0
  $dir=%1
  $mobs=%replace( %2, ", ", "|")
  #FORALL $mobs {
    #LOCAL $count $thisMob
    $num=%word( %i, 1)
    #SWITCH ($num)
      ("two") {$count=2}
      ("three") {$count=3}
      ("four") {$count=4}
      ("five") {$count=5}
      {$count=1}
    #IF ($count>1) {
      $plural=%word( %i, %numwords( %i))
      $single=%db( @unPlural, $plural)
      #IF ($single) {$thisMob=%replace( %rightback( %i, %eval( %len( %i)-%len( $num)-1)), $plural, $single)} {#PRINT Error: Cannot unPlural: $plural}
      } {$thisMob=%rightback( %i, %eval( %len( %i)-%len( $num)-1))}
    $thisScan=%db( @scanResults, $dir)
    #LOOP $count {$thisScan=%additem( $thisMob, $thisScan)}
    #ADDKEY scanResults $dir $thisScan
    }
  #ALARM "showDb" +5 {#PRINT;#SHOWDB @scanResults}
  }</value>
    <trigger type="Within Lines" param="1">
      <pattern>(*)</pattern>
      <value>$dir=%t1
$mobs=%replace( %concat( %t2, " ", %line), ", ", "|")
#FORALL $mobs {
  #LOCAL $count $thisMob
  $num=%word( %i, 1)
  #SWITCH ($num)
      ("two") {$count=2}
      ("three") {$count=3}
      ("four") {$count=4}
      ("five") {$count=5}
      {$count=1}
  #IF ($count>1) {
    $plural=%word( %i, %numwords( %i))
    $single=%db( @unPlural, $plural)
    #IF ($single) {$thisMob=%replace( %rightback( %i, %eval( %len( %i)-%len( $num)-1)), $plural, $single)} {#PRINT Error: Cannot unPlural: $plural}
    } {$thisMob=%rightback( %i, %eval( %len( %i)-%len( $num)-1))}
  $thisScan=%db( @scanResults, $dir)
  #LOOP $count {$thisScan=%additem( $thisMob, $thisScan)}
  #ADDKEY scanResults $dir $thisScan
  }
#ALARM "showDb" +5 {#PRINT;#SHOWDB @scanResults}</value>
    </trigger>
  </trigger>
  <var name="unPlural" type="Record" id="2120">
    <value>wolves=wolf|cats=cat|octopii=octopus|geese=goose|valets=valet</value>
    <json>{"octopii":"octopus","wolves":"wolf","geese":"goose","valets":"valet","cats":"cat"}</json>
  </var>
  <trigger type="Command Input" priority="1" id="2123">
    <pattern>^scan$</pattern>
    <value>scanResults=""</value>
  </trigger>
</class>
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
twiztidfate
Newbie


Joined: 15 Nov 2016
Posts: 6

PostPosted: Fri Nov 18, 2016 5:01 am   
 
Error compiling script:
expression expected
Reply with quote
twiztidfate
Newbie


Joined: 15 Nov 2016
Posts: 6

PostPosted: Fri Nov 18, 2016 5:12 am   
 
and you can't have the ^ before ^({north|south|east|west|up|down}) : (*)$ because there is a 10 spaces before east:
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3658
Location: Pensacola, FL, USA

PostPosted: Fri Nov 18, 2016 2:55 pm   
 
I was basing it off the sample output you provided, you need to use the forum code tags to preserve spacing.

As for the error, I'm not sure why you would get that... you did paste it on the XML tab right?
If so we have to figure out which setting has the error.

Open up triggers in the settings editor.
Select the various triggers about scanning (one by one) and
Choose Editor on the menu bar and choose 'check syntax'

This will let us know if there was some confusion from the XML.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
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