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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Tue Dec 12, 2006 8:53 pm   

[1.22] Troubles with #SUB and #FUNC
 
I have a custom function for returning how much of something is in my pocketbelts or 0 for none.

Code:
#FUNC Belt {%if(%iskey(@belt_count, %1), %db(@belt_count, %1), 0)}

#REGEX {^You put (\d+) (\w+) in your pocketbelts?\.$} {
   #ADDKEY belt_count %2 %eval(%1 + @Belt(%2))
   #SUB {You put %1 %2 in your pocketbelt, bringing the total to @Belt(%2).}
}


As you can see, I tried to use the function as part of a #SUB in a trigger, but I'm running into several problems.

1. If I put curly braces around the #SUB {text goes here}, I get a compiler error. It may be simply because I have the custom function call inside the sub, which is inside my trigger... #SUB {You get %1 %2 from your pocketbelt, bringing the total to @Belt(%2).}

2. I remove the curly braces to get the trigger created, but then the #SUB command creates a whole new trigger to substitute "get" for "You" and that's not what I want, either.

3. I tried a test with #GAG and then #SHOW to emulate the #SUB, and it translated @Belt(marjoram) as 0(marjoram) for output. The function was evaluated as a plain variable without being expanded using the parameter. Odd.

4. I can't put the whole thing inside quotes because that doesn't evaluate the variables. I can do this strange workaround, but it's not as pretty as the way I wanted to do it.

Code:
#SUB "You get "%1" "%2" from your pocketbelt, bringing the total to "@Belt(%2)"."
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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