Skip to content

Commit

Permalink
Added a invariant number format function.
Browse files Browse the repository at this point in the history
This partially/temporarily fixes #369
  • Loading branch information
McJones committed Sep 27, 2023
1 parent 80e84f7 commit 04773e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
}
]
},
{
"YarnName": "format_invariant",
"DefinitionName": "format invariant",
"Documentation": "Converts a number to a string using invariant culture",
"Signature": "format_invariant(value)",
"Parameters": [
{
"Name": "value",
"Type": "Number",
"Documentation": "",
"IsParamsArray": false
}
]
},
{
"YarnName": "bool",
"DefinitionName": "bool",
Expand Down
5 changes: 5 additions & 0 deletions YarnSpinner/Dialogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,11 @@ public StandardLibrary()
return Convert.ToSingle(v);
});

this.RegisterFunction("format_invariant", delegate (float v)
{
return v.ToString(System.Globalization.CultureInfo.InvariantCulture);
});

this.RegisterFunction("bool", delegate(object v)
{
return Convert.ToBoolean(v);
Expand Down

0 comments on commit 04773e2

Please sign in to comment.