Changeset 946
- Timestamp:
- 07/07/2008 06:15:04 (5 months ago)
- Files:
-
- 1 modified
-
trunk/plugins/en/complex_calculator.tcl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/en/complex_calculator.tcl
r936 r946 12 12 13 13 # name regexp chance callback 14 bMotion_plugin_add_complex "calculator" {what('s| is) (\(*\s*[0-9.]+(\s* [+/*x%-]\s*\(*\s*[0-9.]+\s*\)*)+\s*\)*)} 100 "bMotion_plugin_complex_calculator" "en"14 bMotion_plugin_add_complex "calculator" {what('s| is) (\(*\s*[0-9.]+(\s*([+/*x%-]|\*\*)\s*\(*\s*[0-9.]+\s*\)*)+\s*\)*)} 100 "bMotion_plugin_complex_calculator" "en" 15 15 16 16 bMotion_plugin_add_complex "calculator2" {what('s| is) the diff(erence)? between (.+ )?\d+,? and (.+ )?\d+} 100 "bMotion_plugin_complex_calculator2" "en" … … 21 21 proc bMotion_plugin_complex_calculator { nick host handle channel text } { 22 22 if {[bMotionTalkingToMe $text] || [bMotion_interbot_me_next $channel]} { 23 if [regexp -nocase {(\(*\s*[0-9.]+(\s* [+/*x%-]\s*\(*\s*[0-9.]+\s*\)*)+\s*\)*)} $text matches sum] {23 if [regexp -nocase {(\(*\s*[0-9.]+(\s*([+/*x%-]|\*\*)\s*\(*\s*[0-9.]+\s*\)*)+\s*\)*)} $text matches sum] { 24 24 set sum [string map { x * } $sum] 25 25 set sum [string trim $sum] 26 26 set result "failed" 27 28 # TCL < 8.5 doesn't know **, so we have to use pow() 29 if {[info pa] < 8.5} { 30 if [regexp {\*\*} $sum] { 31 bMotion_putloglev d * "calculator: rewriting $sum using pow()" 32 regsub -all {([0-9]+)\s*\*\*\s*([0-9]+)} $sum {pow(\1,\2)} sum 33 bMotion_putloglev d * "calculator: new expr is $sum" 34 } 35 } 36 27 37 catch { 28 38 set result [expr $sum] … … 53 63 54 64 bMotion_abstract_register "calculation_output" { 65 "for this problem, i'll need to set my calculator to 'maths'%|%2" 66 "%2%|write that down in your copybooks now" 55 67 "%% = %2" 56 68 "%% is %2"
