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
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Oct 21, 2010 2:56 pm   

[3.31] Small Bug when entering code from Command Line
 
When the following code is pasted to the command line it creates the trigger with a syntax error in the second trigger state.

Code:
#TRIGGER {^(~[Simyarin~])%s%x} {
#CAP chat
#GAG
}
#COND {^(%s)%x} {
#IF (%len( %1)>1)
{ #CAP chat;
  #STATE 1;
  #gag
}}


The code that's generated is
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="10" copy="yes">
    <pattern>^(~[Simyarin~])%s%x</pattern>
    <value>#CAP chat
#GAG</value>
    <trigger name="">
      <pattern>^(%s)%x</pattern>
      <value>#IF (%len( %1)>1){ #CAP chat;
  #STATE 1;
  #gag
}</value>
    </trigger>
  </trigger>
</cmud>


The key line is
Quote:
#IF (%len( %1)>1){ #CAP chat;


Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="10" copy="yes">
    <pattern>^(~[Simyarin~])%s%x</pattern>
    <value>#CAP chat
#GAG</value>
    <trigger>
      <pattern>^(%s)%x</pattern>
      <value>#IF (%len( %1)>1) { #CAP chat;
  #STATE 1;
  #gag
}</value>
    </trigger>
  </trigger>
</cmud>


In the working version The key line is
Quote:
#IF (%len( %1)>1) { #CAP chat;


Note the space.
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Oct 21, 2010 5:50 pm   
 
Your original code has the wrong multiline syntax. When using multiline syntax, either the { needs to be the last thing on the line, or the only thing on the line. So both of these are valid:
Code:
#IF (%len( %1)>1) {
  #CAP chat
  #STATE 1
  #gag
}

or
Code:
#IF (%len( %1)>1)
{
  #CAP chat
  #STATE 1
  #gag
}

Also, you shouldn't have the ; characters at the end of the line. The ; character is only for separating multiple commands on the same line.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Oct 21, 2010 6:48 pm   
 
Actually, you're right I see it now.

By the by, it wasn't my code, it was something I came across when helping debug another forum post. So many hiccups could be avoid with good coding habits.
_________________
Asati di tempari!
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