- By Mock
- Tested on TFS 0.3.6
- Beta version
This script is not too much unsefull but is fun and good to have in your server

My wold calculator script you only can calc only this:
Code:
1+1
50-40
100/30
60*25
Code:
50-25/37*(10^1)+67^2-3 [COLOR="White"]= 4529.2432432432[/COLOR]

Well to install add this tag:
Code:
<talkaction log="yes" words="!calc" event="script" value="calc.lua"/>
LUA:
function onSay(cid, words, param, channel) --- Calculator beta by mock
param = param..'€'
local lua = ''
for i,sinal,e in param:gmatch('(%(*%d+%.*%d*%)*)%s*([+-/%*^%%])') do
lua = lua ..i..sinal
end
if param:match('.+%s*(%([-]*%d+%)*)€') then
lua = lua..param:match('.+%s*(%([-]*%d+%)*)€')
elseif param:match('.+%s*(%(*[-]%d+%.*%d*%)*)€') then
if lua:sub(lua:len(),lua:len()) ~= '-' then
lua = lua..param:match('%l*(%(*[-]%d+%.*%d*%)*)€')
else
lua = lua..param:match('%l*(%(*%d+%.*%d*%)*)€')
end
elseif param:match('%l*(%(*[-]*%d+%.*%d*%)*)€') then
lua = lua..param:match('%l*(%(*[-]*%d+%)*)€')
end
if lua == '' then
doPlayerSendTextMessage(cid,25,'Command ['..param..'] invalid.')
return true
end
local f,e = loadstring('return '..lua) -- wop but dont spent 50 lines
if not f and e then
doPlayerSendTextMessage(cid,25,'Command ['..lua..'] invalid.')
return true
end
local f,e = pcall(f)
if not f and e then
doPlayerSendTextMessage(cid,25,'Command ['..lua..'] invalid.')
return true
end
doCreatureSay(cid,'Calc: '..lua..' = '..tostring(e),1)
return true
end
unfortunately lua patterns is not powerfull and i got some problems with script and some calcs you cant execute because some bugs