User:Verisimilar/Sandbox: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: =How To Use This Template= When creating a new page that displays information about a macro function, this template should be used for uniformity. What follows are instructions on how to ...)
 
No edit summary
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
=How To Use This Template=
==Highlight Test==
When creating a new page that displays information about a macro function, this template should be used for uniformity.  What follows are instructions on how to use this template. You can enter template parameters in any order, but it is suggested that you use the same order as these instructions to assist other editors with easily finding sections that might need updating.
<syntaxhighlight lang="mtmacro" highlight="5" line>
===Begin===
Function outside of the brackets:
'''Required''' - Begin the template:
defineFunction()
<source lang="text" line start=1>
{{MacroFunction
</source>
===Name===
'''Required''' - Name the function:
<source lang="text" line start=2>
|name=exampleFunction
</source>
===Trusted===
Optional - Indicate the function can only be used in a trusted macro:
<source lang="text" line start=3>
|trusted=true
</source>
===Version===
'''Optional''' - Indicate the version of MapTool that this function was introduced:
<source lang="text" line start=4>
|version=1.3b52
</source>
===Compatibility===
'''Optional''' - Indicate the most recent version of MapTool that the syntax on this page is compatible with:
<source lang="text" line start=5>
|compatibility=1.3b52
</source>
===Description===
'''Multi-Line, Optional''' - Describe the function in a general way:
<source lang="text" line start=6>
|description=This is the description of this exampleFunction.
</source>
===Usage===
'''Required''' - Declare the required syntax for use of the function.
<source lang="text" line start=7>
|usage=
</source>
====Usage Block====
'''Repeatable, Optional''' - Uses a subtemplate for each usage block.
=====Block Begin=====
'''Required'''
<source lang="text" line start=8>
{{FunctionUsage
</source>
=====Block Name=====
'''Optional''' - If you wish you provide a name for your usage block:
<source lang="text" line start=9>
|name=Standard Use
</source>
=====Block Description=====
'''Multi-line, Optional''' - Describe your usage block:
<source lang="text" line start=10>
|description=This is the description for the standard use usage block.
</source>
=====Block Syntax=====
'''Required''' - Provide the syntax for the function:
<source lang="text" line start=11>
|syntax=exampleFunction(param1, param2)
</source>
=====Block End=====
'''Required'''
<source lang="text" line start=12>
|syntax=exampleFunction(param1, param2)
</source>
===Examples===
'''Optional''' - Provide examples of different way to use the function.  Removing the 's' from from 'examples' will cause the header to properly display a singular example.
<source lang="text" line start=13>
|examples=
</source>
====Example Block====
'''Repeatable, Optional''' - Uses a subtemplate for each example block. 
=====Block Begin=====
'''Required'''
<source lang="text" line start=14>
{{FunctionExample
</source>
=====Block Name=====
'''Optional'''
<source lang="text" line start=15>
|name=Standard Example
</source>
=====Block Description=====
'''Multi-line, Optional'''
<source lang="text" line start=16>
|description=This is the description for the standard example.
</source>
=====Block Syntax=====
'''Multi-line, Required'''
<source lang="text" line start=17>
|name=Standard Example
</source>
=====Block Return=====
<source lang="text" line start=15>
|name=Standard Example
</source>
=====Block End=====


Function within square brackets:
[assert()]


=Example=
Function within curly brackets:
<source lang="text" line start=34>
{abort(0)}
sdfdsf
 
sdfsdf
Roll options:
sdfsdfs
[h: abort(0)]
</source>
[t: abort(0)]
=Template Source=
[e,if(0): ]
[macro(): ]
[token(): ]
 
Numbers:
 
[h: 1 2 34 567 ]
 
Symbols:
[h: > = ! & / : ; ]
 
Strings:
[h: "This is a double quoted string" ]
[h; "This is a single quoted string" ]
 
</syntaxhighlight>
 
 
==prop macros==
<syntaxhighlight lang="mtmacro" line>
@onCampaignLoad
[defineFunction("get", "get@this")]
 
@get
[h: checkProp = json.contains(getPropertyNames('json'), arg(0))]
[h,assert(checkProp, '<b>ERROR:</b> get("'+arg(0)+'") '+
                    '- That property does not exist.', 0)]
[h, macro.return = getProperty(arg(0))]
 
@onCampaignLoad
[defineFunction("set", "set@this")]
 
@set
[h: checkProp = json.contains(getPropertyNames('json'), arg(0))]
[h,assert(checkProp, '<b>ERROR:</b> set('+arg(0)+', '+arg(1)+') '+
                    '- That property does not exist.', 0)]
[h: setProperty(arg(0), arg(1))]
[h, macro.return = 1]
</syntaxhighlight>

Latest revision as of 17:00, 13 March 2023

Highlight Test

Function outside of the brackets:
defineFunction()

Function within square brackets:
[assert()]

Function within curly brackets:
{abort(0)}

Roll options:
[h: abort(0)]
[t: abort(0)]
[e,if(0): ]
[macro(): ]
[token(): ]

Numbers:

[h: 1 2 34 567 ]

Symbols:
[h: > = ! & / : ; ]

Strings:
[h: "This is a double quoted string" ]
[h; "This is a single quoted string" ]


prop macros

@onCampaignLoad
[defineFunction("get", "get@this")]

@get
[h: checkProp = json.contains(getPropertyNames('json'), arg(0))]
[h,assert(checkProp, '<b>ERROR:</b> get("'+arg(0)+'") '+
                     '- That property does not exist.', 0)]
[h, macro.return = getProperty(arg(0))]

@onCampaignLoad
[defineFunction("set", "set@this")]

@set
[h: checkProp = json.contains(getPropertyNames('json'), arg(0))]
[h,assert(checkProp, '<b>ERROR:</b> set('+arg(0)+', '+arg(1)+') '+
                     '- That property does not exist.', 0)]
[h: setProperty(arg(0), arg(1))]
[h, macro.return = 1]