setSize: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Removed note about error for free size / native size tokens. Fixed.)
No edit summary
 
(11 intermediate revisions by 5 users not shown)
Line 4: Line 4:
|version=1.3b48
|version=1.3b48
|description=
|description=
Sets the [[Size]] of a [[Token]].
Sets the size of a [[Token]] with one of the defined sizes according to each Grid Type. {{Note|The names of each size are based on the type of grid the map uses. The sizes can be found on the [[Token Size]] page.}} "Free" or "Native" are also valid values.
 
==Grid Sizes and Scales==
 
The valid sizes for each type of grid are documented below, where '''Medium''' is always 1 full grid cell.  The '''Scale''' is a multiplier for the size of the image after configuring it to fit within the stated footprint. For example, the {{code|Huge}} size on a square grid occupies a 3x3 cell area and the image is scaled ('''1.0''') to exactly fit that area.  But the {{code|Large}} size on a hex grid is 3 hexes scaled down 10% ('''0.9''') so as to keep the image slightly within the border of the 3 cells.
 
<table class="wikitable" border="1" style="border-collapse: collapse; float: left; margin-right: 2em">
<tr style="background-color:#e0ddd5"><th>Hex Grid</th><th>Scale</th></tr>
<tr><td>{{code|1/6}}</td><td>0.408</td></tr>
<tr><td>{{code|1/4}}</td><td>0.5</td></tr>
<tr><td>{{code|1/3}}</td><td>0.577</td></tr>
<tr><td>{{code|1/2}}</td><td>0.707</td></tr>
<tr><td>{{code|2/3}}</td><td>0.816</td></tr>
<tr><td>{{code|Medium}}</td><td>1.0</td></tr>
<tr><td>{{code|Large}}</td><td>0.9 (3 cells)</td></tr>
<tr><td>{{code|Huge}}</td><td>1.0 (6 cells)</td></tr>
<tr><td>{{code|Humongous}}</td><td>1.0 (19 cells)</td></tr>
</table>
 
<table class="wikitable" border="1" style="border-collapse: collapse">
<tr style="background-color:#e0ddd5"><th>Square Grid</th><th>Scale</th></tr>
<tr><td>{{code|Fine}}<td>0.5</td></tr>
<tr><td>{{code|Diminutive}}<td>0.5</td></tr>
<tr><td>{{code|Tiny}}<td>0.5</td></tr>
<tr><td>{{code|Small}}<td>0.75</td></tr>
<tr><td>{{code|Medium}}<td>1.0</td></tr>
<tr><td>{{code|Large}}<td>1.0 (2x2)</td></tr>
<tr><td>{{code|Huge}}<td>1.0 (3x3)</td></tr>
<tr><td>{{code|Gargantuan}}<td>1.0 (4x4)</td></tr>
<tr><td>{{code|Colossal}}<td>1.0 (6x6)</td></tr>
</table>
 
<br clear="clear" />
 
<table class="wikitable" border="1" style="border-collapse: collapse; margin-top: 1em">
<tr style="background-color:#e0ddd5"><th>Gridless</th><th>Scale</th><th>Gridless</th><th>Scale</th><th>Gridless</th><th>Scale</th></tr>
<tr><td>{{code|-11}} <td>0.086 </td><td>{{code|0}} </td><td>1.0  </td><td>{{code|11}} <td>7.43</td></tr>
<tr><td>{{code|-10}} <td>0.107 </td><td>{{code|1}} </td><td>1.2  </td><td>{{code|12}} <td>8.916</td></tr>
<tr><td>{{code|-9}} <td>0.134  </td><td>{{code|2}} </td><td>1.44  </td><td>{{code|13}} <td>10.699</td></tr>
<tr><td>{{code|-8}} <td>0.168  </td><td>{{code|3}} </td><td>1.728 </td><td>{{code|14}} <td>12.839</td></tr>
<tr><td>{{code|-7}} <td>0.21  </td><td>{{code|4}} </td><td>2.074 </td><td>{{code|15}} <td>15.407</td></tr>
<tr><td>{{code|-6}} <td>0.262  </td><td>{{code|5}} </td><td>2.488 </td><td>{{code|16}} <td>18.488</td></tr>
<tr><td>{{code|-5}} <td>0.328  </td><td>{{code|6}} </td><td>2.986 </td><td>{{code|17}} <td>22.186</td></tr>
<tr><td>{{code|-4}} <td>0.41  </td><td>{{code|7}} </td><td>3.583 </td><td>{{code|18}} <td>26.623</td></tr>
<tr><td>{{code|-3}} <td>0.512  </td><td>{{code|8}} </td><td>4.3  </td><td>{{code|19}} <td>31.948</td></tr>
<tr><td>{{code|-2}} <td>0.64  </td><td>{{code|9}} </td><td>5.16  </td><td>{{code|20}} <td>38.338</td></tr>
<tr><td>{{code|-1}} <td>0.8    </td><td>{{code|10}} </td><td>6.192</td><td colspan="2"></td></tr>
</table>
 
{{Clarify|It would be nice to include pictures that demonstrate how the grid cells are composed; at least for the hex grids.}}


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
setSize(size)
setSize(size)
</source>
<source lang="mtmacro" line>
setSize(size, id)
setSize(size, id)
</source>
setSize(size, id, mapRef)
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|size|The [[Size]] to set the token to.}}
{{param|size|A [[Token Size]] to set the token to. Can be "Free" or "Native" as well.}}
{{param|id|The token {{code|id}} of the token which has its [[Size]] set, defaults to the [[Current Token]].}}
{{param|id|The token {{code|id}} of the token which will have its [[Token Size]] set. Defaults to the [[Current Token]].}}
{{param|mapRef|The Name or ID of the map to find the token.  Defaults to the current map.}}
 
The sizes available on the for Square grid maps are:
* {{code|Fine}}
* {{code|Diminutive}}
* {{code|Tiny}}
* {{code|Small}}
* {{code|Medium}}
* {{code|Large}}
* {{code|Huge}}
* {{code|Gargantuan}}
* {{code|Colossal}}
&nbsp;


|examples=
|examples=
To set the size of the current token to {{code|Medium}}:
To set the size of the current token to {{code|Medium}}:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: setSize("Medium")]
[h: setSize("Medium")]
</source>
</syntaxhighlight>


To set the size of the current token to whatever string is stored in the macro variable '''mySize''':
To set the size of the current token to whatever string is stored in the macro variable '''mySize''':
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: mySize = "Large"]
[h: mySize = "Large"]
[h: setSize(mySize)]
[h: setSize(mySize)]
</source>
</syntaxhighlight>


|also=
|also=
{{func|getSize}}
{{func|getSize}} [[resetSize|resetSize()]]


|changes=
|changes=
{{change|1.3b51|Added {{code|id}} parameter option.}}
{{change|1.3b51|Added {{code|id}} parameter option.}}
{{change|1.5.4|Added {{code|mapname}} parameter option.}}


}}
}}
[[Category:Token Function]]
[[Category:Token Function]]

Latest revision as of 23:59, 16 April 2024

setSize() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.3b48
Sets the size of a Token with one of the defined sizes according to each Grid Type.
The names of each size are based on the type of grid the map uses. The sizes can be found on the Token Size page.
"Free" or "Native" are also valid values.

Usage

setSize(size)
setSize(size, id)
setSize(size, id, mapRef)

Parameters

  • size - A Token Size to set the token to. Can be "Free" or "Native" as well.
  • id - The token id of the token which will have its Token Size set. Defaults to the Current Token.
  • mapRef - The Name or ID of the map to find the token. Defaults to the current map.

The sizes available on the for Square grid maps are:

  • Fine
  • Diminutive
  • Tiny
  • Small
  • Medium
  • Large
  • Huge
  • Gargantuan
  • Colossal

 

Examples

To set the size of the current token to Medium:
[h: setSize("Medium")]

To set the size of the current token to whatever string is stored in the macro variable mySize:

[h: mySize = "Large"]
[h: setSize(mySize)]

See Also

Version Changes

  • 1.3b51 - Added id parameter option.
  • 1.5.4 - Added mapname parameter option.