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
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sat May 21, 2011 1:52 pm   

PCOL Help
 
Hey guys,

Below is an example of the current trigger I have set up. All of the messages I'm trying to colorize look like one of two things:

You raze Grand Moff Tarkin.
You annihilate Grand Moff Tarkin completely.

Where raze/annihilate completely are the damage types, and Grand Moff Tarkin is a mob.

What I want to do is set the damage types to a certain color each, and leave the mob the standard MUD color.
It works with the 1-word damages, but damage types of two words (IE. annihilate completely), it will color in the mob's name as well. Any idea how to fix this?

Code:

<trigger priority="5040" id="504">
  <pattern>^You (%w) * (%w).</pattern>
  <value>#IF (%1=nick AND %2=lightly) {#PCOL darkred %x1
#PCOL darkred %x2}
#IF (%1=nick) {#PCOL darkred %x1}
#IF (%1=injure) {#PCOL mxpred %x1}
#IF (%1=injure AND %2=severely) {#PCOL mxpred %x1
#PCOL mxpred %x2}
#IF (%1=wound) {#PCOL orangered %x1}
#IF (%1=wound AND %2=badly) {#PCOL orangered %x1
#PCOL orangered %x2}
#IF (%1=nail) {#PCOL darkgreen %x1}
#IF (%1=damage) {#PCOL green %x1}
#IF (%1=damage AND %2=terribly) {#PCOL green %x1
#PCOL green %x2}
#IF (%1=raze) {#PCOL darkcyan %x1}
#IF (%1=decimate) {#PCOL darkcyan %x1}
#IF (%1=obliterate) {#PCOL blue %x1}
#IF (%1=annihilate) {#PCOL cyan %x1}
#IF (%1=annihilate AND %2=completely) {#PCOL cyan %x1
#PCOL cyan %x2}</value>
</trigger>
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sat May 21, 2011 2:17 pm   
 
Also, does not work with mobs with only one name, such as Chewbacca. ;)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat May 21, 2011 2:55 pm   
 
If both the damage type and target can have more than one word, the only way for the trigger to tell where the damage type ends and the target name begins is to make a list of all the damage types:
Code:

#var damtype1 {nick|injure|wound|nail|damage|raze|decimate|obliterate|annihilate}
#var damtype2 { lightly| severely| badly| terribly| completely|}

Then rewrite your trigger to catch this:
Code:

