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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Jan 23, 2009 8:18 pm   

Odd Issue with formatting [Solved]
 
Here's the working trigger:
Code:

<trigger priority="460" regex="true" id="46">
  <pattern>^Spell: permanency        : modifies none by \d+ for (\d+) cycles, \(\d+ (?:1/2 )?hours\)$</pattern>
  <value>$Time_LeftC=%1
$Time_LeftS=$Time_LeftC*41
$Time_LeftM=%float($Time_LeftS)/60
$Time_LeftH=%float($Time_LeftM)/60
$Time_LeftH=%format(2,$Time_LeftH)

$Time_Hours=%round($Time_LeftH*100)/100
$Time_Minutes=%mod(%round($Time_LeftH*100),100)*60/100

#SWITCH ($Time_Hours>1)
{
 #sub  "Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minutes remaining."} ($Time_Hours=1) {#sub  "Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minutes remaining."
} ($Time_Hours<1) {#sub  "Permanency Cooldown      : "$Time_Minutes" minutes remaining. (or "%1" cycles)"}
</value>
</trigger>


However, I don't like how that reads, I wanted it to look like this:
Code:

...
#SWITCH ($Time_Hours>1)
{
 #sub  "Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minutes remaining."
}
($Time_Hours=1)
{
 #sub  "Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minutes remaining."
}
($Time_Hours<1)
{
 #sub  "Permanency Cooldown      : "$Time_Minutes" minutes remaining. (or "%1" cycles)"
}


But it started erroring like that. What rules of formatting am I breaking by doing that?
_________________
Listen to my Guitar - If you like it, listen to more

Last edited by chamenas on Mon Jan 26, 2009 12:59 am; edited 1 time in total
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Fri Jan 23, 2009 8:37 pm   
 
Try to play with an indent. General rule is: your curly braces {} must be 1 level deeper than parentheses. If it'll not help, try to make an indent for the parentheses as well

Code:
#SWITCH ($Time_Hours>1) {
   #sub  "Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minutes remaining."
  }
 ($Time_Hours=1)
  {
    #sub  "Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minutes remaining."
  }
 ($Time_Hours<1)
  {
    #sub  "Permanency Cooldown      : "$Time_Minutes" minutes remaining. (or "%1" cycles)"
  }


Sorry, I can't run CMUD right now and look how I did in my scripts.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Jan 23, 2009 9:30 pm   
 
That worked, thanks. Now I have an odd issue though.

Code:

<trigger priority="460" regex="true" id="46">
  <pattern>^Spell: permanency        : modifies none by \d+ for (\d+) cycles, \(\d+ (?:1/2 )?hours\)$</pattern>
  <value><![CDATA[$Time_LeftC=%1
$Time_LeftS=$Time_LeftC*41
$Time_LeftM=%float($Time_LeftS)/60
$Time_LeftH=%float($Time_LeftM)/60
$Time_LeftH=%format(2,$Time_LeftH)

$Time_Hours=%round($Time_LeftH*100)/100
$Time_Minutes=%mod(%round($Time_LeftH*100),100)*60/100

#SWITCH (($Time_Hours>1) AND ($Time_Minutes>1) OR ($Time_Minutes<1)) {
  #sub  "Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minutes remaining."
  }
 (($Time_Hours=1) AND ($Time_Minutes=1))
  {
   #sub  "Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minute remaining."
  }
 (($Time_Hours<1) AND ($Time_Minutes>1))
  {
   #sub  "Permanency Cooldown      : "$Time_Minutes" minutes remaining. (or "%1" cycles)"
  }
 (($Time_Hours>1) AND ($Time_Minutes=1))
  {
   #sub  "Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minute remaining."
  }
 (($Time_Hours=1) AND ($Time_Minutes>1))
  {
   #sub  "Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minutes remaining."
  }
 (%1<4)
  {
   #sub  "Permanency Cooldown      : cycles remaining!
  }  ]]></value>
</trigger>


Is the new code, and it works fine for the instances I have tested, except then %1 gets below 4. The pattern matches below 4, but the trigger doesn't replace the text, it lets it goes through and tries to create a new trigger based off of information from the pattern.

Example trigger made by #show "Spell: Permanency : modifies none by 0 for 3 cycles, (123 1/2 hours)"
Code:

<trigger priority="870" id="87">
  <pattern>"Permanency</pattern>
  <value>#sub {Cooldown}</value>
</trigger>
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Jan 23, 2009 10:55 pm   
 
Probably because all your subs need to be in brackets, not quotes.

#SUB {Permanency Cooldown : cycles remaining!}

should work.

Charneus
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Jan 24, 2009 12:58 am   
 
Should I do brackets and quotes? Or leave the quotes out. I have a mix of strings and variables.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Jan 24, 2009 1:12 am   
 
Try doing brackets and quotes. Normally, I don't quote anything in #SUB, but it couldn't hurt, I don't think. By the way, instead of doing that large space, try using the %repeat(" ",15) or however many spaces you want so you don't have to type them out. ;)

Charneus
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Jan 24, 2009 1:42 am   
 
Thanks, that worked. Oddly though, the color shorts out about halfway through. Even though there are no errors.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Jan 24, 2009 4:43 pm   
 
Here's the trigger, btw:

Code:

<trigger priority="460" regex="true" id="46">
  <pattern>^Spell: permanency        : modifies none by \d+ for (\d+) cycles, \(\d+ (?:1/2 )?hours\)$</pattern>
  <value><![CDATA[$Time_LeftC=%1
$Time_LeftS=$Time_LeftC*41
$Time_LeftM=%float($Time_LeftS)/60
$Time_LeftH=%float($Time_LeftM)/60
$Time_LeftH=%format(2,$Time_LeftH)

$Time_Hours=%round($Time_LeftH*100)/100
$Time_Minutes=%mod(%round($Time_LeftH*100),100)*60/100

#SWITCH (($Time_Hours>1) AND ($Time_Minutes>1) OR ($Time_Minutes<1)) {
  #sub  {"Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minutes remaining."}
  }
 (($Time_Hours=1) AND ($Time_Minutes=1))
  {
   #sub  {"Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minute remaining."}
  }
 (($Time_Hours<1) AND ($Time_Minutes>1))
  {
   #sub  {"Permanency Cooldown      : "$Time_Minutes" minutes remaining. (or "%1" cycles)"}
  }
 (($Time_Hours>1) AND ($Time_Minutes=1))
  {
   #sub  {"Permanency Cooldown      : "$Time_Hours" hours and "$Time_Minutes" minute remaining."}
  }
 (($Time_Hours=1) AND ($Time_Minutes>1))
  {
   #sub  {"Permanency Cooldown      : "$Time_Hours" hour and "$Time_Minutes" minutes remaining."}
  }
 (%1<4)
  {
   #sub  {"Permanency Cooldown      : "%1" cycles remaining!"}
  }  ]]></value>
</trigger>
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Jan 25, 2009 10:39 pm   
 
bump
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Tech
GURU


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

PostPosted: Mon Jan 26, 2009 12:17 am   
 
What exactly are you bumping? This the last thing you posted before the trigger? Is the trigger not working? Not compiling?

chamenas wrote:
Thanks, that worked. Oddly though, the color shorts out about halfway through. Even though there are no errors.


I just tried pasting into CMUD and it seems fine.
_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Jan 26, 2009 12:59 am   
 
Odd, it is working now. Thanks.
_________________
Listen to my Guitar - If you like it, listen to more
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