]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/math.rb
plugin(points): new message parser, see #34
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / math.rb
index 081c9c042378cf761c5670e5df82dc34df3f6238..a6baa7090bb014b737776abbbd85d49906fb41b0 100644 (file)
@@ -39,6 +39,11 @@ class MathPlugin < Plugin
       expr.gsub!(/\b#{k}\b/, v)
     }
 
+    # ruby doesn't like floating-point values without a 0
+    # in front of them, so find any non-digit followed by
+    # a .<digits> and insert a 0 before the .
+    expr.gsub!(/(\D|^)(\.\d+)/,'\10\2')
+
     while expr =~ /(exp ([\w\d]+))/
       exp = $1
       val = Math.exp($2).to_s