Convert Sting

Aquí podrás hablar de cualquier tema que no tenga un sección específica.
Hi Everyone,
How to convert a sting 01:20 to normal string 10-20-30-90-100...
string = "01:20" --- convert to 80
format = string.format("%02.f", Math.Floor(string)));

pls help me :(

Do you mean convert "hours into integers" or something like that?

If this is the case, I made a function in almost pure lua code for a few weeks.

Here you go:
function HoursToInteger(nH)
	t = {};
	if (#nH >= 1) then
		n = 0;
		for k, v in string.gmatch(nH, "*-(%d+)") do
			n = n + 1;
			t[n] = k;
		end
		if (t ~= nil and table.maxn(t) == 3) then
			nHours = t[1] * 60;
			nMins = t[2] * 60 / 60;
			if (tonumber(t[3]) > 30) then
				nSecs = Math.Round(t[3] * 60 / 3600, 0);
			else
				nSecs = 0;
			end
		elseif (t ~= nil and table.maxn(t) == 2) then
			nHours = t[1] * 60;
			nMins = t[2] * 60 / 60;
			nSecs = 0;
		elseif (t ~= nil and table.maxn(t) == 1) then
			nHours = t[1] * 60;
			nMins = 0;
			nSecs = 0;
		else
			nHours = 0;
			nMins = 0;
			nSecs = 0;
		end
		return (nHours + nMins + nSecs);
	end
end
How do it works?

Put this function in the Global Functions code area, to call it just put, for example, in a button:
Input.SetText("Input2", HoursToInteger(Input.GetText("Input1")));
Of course you'll need two inputs, "input and output".

If you know something about lua then you'll know this code can be improved a lot.

Did this helps to you? Then we wait for your examples. Otherwise...

Regards.

By the way... I wait for your feedback.

works perfect Metafunken big thans :num1:

You're welcome, glad to help you. ;)

I forgot, this function can find all the delimiters within the string, including blanks. try it.

ohhhh awesome Metafunken :pc: tested 01:20 and 01 20 and 01.20 works perfect :num1: can be toz way 0120 or 0230 = 01:20 and 02:30

Not awesome, just analize the regex implemented in the string.gmatch() function, but thanks.

If you want 0120 as a result, then you must change the "return" with a, for example, "string.format()" function or simply just concatenate it, don't forget the zero in case of concatenate them.

As for the other, if you want to input 0120 and get the result as 01:20, must "reverse" my function, but in this case you must "insert" the delimiter.

If you have any doubt just post your code to get more help, if not me, maybe another one can helps you.

We need to participate!

Regards.

thanks for the help Metafunken ;)