RPTools.net

Discussion and Support

Skip to content

It is currently Thu Oct 19, 2017 10:28 pm 






Reply to topic  [ 3 posts ] 

Previous topic | Next topic 

  Print view

Author Message
 Offline
Kobold
 
Joined: Wed Sep 20, 2017 8:24 pm
Posts: 15
 Post subject: Macro Output Artifacts
PostPosted: Mon Sep 25, 2017 6:08 pm 
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: ''
=============================================================


Top
 Profile  
 
User avatar  Offline
Kobold
 
Joined: Tue Apr 16, 2013 7:19 am
Posts: 23
Location: Netherlands
 Post subject: Re: Macro Output Artifacts
PostPosted: Mon Sep 25, 2017 6:26 pm 
Your IF statement are not complete, they require an else. most simple is to add ;{} to the end of them

Code:
[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>};{}]


Code:
[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/>
};{}]



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

_________________
My own 5th d&d character sheet framework (preview)


Top
 Profile  
 
 Offline
Kobold
 
Joined: Wed Sep 20, 2017 8:24 pm
Posts: 15
 Post subject: Re: Macro Output Artifacts
PostPosted: Mon Sep 25, 2017 7:39 pm 
Perfect. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 3 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman