Problem with UDF
Posted: Sun Jul 11, 2010 2:02 pm
OK, so I have UDF that just doesn't want to work... not sure why, I am sure I'm missing something easy, but can't figure it out...
When trying to run the function [r: getabilitymodifier(18)] I get this-
java.lang.NullPointerException error executing expression getabilitymodifier(18).
Ok, so I thought, lets put quotes around the data being passed, can't hurt, right? I get this-
java.lang.NullPointerException error executing expression getabilitymodifier("18").
So next I want to make sure I am defined, and to my surprise I, when I run [r: isFunctionDefined("getAbilityModifier")] it returns- 2
Now, isn't that what is supposed to be returned if it is a built-in MapTool function? So I change the name of the function, and reload the campaign, get the same thing...
If I manually run the macro [macro("get_AbilityModifier@Lib:Charts"):"18"] [r: macro.return] I get what I expect to see, a result of 3.
I have a second function with the same issue, both of these are passing numeric arguments. A third that I have defined works fine, but it is passing a JSON string. What am I doing wrong here?
Here is the code of the macro:
Note with this I also have tried [h: abilityScore=number(macro.args)] to no avail.
An here is the onCampaignLoad where it is defined:
When trying to run the function [r: getabilitymodifier(18)] I get this-
java.lang.NullPointerException error executing expression getabilitymodifier(18).
Ok, so I thought, lets put quotes around the data being passed, can't hurt, right? I get this-
java.lang.NullPointerException error executing expression getabilitymodifier("18").
So next I want to make sure I am defined, and to my surprise I, when I run [r: isFunctionDefined("getAbilityModifier")] it returns- 2
Now, isn't that what is supposed to be returned if it is a built-in MapTool function? So I change the name of the function, and reload the campaign, get the same thing...
If I manually run the macro [macro("get_AbilityModifier@Lib:Charts"):"18"] [r: macro.return] I get what I expect to see, a result of 3.
I have a second function with the same issue, both of these are passing numeric arguments. A third that I have defined works fine, but it is passing a JSON string. What am I doing wrong here?
Here is the code of the macro:
Code: Select all
[h: abilityScore=macro.args]
[h: abilMod=json.get(getLibProperty("abilityModifiers","Lib:Charts"), abilityScore)]
[macro.return=abilMod]
An here is the onCampaignLoad where it is defined:
Code: Select all
[h: defineFunction("getAbilityModifier", "get_AbilityModifier@Lib:Charts")]