I have a variable, that can either be a string that represents an evaluatable expression ("1d6") or a number (100) depending what is stored in it. Either way, when it is "Executed" it will result in a number. I am having a hard time getting maptool to deal with it if it is a number.
Even when I check to see if it a number first, it still seems to fail, as it seems to need to perform both options of an if function even if it doesn't need to use one of them.
So, how do I get this wo work?
[h:odb=json.get(selattackjson, "Other damage bonus")] (odb can be either a number (100) or a roll to make (1d6))
[h:odb=if(isNumber(odb)==1,odb,eval(odb))]
even with this, I get the same errors as if I try and eval(100) even though I am telling it NOT to eval(100)
Why can I eval() a number, and how can I?
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
-
- Giant
- Posts: 221
- Joined: Mon Apr 11, 2011 8:11 pm
Re: Why can I eval() a number, and how can I?
Common problem. Just add string().
[H: mod = eval(string(modText))]
[H: mod = eval(string(modText))]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Giant
- Posts: 221
- Joined: Mon Apr 11, 2011 8:11 pm