<trigger priority="5040" id="2327">
  <pattern>^You ({@damtype1}) *({@damtype2}).</pattern>
  <value>#switch (%1)
  ("nick") {#PCOL darkred %x1}
  ("injure") {#PCOL mxpred %x1}
  ("wound") {#PCOL orangered %x1}
  ("nail") {#PCOL darkgreen %x1}
  ("damage") {#PCOL green %x1}
  ("raze") {#PCOL darkcyan %x1}
  ("decimate") {#PCOL darkcyan %x1}
  ("obliterate") {#PCOL blue %x1}
  ("annihilate") {#PCOL cyan %x1}

#switch (%2)
  ("lightly") {#PCOL darkred %x2}
  ("severely") {#PCOL mxpred %x2}
  ("badly") {#PCOL orangered %x2}
  ("terribly") {#PCOL green %x2}
  ("completely") {#PCOL cyan %x2}
 
</value>
</trigger>
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sat May 21, 2011 4:07 pm   
 
It works properly if there are damages that include the two words. However, if it is a one-word damage, such as "nail", no coloration.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat May 21, 2011 9:51 pm   
 
Did you create the @damtype2 exactly as I had it, with one blank value?
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sun May 22, 2011 10:48 am   
 
I went back in and repasted exactly what you had in, and now it will color the first damage word, but not the second. I have tried damtype2 with a space infront, without a space infront of the word, with a blank value, and without. Nothing.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun May 22, 2011 5:41 pm   
 
#trigger {You ({@damtype1}) (*).} {
$d2 = ""
//STUFF TO FIGURE OUT WHICH COLOR TO CHOOSE FOR damtype1
#pcol color %x1
#call %match(%2,"(*) ({@damtype2})",$mobname,$d2)
#if ($d2 != "") {
//STUFF TO FIGURE OUT WHICH COLOR TO CHOOSE FOR damtype2
#psub $mobname" "%ansi(coloryouwant)$d2 %x2
}
}
_________________
EDIT: I didn't like my old signature
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon May 23, 2011 4:47 pm   
 
Still the same results, Matt. First will color, second will not.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon May 23, 2011 4:51 pm   
 
Changed it back to Rahab's work, and messed around with it a bit. Currently, it will color only if the first and second words are present. No one-word damages.

Code:

<trigger priority="5040" id="550">
  <pattern>^You ({@damtype1}) *({@damtype2}).</pattern>
  <value>#switch (%1)
  ("nick") {#PCOL darkred %x1}
  ("injure") {#PCOL mxpred %x1}
  ("wound") {#PCOL orangered %x1}
  ("nail") {#PCOL darkgreen %x1}
  ("damage") {#PCOL green %x1}
  ("raze") {#PCOL darkcyan %x1}
  ("decimate") {#PCOL darkcyan %x1}
  ("obliterate") {#PCOL blue %x1}
  ("annihilate") {#PCOL cyan %x1}

#switch (%2)
  ("lightly") {#PCOL darkred %x2}
  ("severely") {#PCOL mxpred %x2}
  ("badly") {#PCOL orangered %x2}
  ("terribly") {#PCOL green %x2}
  ("completely") {#PCOL cyan %x2}</value>
</trigger>
[/code]
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon May 23, 2011 10:04 pm   
 
Quote:

Still the same results, Matt. First will color, second will not.


Insert some #PRINT commands and see what the local variables and %1/%2 variables are showing. To better point out leading or trailing whitespace, concatenate a visible character in front and in back of the variable, like so:

#print "|"%1"|"

Without knowing what's actually getting assigned, there's no way to tell where the error is occurring (it's not like we can just stroll off to your mud and see for ourselves).
_________________
EDIT: I didn't like my old signature
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sat May 28, 2011 6:50 am   
 
Hey guys,

Here's what I've got. With Rahab's trigger:

On a one-word damage, nothing at all pops up with print, and nothing colors.

You wound Assassin.

With a two-word damage, the brackets pop up, but only the first word colors.

You injure Assassin severely.
|injure|
| severely|

Code:

<trigger priority="5040" id="550">
  <pattern>^You ({@damtype1}) *({@damtype2}).</pattern>
  <value>#switch (%1)
  ("nick") {#PCOL darkred %x1}
  ("injure") {#PCOL red,bold %x1}
  ("wound") {#PCOL orangered %x1}
  ("nail") {#PCOL darkgreen %x1}
  ("damage") {#PCOL green %x1}
  ("raze") {#PCOL darkcyan %x1}
  ("decimate") {#PCOL darkcyan %x1}
  ("obliterate") {#PCOL blue %x1}
  ("annihilate") {#PCOL cyan %x1}

#switch (%2)
  ("lightly") {#PCOL darkred %x2}
  ("severely") {#PCOL mxpred %x2}
  ("badly") {#PCOL orangered %x2}
  ("terribly") {#PCOL green %x2}
  ("completely") {#PCOL cyan %x2}
 
#print "|"%1"|"
#print "|"%2"|"</value>
</trigger>


With Matt's:

One-word damages pop up with the first damage as variable1 and the target's name as variable2, and colors the first word.

You wound Assassin.
|wound|
|Assassin|

Two-word damages pop up with the first damage as variable1, and the target's name and second damage as variable 2, and colors only the first word.

You wound Assassin badly.
|wound|
|Assassin badly|

Code:

<trigger priority="5570" enabled="false" id="557">
  <pattern>You ({@damtype1}) (*).</pattern>
  <value>$d2 = ""
//STUFF TO FIGURE OUT WHICH COLOR TO CHOOSE FOR damtype1
#pcol red,bold %x1
#call %match(%2,"(*) ({@damtype2})",$mobname,$d2)
#if ($d2 != "") {
//STUFF TO FIGURE OUT WHICH COLOR TO CHOOSE FOR damtype2
#psub $mobname" "%ansi(blue)$d2 %x2
}

#print "|"%1"|"
#print "|"%2"|"</value>
</trigger>


Variable 1 looks like:

Code:

  <var name="damtype1" type="StringList">
    <value>nick|injure|wound|nail|damage|raze|decimate|obliterate|annihilate</value>
    <json>["nick","injure","wound","nail","damage","raze","decimate","obliterate","annihilate"]</json>
  </var>


Variable 2 looks like:

Code:

  <var name="damtype2" type="StringList">
    <value> lightly| severely| badly| terribly| completely| </value>
    <json>[" lightly"," severely"," badly"," terribly"," completely"," "]</json>
  </var>
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat May 28, 2011 10:06 pm   
 
Quote:

On a one-word damage, nothing at all pops up with print, and nothing colors.


I am sure this is because the trigger does not fire at all. Replace the last item with a blank value. " " is not a blank value.

Quote:

Two-word damages pop up with the first damage as variable1, and the target's name and second damage as variable 2, and colors only the first word.


Rahab made a typo in the second switch command. Let's see if you can spot it too (hint: look carefully at the values in @damtype2.)

With regards to my trigger, you need to remove the spaces from @damtype2 entirely. Those spaces are handled in the %match() pattern.
_________________
EDIT: I didn't like my old signature
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Sat May 28, 2011 10:41 pm   
 
Restructured damtype2 to reflect the empty space:

Code:

  <var name="damtype2" type="StringList">
    <value>| lightly| completely| severely| badly| terribly</value>
    <json>[""," lightly"," completely"," severely"," badly"," terribly"]</json>
  </var>


I can't find what you're talking about in the "second switch command". Are you talking about the values in the trigger, or in @damtype2 itself? I've tried all kinds of spacings and still nothing.

As for your trigger, I removed the spaces, and still no dice.
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Mon May 30, 2011 5:00 pm   
 
Any ideas?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue May 31, 2011 12:43 am   
 
Give me the contents of $mobname and $d2. The trigger as I have written it SHOULD work just fine, so either one of the local variables has something unexpected or your permanent variables are incorrectly formatted (remove all spaces and blank values from @damtype2 if you are going to use my trigger.)
_________________
EDIT: I didn't like my old signature
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Tue May 31, 2011 5:05 am   
 
Removed all spaces and blank values from @damtype2.

You damage Trooper. (damage shows up correctly in red)
%1: |damage|
%2: |Trooper|
mobname: ||
d2: ||

You wound Trooper badly. (damage 1 shows up correctly in red. damage 2 shows no color change)
%1: |wound|
%2: |Trooper badly|
mobname: ||
d2: ||
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue May 31, 2011 9:47 pm   
 
Ok, now the problem is obvious. The %match() function must not do stringlists, so we'll have to do things differently.

The following is the existing portion of the code to be replaced:
Code:
#call %match(%2,"(*) ({@damtype2})",$mobname,$d2)
#if ($d2 != "") {
  //STUFF TO FIGURE OUT WHICH COLOR TO CHOOSE FOR damtype2
  #psub $mobname" "%ansi(blue)$d2 %x2
}


This is the code that replaces it:
Code:
$d2 = %word(%2,%numwords(%2))
#if (%ismember($d2,@damtype2)) {
  $mobname = %remove($d2,%2)
  #psub $mobname%ansi(blue)$d2 %x2
}
_________________
EDIT: I didn't like my old signature
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 111

PostPosted: Wed Jun 01, 2011 7:47 am   
 
Getting the "ERROR: Trigger "You ({@damtype1}) (*)." fired but did not compile" error.

Here is the trigger script currently. Not sure how to troubleshoot this.

Code:

$d2 = ""
//STUFF TO FIGURE OUT WHICH COLOR TO CHOOSE FOR damtype1
#pcol red,bold %x1
$d2 = %word(%2,%numwords(%2))
#if (%ismember($d2,@damtype2)) {
  $mobname = %remove($d2,%2)
  #psub $mobname%ansi(blue)$d2 %x2
}

#print "|"%1"|"
#print "|"%2"|"
#print "|"$mobname"|"
#print "|"$d2"|"
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Jun 01, 2011 10:43 am   
 
I just put your script into an alias and went to the compiled code tab which stated

Error compiling script:
invalid local variable: mobname

Inserting

$mobname = ""

before or after the $d2 = "" fixes the error.
_________________
Taz :)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Jun 12, 2011 4:40 am   
 
Heh... %match does too do string lists...

Code:
#VAR test {1|2|3|4}
#ALIAS test {#SHOW %match(%1,%concat("^({",@test,"}]$"))}


test 1
test 2
test 3
test 4

All correctly show 1 as output.
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