function chat_catch(tar,nick,text) --print("chat_catch called") local words = explode(" ",text) if string.find(words[1],".calc") then local str = "" local ostr = "" for i=2,table.getn(words) do ostr = ostr..words[i].." " if findInKeys(math,words[i]) and not string.find(words[i],"pi") then if not words[i+1] then str = str..words[i].."()" else words[i+1] = words[i+1]..")" str = str..words[i].."(" end else str = str..words[i].." " end end str = string.lower(str) str = string.gsub(str,"pi","math.pi") local str = "function magic() return "..str.." end" print("Trying: "..str) str = string.gsub(str,"x","*") local f = loadstring(str) if not f then --privmsg(tar,ostr.." is not a valid string") else f() if not magic then return end res = magic();magic = nil end if not res or type(res) ~= "number" then return elseif type(res) == "boolean" then if res == true then privmsg(tar,ostr.."is true") else privmsg(tar,ostr.."is false") end end privmsg(tar,ostr.."= "..res) endend