How to convert decimals to integers
I wanted to follow up with a slight work-around for the problem I explained above:
Quote:
While the "Top" "Height" "Left" and "Width" do not support trailing decimals, the comma delimited (IE: Location, MinimumScrollExtent) values will. It will trim off the decimals automatically. I forget where I first saw this mentioned, but I tried it for myself in the UIBuilder a while ago. Code:
Parent.Parent.Parent.Parent.Select.MinimumScrollExtent=('146' ## ',' ## SUM) SUM=(Parent.Parent.SETTINGS.SizeCollection) + (Parent.Parent.SETTINGS.SizeTotal) |
Quote:
Strange thing is I could have sworn I had unsuccessfully tried assigning floating point values to both location and size, in particular location, because I wanted to automatically align elements. Maybe it's because you used a variable and I probably didn't, or because you used brackets? Or maybe this was recently changed. Anyway, take these: :nana::nana::nana::nana::nana::nana::nana::nana::nana: |
Well it worked about 20+ times in the Info Center :)
Just thinking about it more in my head... You could use dummy pages and do just about any mathematical equation and set it into the page's location (or whichever). This would then update the "Top", etc values which could then be easily used anywhere else in the UI. Now I can update my Resist average value with a real, non-floating decimal, number. |
Exactly, that's what you got the nanas for. ;)
|
Ohhh.
Float -> Int has been like the holy grail. You sir do indeed deserve 'nanas and more. I dub thee Drumstix42, Lord of Floating Integers! ;) |
Quote:
|
It creates beautiful INTEGERS out of the ugly and mean numbers having a decimal point that every scripted mathematical outputs, and we want integers since no UI element (except those that Drumstix discovered) accepts non-integer numbers as values (unless it's as text of course).
|
Quote:
|
Well you don't, that's the whole point, but previously we had no way to obtain integers, since every mathematical operation in eq2 ui scripting adds a decimal point.
|
Quote:
|
You don't, you want integers.
But if I do 5+6 the game gives 11.0 (a float) and then if I try to put that in somewhere it gets upset because it only wants to take intergers and not floats. But with this you can put in a float which will be converted to an integer and then can be read and put into those fields that only take integers. |
Maybe an example helps.
A=1If you do C=A+Byou end up with C=4.0000Now if you do Location=C,Dyou get Location=4,2which equals Left=4Tada, you have your integers and can assign them to something else, eg IconSize=LeftThis allows you to assign the output of the mathematical operation A+B to, for example, IconSize, which you cannot do directly because of the decimal point. |
I get it. That's going to be really helpful Drums.
Nice work....lol and thanks for explaining it to me. |
It works well.
I used it in my recent Persona window upload for the Average resist value. Feel free to split these posts into maybe a sticky for future reference. |
Hehe, I had hoped this would work when I saw the post from SOE about adding the seperated size and location atributes. The comma seperated values have delt with float all along, the problem was getting the converted number out of the comma string ;)
FYI there are some controls that expect float, progress bars for example. |
You are right Zonx, I actually went through an old project of mine that has lots of dummy windows to save arbitrary values and it used that property of the size attribute as well. In that case I was using it to cut of the part after a comman in another size attribute. Say you have SizeA=100,20 and SizeB=200,30 then SizeC=SizeA,SizeB will be => SizeC=100,200. The things you forget...
|
All times are GMT -5. The time now is 10:49 AM. |
vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI