|
02-26-2008, 02:47 PM
|
|
A Griffon
|
|
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,287
|
|
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
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.
|
02-26-2008, 02:57 PM
|
gm10-1
|
|
Join Date: Feb 2006
Posts: 6,479
|
|
Quote:
Originally Posted by Drumstix42
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.
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:
|
02-26-2008, 03:10 PM
|
|
A Griffon
|
|
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,287
|
|
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.
|
02-26-2008, 03:17 PM
|
gm10-1
|
|
Join Date: Feb 2006
Posts: 6,479
|
|
Exactly, that's what you got the nanas for.
|
02-27-2008, 09:27 AM
|
Fetish Core author
|
|
Join Date: Jun 2005
Server: Crushbone
Posts: 2,667
|
|
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!
|
02-27-2008, 12:07 PM
|
|
A man among men
|
|
Join Date: Dec 2004
Server: Nagafen
Posts: 934
|
|
Quote:
Originally Posted by lordebon
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????
__________________
May Jesus Have Mercy On Us
|
02-27-2008, 12:41 PM
|
gm10-1
|
|
Join Date: Feb 2006
Posts: 6,479
|
|
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).
|
02-27-2008, 01:25 PM
|
|
A man among men
|
|
Join Date: Dec 2004
Server: Nagafen
Posts: 934
|
|
Quote:
Originally Posted by gm9
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???
__________________
May Jesus Have Mercy On Us
|
02-27-2008, 01:42 PM
|
gm10-1
|
|
Join Date: Feb 2006
Posts: 6,479
|
|
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.
|
02-27-2008, 01:43 PM
|
|
A man among men
|
|
Join Date: Dec 2004
Server: Nagafen
Posts: 934
|
|
Quote:
Originally Posted by gm9
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?
__________________
May Jesus Have Mercy On Us
|
02-27-2008, 01:45 PM
|
Fetish Core author
|
|
Join Date: Jun 2005
Server: Crushbone
Posts: 2,667
|
|
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.
|
02-27-2008, 01:55 PM
|
gm10-1
|
|
Join Date: Feb 2006
Posts: 6,479
|
|
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.
Last edited by gm9 : 02-27-2008 at 02:48 PM.
|
02-27-2008, 02:33 PM
|
|
A man among men
|
|
Join Date: Dec 2004
Server: Nagafen
Posts: 934
|
|
I get it. That's going to be really helpful Drums.
Nice work....lol and thanks for explaining it to me.
__________________
May Jesus Have Mercy On Us
|
02-28-2008, 04:56 PM
|
|
A Griffon
|
|
Join Date: Oct 2004
Server: Antonia Bayle
Posts: 3,287
|
|
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.
|
03-05-2008, 01:19 PM
|
|
A Green Troll
|
|
Join Date: Dec 2004
Server: Blackburrow
Posts: 2,221
|
|
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.
|
03-05-2008, 01:33 PM
|
gm10-1
|
|
Join Date: Feb 2006
Posts: 6,479
|
|
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...
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:16 PM.
|
|