[SOLVED] How to make calculator or more likely how to make calculations

I found some topics on how to make calculator in gdevelop but none of them answered my questions

Where i would wish to create calculator
But my only problem is how to pass operator or is it called modification sign like + - / *
I am thinking i would need to create array and each segment of numbers would be numbers until modification sign is added like + or -

But i have no idea how to make that into dynamic equation i could just type in real time ingame
Instead of making premade equation in events

I did try this

But it ends up with 5
And i can’t type + in number var since it expects number value
Where converting “+” in text var ToNumber() does not give anything

I just made one calculating previous input

Download link (including project file)

It’s really nice looking. Not to detract because I love it but…

Real large numbers don’t fit. It wouldn’t be an issue except for the dreaded floating point error issue.

Also, the 2nd number can’t start with a decimal. You need to type a number (like 0) first

1 Like

Make long output either in top text or bottom text
And try pressing it on the left side and right

About decimal
I just did not allow to any input start with dot
So i assumed ppl who would press dot on empty input
Would need to now delete dot and 0 which would be created left from dot

But now i think about it maybe it would not be so bad idea to place automatically 0. if current input is empty and dot is pressed

1 Like

Ok papu zero did ran some tests
And i made it this way cause if it starts with dot result will be NaN
So it needs to be 0. at least
And i did it link is updated you can try it
Pressing . with empty or - input will result in 0. and -0. respectively
While if current input is empty or 0 or - or 0. or -0.
It will not give any result if there was not any calculation made before () so this is 2nd number you ever input
AND also it will not affect result after at least any calculation was made

BTW check this out

Do not ask

SubStr(Calc.Output.Text,StrLength(Calc.Output.Text)-ToNumber(SubStr(Calc.Output.Length,StrFindLast(Calc.Output.Length,".")+1,StrLength(Calc.Output.Length)-StrFindLast(Calc.Output.Length,".")-1)),ToNumber(SubStr(Calc.Output.Length,StrFindLast(Calc.Output.Length,".")+1,StrLength(Calc.Output.Length)-StrFindLast(Calc.Output.Length,".")-1)))

Just try to figure out what this wall of text is trying to do
I picked worst possible route because i did not think ahead

F me hard

1 Like

So now we have arrows

I fixed some issues with that decimal
Now seems everything is ok i can’t find anymore bugs
And time to end this anyway since its becoming spam

But i just wanna say THX Keith cause now starting your input by pressing dot to follow up with decimal seems like natural thing to have

Also it is obvious to me that text is movable
So even it was possible it was not obvious for you (so same would be for others) to at least try to click/touch it

1 Like