wolph42 wrote:- did you try to run isPropertyEmpty directly (and isolated) on the token? (and did it generate the same error?),
Yes, and no, respectively. It works fine by itself. The other macro works fine without it. But if I try to tie the two together, it errors out.
wolph42 wrote:- what is the context of this macro (from where do you run it)?
Campaign tab, with Apply to Selected Tokens active.
wolph42 wrote:- what error message?
Code: Select all
Error in body of roll.
Statement options (if any): if(isPropertyEmpty("SP") != 1 && SP > 0),CODE
Statement Body : {[h:SP = SP - damageTaken]};{[h:HP = HP - damageTaken]}
wolph42 wrote:EDIT: ah wait... what you do can't work: lets say that SP contains the value "" (or NULL) then in your code you effectively do
if("" > 0): etc.
OR
if(NULL > 0): etc.
which obviously generates an error.
This is why I'm trying to use isPropertyEmpty() instead of just calling the value itself; according to the wiki's documentation, isPropertyEmpty()
should return 1 if the property is null, or 0 if the property is either a blank string or any other value. This is why it's been tripping me up.
wolph42 wrote:I would suggest you initialize the SP value for all tokens and then reduce the statement to:
Code: Select all
[if(SP): SP = max(0, SP - damageTaken) ; HP = HP - damageTaken]
unless you can have negative shieldpoints (which it certainly looks like) in which can you need to do
Code: Select all
[if(SP>0): SP = SP - damageTaken ; HP = HP - damageTaken]
This is basically the solution I'm running with at the moment, but it seems a little ugly as a workaround given the function I'm trying to use doesn't work as advertized.
Ed: I guess the point of the problem is that it seems to me that it shouldn't be too hard to check if a target has a shield value at all, and if it's above 0, then to apply damage to shields -- and if not, then to apply damage to health instead -- without having to do a workaround by having the default value for shields always be 0.