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


Joined: 14 Jul 2009
Posts: 6

PostPosted: Sun Nov 27, 2011 10:30 am   

Trigger-creating script resulting in unexpected trigger type
 
Hi, after several hours spent on that bloody problem, I have to use collective skills and knowledge and ask here ;)
So here is the issue:

I got a db variable with descriptions and names and another one with names and colors:

Code:
#VAR desc_name "fat stupid man=Peter"
#VAR name_col "Peter=red"



I got an alias that fires #SUB and another one that the colors the name:

Code:
#ALIAS sub_desc {
    #SUB %format( "%s (%s)", %1, @desc_name.%1)}

#ALIAS color_name {
    #CW @name_col.%1}


A loop script that creates triggers for all the people from the database (values above are just one example).
It's supposed to create two triggers - one that colors the name (if I know the person or someone introduces them) and another one to show the name next to the description, so it looks like:

Quote:
Fat stupid man (Peter) arrives from the east.

Lois introduces fat stupid man (Peter) as:
Peter Griffin, man.


And inside the loop script:

Code:
(...)
$trigger_name = people_desc_sub_%replace( $desc, " ", "_")
$pattern = ~($desc~)
$commands = sub_desc $desc
#TRIGGER $trigger_name $pattern $commands {People|Triggers} regex|pri=1

$trigger_name = people_name_color_$name
$pattern = $name~(~ |\.|, ~)
$commands = color_name $name
#TRIGGER $trigger_name $pattern $commands {People|Triggers}  regex|pri=1


Second trigger is created correctly, results in:
Code:
<trigger name="people_name_color_Peter" priority="1" regex="true" id="1770">
  <pattern>Peter( |\.|, )</pattern>
  <value>color_name Sander</value>
</trigger>


However the first one ends up NOT as normal 'Pattern' type trigger, but as 'Expression' type trigger:
Code:
<trigger name="people_desc_sub_fat_stupid_man" type="Expression" priority="1" trigontrig="false" regex="true" id="1769">
  <pattern>(fat_stupid_man)</pattern>
  <value>sub_desc fat stupid man</value>
</trigger>


The way of creating them seems the same to me, but one works fine, another doesn't. Fixing the settings manually is not an option, since I loop through like 700 records. Or maybe someone has a better idea how to create a fast-working script that would use the provided data:
Quote:
Desc=fat stupid man
Name=Peter
Guild=FG

to produce substitution results like
Quote:

Fat stupid man (Peter FG) attacks you!
Reply with quote
shalimar
GURU


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

PostPosted: Sun Nov 27, 2011 1:12 pm   
 
Why don't you keep all the data in one DB var\r?

Code:
#FORALL %keys(@desc_name) {
$desc=%i
$name=@{desc_name.%i}
$color=@{name_col.%i}
$guild=wherever you store guild info
#ADDKEY @char_list.$desc {Name=$name}
#IF ($color) {#ADDKEY @char_list.$desc {Color=$color}}
#IF ($guild) {#ADDKEY @char_list.$desc {Guild=$guild}}
}


Then a single trigger should work.

Code:
#TR {({@char_list})} {
$who=%1
$name=@{char_list.$who.name}
#IF (@{char_list.$who.guild}) {$name=%concat($name, " ", @{char_list.$who.guild})}
#SUB {$who ($name)}
#IF (@{char_list.$who.color}) {#CW @{char_list.$who.color}}
}
_________________
Discord: Shalimarwildcat
Reply with quote
Sjrv
Newbie


Joined: 14 Jul 2009
Posts: 6

PostPosted: Mon Nov 28, 2011 9:47 am   
 
Yep, I did something like that and it works now, cheers!
Now that's silly. Doing some crazy sql scripting, automatic noun and adjective declension (not an English MUD) and forgetting I could make a trigger with (@db_var) pattern that would use the variable's keys by default.
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