EQ2Interface

EQ2Interface (https://www.eq2interface.com/forums/index.php)
-   XML Modification Help & Info (https://www.eq2interface.com/forums/forumdisplay.php?f=22)
-   -   How to convert decimals to integers (https://www.eq2interface.com/forums/showthread.php?t=10472)

Drumstix42 02-26-2008 02:47 PM

How to convert decimals to integers
 
I wanted to follow up with a slight work-around for the problem I explained above:

Quote:

Originally Posted by Drumstix42 (Post 66596)
With the new "Top" "Height" "Left" and "Width" values, I've been messing around with some trigger events to try to change the size of other objects.
The problem is if I try to do any math, I'll get the 3 trailing decimals, ie 147.000
I tried manually putting in 147.000 into the "Height" property, and it wouldn't accept it. It just kept the previous value in there.

I guess my request is that these fields be updated to accept decimal inputs, and just trim off the trailing decimals.

*edit* My work around was to just set a nonvisable object the same size as the original, with the same pack size/location properties. (I'm changeing the size of a frame depending on certain conditions). This way I could change the size back and forth, without doing the simple math equations.

I've used my solution in my Info Center, because I needed to use simple math to properly display my drop-down list in the tree-view. I have to add several values together to position them correctly when each expands/collapses. I also had to change the scroll length each time.

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)
Parent.Parent.HQ.Location=('0' ## ',' ## ADD) ADD=(Parent.Parent.Collection.Top) + (Parent.Parent.Collection.Height)

Hope this helps.

gm9 02-26-2008 02:57 PM

Quote:

Originally Posted by Drumstix42 (Post 69907)
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)
Parent.Parent.HQ.Location=('0' ## ',' ## ADD) ADD=(Parent.Parent.Collection.Top) + (Parent.Parent.Collection.Height)

Hope this helps.

You sir are officially my new hero, as - assuming your code works - you found the way to convert any floating point value into an integer, the holy grail of eq2 interface modding. lol. :nana:

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:

Drumstix42 02-26-2008 03:10 PM

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.

gm9 02-26-2008 03:17 PM

Exactly, that's what you got the nanas for. ;)

lordebon 02-27-2008 09:27 AM

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! ;)

dragowulf 02-27-2008 12:07 PM

Quote:

Originally Posted by lordebon (Post 69948)
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! ;)

I'm confused....what exactly does drum's code do????:confused:

gm9 02-27-2008 12:41 PM

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).

dragowulf 02-27-2008 01:25 PM

Quote:

Originally Posted by gm9 (Post 69961)
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).

Why would you want non-integer numbers as values???

gm9 02-27-2008 01:42 PM

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.

dragowulf 02-27-2008 01:43 PM

Quote:

Originally Posted by gm9 (Post 69969)
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.

So exactly why would this help us?

lordebon 02-27-2008 01:45 PM

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.

gm9 02-27-2008 01:55 PM

Maybe an example helps.
A=1
B=3
If you do
C=A+B
D=B-A
you end up with
C=4.0000
D=2.0000
Now if you do
Location=C,D
you get
Location=4,2
which equals
Left=4
Top=2
Tada, you have your integers and can assign them to something else, eg
IconSize=Left
This 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.

dragowulf 02-27-2008 02:33 PM

I get it. That's going to be really helpful Drums.

Nice work....lol and thanks for explaining it to me.

Drumstix42 02-28-2008 04:56 PM

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.

Zonx 03-05-2008 01:19 PM

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.

gm9 03-05-2008 01:33 PM

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:05 AM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI