But my prior uses of if the isPropertyEmpty() function have never ran into this problem when I cleared the properties... Which I am routinely doing.Craig wrote:The token property is blank after you delete it, i.e. "" which is different from empty. If you want to "empty" the property use the resetProperty() function. If you need to check for an empty string use if(XP == "").nwelte1 wrote:Macro is real simple..... [h, if(isPropertyEmpty("XP")): XP="XPC=0; XPN=0"]. I run the macro and it works perfectly. I then delete the contents of the XP property and rerun the macro and the property remains blank
Empty in this case means it has never been set, or has been reset.
MapTool 1.3 Development Build 49
Moderators: dorpond, trevor, Azhrei, Craig
Re: MapTool 1.3 Development Build 49
Re: MapTool 1.3 Development Build 49
Are you sure? Because that I could not explain as the behavior I described has always been the way isPropertyEmpty() works.nwelte1 wrote:But my prior uses of if the isPropertyEmpty() function have never ran into this problem when I cleared the properties... Which I am routinely doing.Craig wrote:
Empty in this case means it has never been set, or has been reset.
Re: MapTool 1.3 Development Build 49
Yes I am sure. I just tested this macro.Craig wrote:Are you sure? Because that I could not explain as the behavior I described has always been the way isPropertyEmpty() works.nwelte1 wrote:But my prior uses of if the isPropertyEmpty() function have never ran into this problem when I cleared the properties... Which I am routinely doing.Craig wrote:
Empty in this case means it has never been set, or has been reset.
Code: Select all
<!--- Set Property with String Properties if empty--->
[h, if(isPropertyEmpty("Modifiers")):Modifiers="Str=0; Con=0; Dex=0; Int=0; Wis=0; Cha=0;"]
<!--- Set individual sting properties--->
[h: Modifiers = setStrProp(Modifiers, "Str",
if( Strength == "",0,
if( Strength ==1,-4,
if( Strength <=3,-3,
if( Strength <=5,-2,
if( Strength <=8,-1,
if( Strength <=12,0,
if( Strength <=15,1,
if( Strength <=17,2,
floor(( Strength -12)/2) )
)
)
)
)
)
)
)
)]
[h: Modifiers = setStrProp(Modifiers, "Dex",
if( Dexterity== "",0,
if( Dexterity ==1,-4,
if( Dexterity <=3,-3,
if( Dexterity <=5,-2,
if( Dexterity <=8,-1,
if( Dexterity <=12,0,
if( Dexterity <=15,1,
if( Dexterity <=17,2,
floor(( Dexterity -12)/2) )
)
)
)
)
)
)
)
)]
[h: Modifiers = setStrProp(Modifiers, "Con",
if( Constitution == "",0,
if( Constitution ==1,-4,
if( Constitution <=3,-3,
if( Constitution <=5,-2,
if( Constitution <=8,-1,
if( Constitution <=12,0,
if( Constitution <=15,1,
if( Constitution <=17,2,
floor(( Constitution -12)/2) )
)
)
)
)
)
)
)
)]
[h: Modifiers = setStrProp(Modifiers, "Int",
if( Intelligence == "",0,
if( Intelligence ==1,-4,
if( Intelligence <=3,-3,
if( Intelligence <=5,-2,
if( Intelligence <=8,-1,
if( Intelligence <=12,0,
if( Intelligence <=15,1,
if( Intelligence <=17,2,
floor(( Intelligence -12)/2) )
)
)
)
)
)
)
)
)]
[h: Modifiers = setStrProp(Modifiers, "Wis",
if( Wisdom == "",0,
if( Wisdom ==1,-4,
if( Wisdom <=3,-3,
if( Wisdom <=5,-2,
if( Wisdom <=8,-1,
if( Wisdom <=12,0,
if( Wisdom <=15,1,
if( Wisdom <=17,2,
floor(( Wisdom -12)/2) )
)
)
)
)
)
)
)
)]
[h: Modifiers = setStrProp(Modifiers, "Cha",
if( Charisma == "",0,
if( Charisma ==1,-4,
if( Charisma <=3,-3,
if( Charisma <=5,-2,
if( Charisma <=8,-1,
if( Charisma <=12,0,
if( Charisma <=15,1,
if( Charisma <=17,2,
floor(( Charisma -12)/2) )
)
)
)
)
)
)
)
)]
Please excuse my code if it is not elegant... I have no idea was constitutes clean coding practices.
Re: MapTool 1.3 Development Build 49
Ahh I see what it is now, after running the above code Modifiers will equal "Str=0; Con=0; Dex=0; Int=0; Wis=0; Cha=0;" if it has never been set before (or has been reset), if it has and been cleared it will not be effected (so it would still be "").nwelte1 wrote: Yes I am sure. I just tested this macro....Code: Select all
<!--- Set Property with String Properties if empty---> [h, if(isPropertyEmpty("Modifiers")):Modifiers="Str=0; Con=0; Dex=0; Int=0; Wis=0; Cha=0;"]
The reason that the rest of your code works is set the properties in the string in the latter ifs.
If you run these two commands
Code: Select all
[setStrProp("Str=0", 1)]
[setStrProp("", 1)]
So while the original test/set was not working as you expect, it did not need to for the rest of the code to produce the correct result. You can try it by removing the line
Code: Select all
[h, if(isPropertyEmpty("Modifiers")):Modifiers="Str=0; Con=0; Dex=0; Int=0; Wis=0; Cha=0;"]