Macro Output Artifacts

Doc requests, organization, and submissions

Moderators: Azhrei, dorpond, trevor

Post Reply
Templar
Cave Troll
Posts: 39
Joined: Wed Sep 20, 2017 9:24 pm

Macro Output Artifacts

Post by Templar »

Hi,

I get some weird artifacts in my output for some of my macros.
We use our own custom system where Primary weapon, Secondary Weapon and Missile Weapon each have there own Init roll.
The Macros work perfectly but:

The first example below always has these 3 '' '' '' at the end of the output.

The second example works perfectly if its the Npcs init but if not it gets one ".
I would rather it produced no output at all.

Example 1
============================================================
[h:x=input(
"Weapon | Primary, Secondary, Missile, All | Pick the weapon for this Init Roll | RADIO | ORIENT=V SELECT=0"
)]
[h: abort(x)]
[if(Weapon == 0), Code:{

[h: PInit = initiative]
[h: Init = "{PInit}"]
<b>Primary Init set to: [r: PInit]</b> }]

[if(Weapon == 1), Code:{
[h: SInit = initiative]
[h: Init = "{SInit}"]
<b>Secondary Init set to: [r: SInit]</b> }]

[if(Weapon == 2), Code:{
[h: MInit = initiative]
[h: Init = "{MInit}"]
<b>Missile Init set to: [r: MInit]</b>}]

[if(Weapon == 3), Code:{
[h: PInit = initiative]
[h: SInit = PInit]
[h: MInit = PInit]
[h: Init = "{PInit}"]
<b>All Init set to: [r: PInit]</b>}]
-----------------------------------------------
Output looks like this:
Colin: Primary Init set to: 1 '' '' ''
=============================================================

Example 2
=============================================================

[h: CurrentToken = nextInitiative()]
[h: jsonInit = getInitiativeList()]
[h: AllTokenArray = json.get(jsonInit, "tokens")]
[h: Token_ID = json.get(json.get(AllTokenArray, CurrentToken), "tokenId")]
[h: CurrentTokenName = getName( Token_ID)]

[h: SelectedTokens = getSelectedNames()]
[h: deselectTokens(SelectedTokens, ",")]
[h: selectTokens(Token_ID, 1)]

[h: TokenInit = getProperty("Init", Token_ID)]
[h: WeaponSpeed = getProperty("PWeaponSpeed", Token_ID)]
[h: DBonus = getProperty("DexBonus", Token_ID)]

[h: WSpeed = TokenInit + WeaponSpeed]
[h: React = 9 - DBonus]
[h: InitRoll = eval("D" + React)]
[h: NewInit = WSpeed + InitRoll]
[h: CurrentCount = getInitiativeRound()]

[If(TokenInit == CurrentCount), CODE:{
[h: setProperty("PInit", NewInit, Token_ID)]
<b>Current Count: </b>[r: CurrentCount]<br>
<hr/>
<b>[r: CurrentTokenName]: Init = [r: TokenInit] GO-GO-GO</b><br>
<b>Recovery: </b>[r: WSpeed]<br>
<b>Reaction: </b>[r: React]<br>
<b>Init Roll: </b>[r: InitRoll]<br>
<b>New Initiative: </b>[r: NewInit]<br>
<hr/>
}]
-----------------------------------------------
Output looks like this:

Colin: ''
=============================================================

User avatar
jackolas
Cave Troll
Posts: 28
Joined: Tue Apr 16, 2013 8:19 am
Location: Netherlands
Contact:

Re: Macro Output Artifacts

Post by jackolas »

Your IF statement are not complete, they require an else. most simple is to add ;{} to the end of them

[spoiler=example 1]

Code: Select all

[h:x=input(
"Weapon | Primary, Secondary, Missile, All | Pick the weapon for this Init Roll | RADIO | ORIENT=V SELECT=0"
)]
[h: abort(x)]
[if(Weapon == 0), Code:{

[h: PInit = initiative]
[h: Init = "{PInit}"]
<b>Primary Init set to: [r: PInit]</b> };{}]

[if(Weapon == 1), Code:{
[h: SInit = initiative]
[h: Init = "{SInit}"]
<b>Secondary Init set to: [r: SInit]</b> };{}]

[if(Weapon == 2), Code:{
[h: MInit = initiative]
[h: Init = "{MInit}"]
<b>Missile Init set to: [r: MInit]</b>};{}]

[if(Weapon == 3), Code:{
[h: PInit = initiative]
[h: SInit = PInit]
[h: MInit = PInit]
[h: Init = "{PInit}"]
<b>All Init set to: [r: PInit]</b>};{}]
[/spoiler]

[spoiler=Example 2]

Code: Select all

[h: CurrentToken = nextInitiative()]
[h: jsonInit = getInitiativeList()]
[h: AllTokenArray = json.get(jsonInit, "tokens")]
[h: Token_ID = json.get(json.get(AllTokenArray, CurrentToken), "tokenId")]
[h: CurrentTokenName = getName( Token_ID)]

[h: SelectedTokens = getSelectedNames()]
[h: deselectTokens(SelectedTokens, ",")]
[h: selectTokens(Token_ID, 1)]

[h: TokenInit = getProperty("Init", Token_ID)]
[h: WeaponSpeed = getProperty("PWeaponSpeed", Token_ID)]
[h: DBonus = getProperty("DexBonus", Token_ID)]

[h: WSpeed = TokenInit + WeaponSpeed]
[h: React = 9 - DBonus]
[h: InitRoll = eval("D" + React)]
[h: NewInit = WSpeed + InitRoll]
[h: CurrentCount = getInitiativeRound()]

[If(TokenInit == CurrentCount), CODE:{
[h: setProperty("PInit", NewInit, Token_ID)]
<b>Current Count: </b>[r: CurrentCount]<br>
<hr/>
<b>[r: CurrentTokenName]: Init = [r: TokenInit] GO-GO-GO</b><br>
<b>Recovery: </b>[r: WSpeed]<br>
<b>Reaction: </b>[r: React]<br>
<b>Init Roll: </b>[r: InitRoll]<br>
<b>New Initiative: </b>[r: NewInit]<br>
<hr/>
};{}]
[/spoiler]


btw, there is a Macro help section under the Maptools Subforum: viewforum.php?f=20

Templar
Cave Troll
Posts: 39
Joined: Wed Sep 20, 2017 9:24 pm

Re: Macro Output Artifacts

Post by Templar »

Perfect. I appreciate it.

Post Reply

Return to “Documentation Requests/Discussion”