Skip to content

Commit

Permalink
adding parseFloat
Browse files Browse the repository at this point in the history
  • Loading branch information
bizzehdee committed Sep 23, 2024
1 parent b0d86e1 commit 2235e96
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DScript.Extras/FunctionProviders/IntegerFunctionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ public static void IntParseIntImpl(ScriptVar var, object userData)
var.ReturnVar.Int = intResult;
}

[ScriptMethod("parseFloat", "str")]
[ScriptMethod("parseFloat", "str", AppearAtRoot = true)]
public static void IntParseFloatImpl(ScriptVar var, object userData)
{
var str = var.GetParameter("str").String;

if (double.TryParse(str, out double intResult) == false)
{
intResult = 0;
}

var.ReturnVar.Float = intResult;
}

[ScriptMethod("valueOf", "str")]
public static void IntValueOfImpl(ScriptVar var, object userData)
{
Expand Down

0 comments on commit 2235e96

Please sign in to comment.