• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

2 simples function

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

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:
Back
Top