You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create an createPrefItemNumber but I can't figure out how to change the formatter to use a Float instead.
I found only this in the Source of the game:
/** * Creates a pref item that works with general numbers * @paramonChange Gets called every time the player changes the value; use this to apply the value * @paramvalueFormatter Will get called every time the game needs to display the float value; use this to change how the displayed value looks * @paramdefaultValue The value that is loaded in when the pref item is created (usually your Preferences.settingVariable) * @parammin Minimum value (example: 0) * @parammax Maximum value (example: 10) * @paramstep The value to increment/decrement by (default = 0.1) * @paramprecision Rounds decimals up to a `precision` amount of digits (ex: 4 -> 0.1234, 2 -> 0.12)*/functioncreatePrefItemNumber(prefName:String, prefDesc:String, onChange:Float->Void, ?valueFormatter:Float->String, defaultValue:Int, min:Int, max:Int,
step:Float=0.1, precision:Int):Void
{
varitem=newNumberPreferenceItem(0, (120*items.length) +30, prefName, defaultValue, min, max, step, precision, onChange, valueFormatter);
items.addItem(prefName, item);
preferenceItems.add(item.lefthandText);
}
But I can't figure out how to change the valueFormatter to format value as Float.
I have only this till now if helps:
Update:
I tried something like this but now when I force restart (F5) the game the value starts from the int instead of the float, ex: I save 3.3 REFRESH it shows 3.3 but when i change it starts back from 3
preferences.createPrefItemNumber("Float", "", function (value:Float) {
save.data.floatFactor=value; },
function (value:Float):String {
Std.parseFloat(save.data.floatFactor ); }, save.data.floatFactor , 0.0, 1.0, 0.1, 1);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to create an createPrefItemNumber but I can't figure out how to change the formatter to use a Float instead.
I found only this in the Source of the game:
But I can't figure out how to change the valueFormatter to format value as Float.
I have only this till now if helps:
Update:
I tried something like this but now when I force restart (F5) the game the value starts from the int instead of the float, ex: I save 3.3 REFRESH it shows 3.3 but when i change it starts back from 3
Beta Was this translation helpful? Give feedback.
All reactions