diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-05-27 18:04:46 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-05-27 18:04:46 +0200 |
| commit | 778960415464079277b31365f0465159585be018 (patch) | |
| tree | 4984ae9c69fd589cfe1a955a90ac9a1fb2dbad49 /Scripts | |
| parent | 6363292d14d84ae0641b6ce1048f4ca7268ebb49 (diff) | |
| download | texty-778960415464079277b31365f0465159585be018.tar.xz texty-778960415464079277b31365f0465159585be018.zip | |
game: parse submitted commands
Diffstat (limited to 'Scripts')
| -rw-r--r-- | Scripts/Game.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Scripts/Game.cs b/Scripts/Game.cs index 645c922..07dab9a 100644 --- a/Scripts/Game.cs +++ b/Scripts/Game.cs @@ -5,6 +5,7 @@ namespace Texty.Scripts { public abstract class Game : MarginContainer { + public CommandParser CommandParser; public VBoxContainer LayoutContainer; public OutputContainer OutputContainer; @@ -14,6 +15,7 @@ namespace Texty.Scripts { Debug.Assert(OutputRowScene != null, $"The {nameof(OutputRowScene)} was not set!"); + CommandParser = GetNode<CommandParser>(nameof(CommandParser)); LayoutContainer = GetNode<VBoxContainer>(nameof(LayoutContainer)); OutputContainer = LayoutContainer.GetNode<OutputContainer>(nameof(OutputContainer)); } @@ -22,7 +24,9 @@ namespace Texty.Scripts { var newRow = OutputRowScene.Instance<OutputRow>(); newRow.InputText = text; - newRow.OutputText = "THE OUTPUT SHOULD GO HERE!"; + + var command = CommandParser.TryParse(text); + newRow.OutputText = command == null ? "Please rephrase your command" : "THE OUTPUT SHOULD GO HERE!"; OutputContainer.Add(newRow); } |
