Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Dec 13, 2024
2 parents 37ee240 + 0fca50f commit bcebc67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed

- Commands are now better at checking to see if the first word is a keyword (e.g. `return`) or a word that just _begins_ with a keyword (`returnToMenu`).
- `random_range(min, max)` now returns a random integer between `min` and `max`, inclusive. (Previously, it returned a float.)
- Added a new function, `random_range_float` now returns a random float between `min` and `max`, inclusive. (This is the previous behaviour of `random_range`.)

### Removed

Expand Down
2 changes: 1 addition & 1 deletion YarnSpinner.Compiler/YarnSpinner.Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This package provides support for compiling Yarn source code, so that you can ex
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.13.1"/>
<PackageReference Include="CsvHelper" Version="12.2.2" />
<PackageReference Include="Google.Protobuf" Version="3.25.2"/>
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
</ItemGroup>

Expand Down
7 changes: 6 additions & 1 deletion YarnSpinner/Dialogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,11 +1183,16 @@ public StandardLibrary()
return (float)Random.NextDouble();
});

this.RegisterFunction<float, float, float>("random_range", (float min, float max) =>
this.RegisterFunction("random_range", (float min, float max) =>
{
return Random.Next((int)max - (int)min + 1) + min;
});

this.RegisterFunction("random_range_float", delegate (float minInclusive, float maxInclusive)
{
return Random.Next((int)maxInclusive - (int)minInclusive + 1) + minInclusive;
});

this.RegisterFunction<int, int>("dice", (int sides) =>
{
return Random.Next(sides) + 1;
Expand Down

0 comments on commit bcebc67

Please sign in to comment.