PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Str?m@p?gen? on 22 October, 2003, 23:19:58

Title: Convertscript
Post by: Str?m@p?gen? on 22 October, 2003, 23:19:58
Hi!
I?am looking for a script thats convert swedish money to  euro, dollar, pund, danish, and so on. anybody know such a scrip? or can make on?

 
Title:
Post by: Optimus on 22 October, 2003, 23:32:56
hi me want 1 that makes gold :]

but if you really do want 1 go ahead maybe some 1 is kind enough to make you 1

;)
Title:
Post by: pHaTTy on 22 October, 2003, 23:44:53
sorry :(  i wud have liked to try this one, but i have not time as i have to install my linux partitions agen, setup all devices, and lotsa other stuff b4 i erase windows full stop :)

but if i do get a little time i will give it a shot

btw you will probably have to give me the change ratio
Title:
Post by: servaks on 23 October, 2003, 12:46:36
Ratio +/- cahnges every day...

/shipis
Title:
Post by: pHaTTy on 23 October, 2003, 12:51:50
well average wud do until i made a backbone for the script, so it can be changed
Title:
Post by: Str?m@p?gen? on 25 October, 2003, 19:27:41
here is a site http://www.forex.se/ where u an the latest curancy
Title:
Post by: tezlo on 26 October, 2003, 07:28:05
rates = dofile("rates.dat") or {}

function save()
local f = openfile("rates.dat", "w+")
write(f, "rates = {\n")
for currency, rate in rates do
write(f, "\t"..format("[%q]", currency).." = "..rate..",\n")
end write(f, "}") closefile(f)
end

function DataArrival(user, data)
if strsub(data, 1, 1) ~= "<" then return end
local s, e, cmd, args = strfind(data, "^%b<> %!(%S*)%s*(.*)|$")
if s then
cmd = strlower(cmd)
if cmd == "rconv" then
local s, e, currency, amount = strfind(args, "^(%a+)%s*(%d*)$")
if not s then user:SendData(">> syntax: !rconv [amount]") return 1 end
local rate = rates[currency]
if not rate then user:SendData(">> unknown currency") return 1 end
amount = tonumber(amount)
if amount and amount ~= 1 then currency = currency.."s" else amount = 1 end
user:SendData(">> "..amount.." "..currency.." = "..rate*amount.." kronen or whatever")
elseif cmd == "rset" then
if not user.bOperator then user:SendData(">> you cant change conversion rates") return 1 end
local s, e, currency, value = strfind(args, "^(%a+) ([%d%.]+)$")
if not s then user:SendData(">> syntax: !rset ") return 1 end
user:SendData(">> 1 "..currency.." = "..value.." kronen or whatever")
rates[currency] = tonumber(value) save()
else return
end return 1
end
end -- tezlo

OPs can !rset
anyone can !rconv [amount]