Why are my old MM2000 /if statements not working? Print
Written by Ghoti   
Tuesday, 25 May 2010 09:36

There is a very good chance your MM2000 scripts have /if statements which have string variables in them which aren't surrounded by double quotes. Many of the bugs in the /if code of MM2000 have been fixed in MudMaster 2k6 but one result is 2k6 is extremely picky about strings and string variables in /if statements.

The simplest way to avoid problems now is to put double quotes around both strings and string variables. So instead of /if {$this == $that}{/showme {this matches that} use /if {"$this" == "$that"}{/showme {this matches that}

The other possible problems could be related to /empty MyVar makes MyVar null which is not the same as 0 and variables that haven't been made empty or set to anything yet become strings.

Here are some examples to try to explain further.

/if {$MyVar = 0}{/showme {true}}{/showme {false}}

  • If MyVar was never set this if becomes "$MyVar" = 0 raising an error because the left is string and the right is numeric. The error will be sring variables must use quotes.
  • if /empty MyVar was done then the if becomes = 0 rasing an error because there is only half a condition
  • If /var {MyVar}{1} or equivalent was done then the if works and returns false

/if {$MyVar = $RoomName}{/showme {true}}{/showme {false}}

  • Even if MyVar or RoomName have¬†previously been set to some string this condition will fail - even if the strings are the same.¬†Strings inside /if statements must be surrounded by double quotes like:

/if {"$MyVar" = "$RoomName"}{/showme {true}}{/showme {false}}

This is because of the mechanics of variable replacement. The $MyVar and the $RoomName are replaced with the actual strings they contain before the if condition is evaluated.

Last Updated on Wednesday, 23 June 2010 11:20