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


Joined: 06 May 2019
Posts: 9

PostPosted: Sun Jan 12, 2020 3:55 pm   

Does not compile : syntax error at row 13 col 37?.
 
Hello,


Code:
\s+Exp:(\d+)\s+

#If (%1 != @Experience.Current) {
#math Experience.Difference %1 - @Experience.Current
}
#If (@Experience.Required_for_next_level - @Experience.Stored <= %1) {
#Substitute {%Char(32)<color gold https://chatroulette.onl >Exp</color>:<color green>%1</color>%IF(@Experience.Current != %1, %Char(40)%If(0<@Experience.Difference,<color green>+@Experience.Difference,<color red>@Experience.Difference)</color>%Char(41), "")%Char(32)}
} {
#If (@Improvement.Max_Cost <= %1) {
#Substitute {%Char(32)Exp:<color green>%1</color>%IF(@Experience.Current != %1, %Char(40)%If(0<@Experience.Difference,<color green>+@Experience.Difference,<color red>@Experience.Difference)</color>%Char(41), "")%Char(32)}
} {
#If (300000 <= %1) {
#Substitute {%Char(32)Exp:<color yellow>%1</color>%IF(@Experience.Current != %1, %Char(40)%If(0<@Experience.Difference,<color green>+@Experience.Difference,<color red>@Experience.Difference)</color>%Char(41), "")%Char(32)}
} {
#If (@Improvement.Min_Cost <= %1) {
#Substitute {%Char(32)Exp:<color $BF6000>%1</color> https://ometv.onl %IF(@Experience.Current != %1, %Char(40)%If(0<@Experience.Difference,<color green>+@Experience.Difference,<color red>@Experience.Difference)</color>%Char(41), "")%Char(32)}
} {
#Substitute {%Char(32)Exp:<color red>%1</color>%IF(@Experience.Current != %1, %Char(40)%If(0<@Experience.Difference,<color green>+@Experience.Difference,<color red>@Experience.Difference)</color>%Char(41), "")%Char(32)}
}
}
}
}
#AddKey Experience Current %1
It calculates and adds my exp change from
" Exp:NUMBER "
to
" Exp:COLORED NUMBER(�COLORED NUMBER) "

Works fine in zMud, does not compile in Cmud and gives stuff like this
Quote:
239(+Differenceurrent235Max239.Difference)239

thanks
iosman


Last edited by iosman on Thu Jan 16, 2020 1:47 pm; edited 1 time in total
Reply with quote
shalimar
GURU


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

PostPosted: Mon Jan 13, 2020 2:26 pm   
 
zMUD allowed a lot of sloppy shortcuts in code, CMUD is much more strict about syntax.

In a lot of your %if you open the color tags, but dont close them inside the same %if, i believe this is leading to unmatched braces.
You might also get better results using %db(@experience, Current) as opposed to the dot notation.
Not sure why you are inserting spaces and parenthesis with the %char command, but that just makes your code harder to read.
Local variables can shorten code a lot as well.
_________________
Discord: Shalimar#3679
Reply with quote
shalimar
GURU


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

PostPosted: Mon Jan 13, 2020 7:24 pm   
 
Try this:

Code:
#LOCAL $color
$current=%db(@experience, Current)
#If (%1 != $current) {#ADDKEY Experience Difference %eval(%1-$current)}
$diff=%db(@experience, Difference)

#SWITCH ((%db(@experience, Required_for_next_level)-%db(@experience, Stored))<=%1) {$color=gold}
  (%db(@improvement, Max_Cost)<=%1) {$color=green}
  (300000<=%1) {$color=yellow}
  (%db(@improvement, Min_Cost)<=%1) {$color=$BF6000}
  {color=red}
#IF (0 < $diff) {$diff=<color green>$diff</color>} {$diff=<color red>$diff</color>}
#SUB { EXP: <color $color>%1</color>%if($current!=%1, ~($diff~)) }
#AddKey Experience Current %1
_________________
Discord: Shalimar#3679
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