MLConditional Wiki

Post in this thread issues and solution you find with the MainLobby 3 Client
Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

MLConditional Wiki

Postby Art Dustman » Thu May 24, 2012 3:27 pm

So I was going back over my macros, and went to the wiki which shows:

MLConditional|<<command>>##<<parm>>##<<execute_true>>##<<execute_false>>

Effective with MLServer 3.75.70, MLServer supports up to 4 nested macros. Use them this way:

Macro|MLConditional|IsEqual##Something##1##Macro|Setvariable|Var1~1!SetVariable|Var2~2##Macro|Setvariable|Var1~3!SetVariable|Var2~4##!!SetVariable|AllDone~1

According to the syntax, shouldn't it be this? (adding ## after MLConditional and removing the extra ## before the !!)

Macro|MLConditional|IsEqual##Something##1##Macro|Setvariable|Var1~1!SetVariable|Var2~2##Macro|Setvariable|Var1~3!SetVariable|Var2~4!!SetVariable|AllDone~1

*************************************************************

The nested ! (up to 4) are for running multiple macros in place of creating a large single macro. Therefore for each execution of true or false, I can run 4 macros each, or a total of 8 commands (4 when true and 4 when false)

color = red
if color = red, make var traffic = stopped and make var driver = sad
if color != red, make var traffic = go, and make var driver = happy, and make var speed = fast, and make var smog = low

Macro|MLConditional|IsEqual##color##red##Macro|SetVariable|traffic~stopped!SetVariable|driver~sad##Macro|Setvariable|traffic~go!SetVariable|driver~happy!!SetVariable|speed~fast!!!SetVariable|smog~low

**********************************************

To condition on conditions (nested with pair delimiters @@,##,$$,etc) may look like this:

color = red

if color = red,
and if sun = cloudy
then make var traffic = stopped and make var driver = sad and make var speed = stopped

if color != red
make var traffic = go, and make var driver = happy, and make var speed = fast



Macro|MLConditional|IsEqual##color##red##MLConditional|IsEqual@@sun@@cloudy@@Macro|SetVariable|traffic~stopped!SetVariable|driver~sad!!SetVariable|driver~sad@@Macro|Setvariable|traffic~go!SetVariable|driver~happy!!SetVariable|speed~fast##


Can anyone verify this is the correct interpretation. Thanks

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: MLConditional Wiki

Postby CinemarDave » Thu May 24, 2012 4:39 pm

Something is not right but I cannot see all the text because it was not wrapped in a CODE /CODE block.

Code: Select all

If Color = Red then
   If Sun = Cloudy then
       Traffic = stopped
       Driver = Sad
       Speed = Slow
   Else
       Traffic = Go
       Driver = Happy
       Speed = False
   End If
End If


Translates to

Code: Select all

Conditional|IsEqual##{{color}}##red##
     Conditional|IsEqual@@{{sun}}@@cloudy@@
         Macro|SetVariable|traffic~stopped!SetVariable|driver~sad!SetVariable|speed~slow
     @@
        Macro|Setvariable|traffic~go!SetVariable|driver~happy!SetVariable|speed~fast
##


This can be further simplified by combining the two conditionals into one

Code: Select all

Conditional|IsEqual##{{color}}{{sun}}##redcloudy##
         Macro|SetVariable|traffic~stopped!SetVariable|driver~sad!SetVariable|speed~slow
     ##
        Macro|Setvariable|traffic~go!SetVariable|driver~happy!SetVariable|speed~fast


I didn't see any need to nest the macros.

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: MLConditional Wiki

Postby Art Dustman » Thu May 24, 2012 6:57 pm

This can be further simplified by combining the two conditionals into one
Code: Select allConditional|IsEqual##{{color}}{{sun}}##redcloudy##
Macro|SetVariable|traffic~stopped!SetVariable|driver~sad!SetVariable|speed~slow
##
Macro|Setvariable|traffic~go!SetVariable|driver~happy!SetVariable|speed~fast


1. Are you saying that I can search muliple variables for multiple strings at once as a "contains?'"

2. Since you are stringing together multiple macros, wouldn't this: Macro|Setvariable|traffic~go!SetVariable|driver~happy!SetVariable|speed~fast
.. be this Macro|Setvariable|traffic~go!SetVariable|driver~happy!!SetVariable|speed~fast (macro-one!macro-2!!macro-3!!!Macro-4)

Art Dustman
Expert
Expert
Posts: 576
Joined: Fri Nov 10, 2006 3:22 pm
Location: NJ
Contact:

Re: MLConditional Wiki

Postby Art Dustman » Wed May 30, 2012 7:31 am

Ok. Nevermind. I see why you did that. Just needed to "go away" for a day and look at it again.


Return to “MainLobby 3 Client”

Who is online

Users browsing this forum: No registered users and 2 guests