Macros (MPI)
From Tapestries MUCK
(Difference between revisions)
Line 1: | Line 1: | ||
[[Category:MPI functions]] | [[Category:MPI functions]] | ||
=macros= | =macros= | ||
- | <mpi>{ | + | If the MPI interpreter comes across a function name that it does not recognize, it will look in the _msgmacs/ propdirs down the environment from the trigger object, for a property with the name of the function. |
- | + | ||
+ | If it does find it there, then it takes the value of that property, and substitutes it in for the function as a macro. The arguments to the function replace the {:1} through {:9} markers in the macro definition. | ||
+ | |||
+ | For example, if there were a property set on #0, defined as: | ||
+ | <mpi>_msgmacs/div_rand:{add:{div:{:2},10},{dice:{:1}}}</mpi> | ||
+ | And you had some MPI code that looked like: | ||
+ | <mpi>{div_rand:22,160}</mpi> | ||
+ | Then the macro would expand out to: | ||
+ | <mpi>{add:{div:160,10},{dice:22}}</mpi> | ||
+ | After the macro argment substitution is complete, it is then evaluated. |
Revision as of 13:02, 30 March 2007
macros
If the MPI interpreter comes across a function name that it does not recognize, it will look in the _msgmacs/ propdirs down the environment from the trigger object, for a property with the name of the function.
If it does find it there, then it takes the value of that property, and substitutes it in for the function as a macro. The arguments to the function replace the {:1} through {:9} markers in the macro definition.
For example, if there were a property set on #0, defined as:
_msgmacs/div_rand:{add:{div:{:2},10},{dice:{:1}}}
And you had some MPI code that looked like:
{div_rand:22,160}
Then the macro would expand out to:
{add:{div:160,10},{dice:22}}
After the macro argment substitution is complete, it is then evaluated.