Quantcast
Channel: Questions in topic: "parser"
Viewing all articles
Browse latest Browse all 108

Strange issue with the B83 expression parser

$
0
0
I'm using the wonderful Expression Parser created by @Bunny83 as-is with no modifications (yet): http://wiki.unity3d.com/index.php/ExpressionParser What I'm trying to do is set it up so that the parser can take variables from within my code, for example, the power of a weapon or ability. This should be possible with the AddConst() function. However, I must be misunderstanding something here. See below: ExpressionParser fParser = new ExpressionParser(); fParser.AddConst("effectPower", () => 42); fParser.AddConst("meaningOfLife", () => 42); string test = "meaningOfLife + rnd(1,4)"; float value = (float)fParser.Evaluate(test); In the test case shown above, "value" evaluates to 42 plus 1-4. Correct, and makes sense. But if I change the evaluation string to use "effectPower" instead... string test = "effectPower + rnd(1,4)"; The effectPower constant is ignored / evaluated as 0. I don't understand why or how this could happen. Is there something with constants that I'm missing? Of course the end goal is to actually set the value of the constant "effectPower" to something else entirely, but for now, for the sake of testing, I set it to an actual simple constant... and it still evaluates as 0! Any advice appreciated... thanks in advance!

Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>