marcryzius
New Member
- Joined
- Mar 22, 2009
- Messages
- 61
- Reaction score
- 0
this function is an alternative to using the function tonumber().
transforms a 'string' to 'numbers'.
the other returns all the elements
Ex:
this;
to;
edited:
exclusive to otland do not let that put on another site
transforms a 'string' to 'numbers'.
the other returns all the elements
Lua:
function getnumber(n) --[[> Marcryzius <]]--
local v = 0
if type(n) == 'number' then return n end
for s = 1,#n do
for N = 0,9 do
if ''..N == n:sub(s,s) then
v = (v+N)*10
end
end
end
return v/10
end
function tonumber(...) --[[> Marcryzius <]]--
local tab = {}
for k,n in ipairs({...}) do
tab[k] = getnumber(n)
end
return unpack(tab)
end
Ex:
this;
local a,b = '1525',235
local c,d = tonumber(a),tonumber(b)
print(c,d)
to;
local a,b = '1525',235
local c,d = tonumber(a,b)
print(c,d)
edited:
exclusive to otland do not let that put on another site
Last edited: