he hecho algunos arreglos al codigo para manejar los espacios vacíos y un bug en los miles
--ES_es number to numeral string
function roll(num)
local out = ""
local numz = {
["0"] = "cero",
["1"] = "uno",
["2"] = "dos",
["3"] = "tres",
["4"] = "cuatro",
["5"] = "cinco",
["6"] = "seis",
["7"] = "siete",
["8"] = "ocho",
["9"] = "nueve",
["10"] = "diez",
["11"] = "once",
["12"] = "doce",
["13"] = "trece",
["14"] = "catorce",
["15"] = "quince",
["16"] = "dieciseis",
["17"] = "diecisiete",
["18"] = "dieciocho",
["19"] = "diecinueve",
["20"] = "veinte",
["30"] = "treinta",
["40"] = "cuarenta",
["50"] = "cincuenta",
["60"] = "sesenta",
["70"] = "setenta",
["80"] = "ochenta",
["90"] = "noventa"
}
if (#num>6 and #num<13) then
nc = #num - 6
n = String.Mid(num, 1, nc)
num = String.Mid(num, nc+1, 6)
if (n=="1") then
out=out.."un millon "
else
result = String.Replace(roll(n), "y uno", "y un", false);
out=out..result.." millones "
end
--out = String.Replace(out, "e y ", "i", false);
end
if (#num==6) then
n = String.Mid(num, 1, 3)
m = String.Mid(num, 1, 1)
ret = roll(n)
if (m~="0") then
out = out..ret.." mil "
num = String.Mid(num, 4, 3)
else
--out = out..ret
num = String.Mid(num, 3, 4)
end
end
if (#num==5) then
n = String.Mid(num, 1, 2)
m = String.Mid(num, 1, 1)
ret = roll(n)
if (m~="0") then
out = out..ret.." mil "
num = String.Mid(num, 3, 3)
else
--out = out..ret
num = String.Mid(num, 2, 4)
end
end
if (#num==4) then
n = String.Mid(num, 1, 1)
if (n~="0") then
if (n~="1") then
out=out..numz[n]
end
out=out.." mil "
end
num = String.Mid(num, 2, 3)
end
if (#num==3) then
if (num=="100") then
out=out.."cien "
else
n = String.Mid(num, 1, 1)
if (n=="1") then
out = out.."ciento "
elseif (n=="5") then
out = out.."quinientos "
elseif (n=="7") then
out = out.."setecientos "
elseif (n=="9") then
out = out.."novecientos "
else
if (n~="0") then
out=out..numz[n].."cientos "
end
end
end
num = String.Mid(num, 2, 2)
end
if (#num==2) then
if (numz[num]~=nil) then
out = out..numz[num]
else
n = String.Mid(num, 1, 1)
if (n=="0") then
n = String.Mid(num, 2, 1)
if (n~="0") then
out = out..numz[n]
end
else
m = String.Mid(num, 2, 1)
out = out..numz[n.."0"].." y "..numz[m]
end
end
num=""
end
if (#num==1) then
out = out..numz[num]
end
return out
end
num = Input.GetText("Input1")
out = roll(num)
out = String.Replace(out, "e y ", "i", false);
out = String.Replace(out, " uno mil ", " un mil ", false);
out = String.Replace(out, " mil ", "mil ", false);
Dialog.Message("",out)
probablemente necesite mas ajustes pero es facil de seguir, simplemente ir descomponiendo recursivamente el numero