Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: Lane on January 26, 2015, 09:35:26 AM

Title: Float Round To Nearest
Post by: Lane on January 26, 2015, 09:35:26 AM
Rounds a Float variable to the nearest specified multiplier.

Also on Ecosystem.
Title: Re: Float Round To Nearest
Post by: wheretheidivides on January 26, 2015, 01:21:22 PM
With each action you guys keep making playmaker better and better.
Title: Re: Float Round To Nearest
Post by: wheretheidivides on January 27, 2015, 01:08:20 PM
I just used this on a slider.  So anyone making a slider can use this.

So I have a pause menu pop up.  The player can use the mouse to select the slider.  Sense it is a float, it can be any float value.  I just display a percent to make it easier to read forgetting the rest even though technically they are there.  So .054567 would display as '55%'.

However, it doesn't seem to do what I thought it would.  It seems to be going in increments of 15.  So 43 becomes 60.  Now I do add or subtract 5% as well.  So 43 plus 5 = 48.  The round should move it to 50 but it goes up to 60.

So I click with mouse at 43. 
Then I use the joystick right axis (FSM2 un-shown) to trigger 'increment right'. 
'Add'  is where I add 5.  I use the round here to 0.05.
'Set slider value' state is where I clamp it to 0 an 1.
"Set Slider onscreen" sets the property of the slider
"Show Slider Number" displays it, plays sound and such.  More used for mouse.
Any ideas of how I am setting this wrong?
Title: Re: Float Round To Nearest
Post by: wheretheidivides on January 27, 2015, 01:14:02 PM
Here are screenshots of pause menu. 

The top left has 'pause menu slider' at 0.4293623 which displays at 43%.
I click right to add 5% and it goes to 0.6 or 60%.


Now I did reverse the position of the round and float add in that state which sort of fixed the problem.  However, there is some bug (on my end or yours) that sometimes it will do 5% and sometimes will do 15%.  I get it to 0% and then it then only goes up or down in 15% increments.  the code here is really simple so that's weird.
Title: Re: Float Round To Nearest
Post by: Lane on January 27, 2015, 01:35:21 PM
Maybe it's running it more than once because of your inputs, looks like a weird way to handle a slider.
Title: Re: Float Round To Nearest
Post by: wheretheidivides on January 27, 2015, 03:17:52 PM
Maybe it has something to do with the joystick/button adding 5% (and rounding), then the playmaker proxy doing a 'on value changed'.  maybe the proxy sees a change and thus changed the float value.

If true, is there a way around this?

UPDATE:  When it messes up (mouse click on slider then use keyboard/joystick) and does it wrong at 15% increments (add or subtract),

then I click on another window like the scene and
then click back on the game window, it fixes it. 
It will now go up or down at 5% increments (not 15%)  Weird.
Title: Re: Float Round To Nearest
Post by: wheretheidivides on January 30, 2015, 12:09:06 AM
I keep getting this console error on this action. 

Assets/PlayMaker Custom Actions/DownloadedFromForems/FloatRoundToNearest.cs(53,41): warning CS0472: The result of comparing value type `HutongGames.PlayMaker.FsmInt.Value' with null is `true'
Title: Re: Float Round To Nearest
Post by: wheretheidivides on February 07, 2015, 09:34:47 PM
So how do I get rid of this error so it won't keep popping on in the console?

"Assets/PlayMaker Custom Actions/DownloadedFromForems/FloatRoundToNearest.cs(53,41): warning CS0472: The result of comparing value type `HutongGames.PlayMaker.FsmInt.Value' with null is `true'"
Title: Re: Float Round To Nearest
Post by: jeanfabre on February 17, 2015, 01:34:14 AM
Hi,

 you can insert a pragma declaration and the related warning will not be raised:

http://answers.unity3d.com/questions/21796/disable-warning-messages.html

when I'll move that action to the ecosystem, I'll clean up that warning.

 Bye,

 Jean
Title: Re: Float Round To Nearest
Post by: wheretheidivides on February 17, 2015, 12:49:06 PM
I don't know C#.  So I just add:

"#pragma warning disable 0472"

at the top of the action script somewhere?
Title: Re: Float Round To Nearest
Post by: Lane on February 17, 2015, 01:05:38 PM
I don't see the warning in 5f1, but I fixed the line. The warning should go away.
Title: Re: Float Round To Nearest
Post by: wheretheidivides on February 17, 2015, 01:12:09 PM
Could you post it here so I can download/?
Title: Re: Float Round To Nearest
Post by: Lane on February 17, 2015, 01:33:37 PM
Its in the first post and ecosystem.