Skip to content

Commit

Permalink
Updated project version and added clear, print and echo system commands
Browse files Browse the repository at this point in the history
  • Loading branch information
p3nGu1nZz committed Apr 7, 2024
1 parent f32a9b0 commit c570743
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Assets/Resources/bootstrap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# System Commands
Register { Register, 0, -1, "Registers a new command in the terminal."}
Register { Unregister, 1, 1, "Unregisters an existing command from the terminal."}
Register { clear, 0, 1, "Clears the console and archives the log lines."}
Register { print, 1, 1, "Prints a message to the terminal."}
Register { echo, 1, 1, "Echo's a message to the terminal."}

# Help Command
Register { Help, 0, -1, "Displays help information for all commands."}
Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/Agents/EchoAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public void FixedUpdate()
if (_CachedGuessedString.EndsWith(k_EndOfSequence))
{
_reward = CalculateReward(expectedString, _CachedGuessedString);

_CachedGuessedString = _CachedGuessedString.Replace(k_EndOfSequence, "");

Terminal.Instance.Shell.Run(_CachedGuessedString);

if(Terminal.Instance.IssuedError)
{
_reward -= 0.5f; // Penalize for bad commands
Expand Down
43 changes: 43 additions & 0 deletions Assets/Scripts/Commands/SystemCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,48 @@ public static void UnregisterCommand(CommandArg[] args)
Terminal.Instance.LogError("[SYST] Unable to locate the terminal in TerminalCommand.");
}
}

[Command("clear")]
public static void ClearCommand(CommandArg[] args)
{
if (args.Length == 0)
{
Terminal.Instance.Buffer.ArchiveLogs();
}
else if (args.Length == 1 && args[0].String == "--reset")
{
Terminal.Instance.Buffer.Reset();
}
else
{
Terminal.Instance.LogError("[SYST] Insufficient arguments provided for 'clear' command.");
}
}

[Command("print")]
public static void PrintCommand(CommandArg[] args)
{
if (args.Length == 1)
{
Terminal.Instance.Log(args[0].String);
}
else
{
Terminal.Instance.LogError("[SYST] Insufficient arguments provided for 'print' command.");
}
}

[Command("echo")]
public static void EchoCommand(CommandArg[] args)
{
if (args.Length == 1)
{
PrintCommand(new CommandArg[] { args[0] });
}
else
{
Terminal.Instance.LogError("[SYST] Insufficient arguments provided for 'echo' command.");
}
}
}
}
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2023.2.16f1
m_EditorVersionWithRevision: 2023.2.16f1 (7f45223012db)
m_EditorVersion: 2023.2.17f1
m_EditorVersionWithRevision: 2023.2.17f1 (396a1c6fe404)

0 comments on commit c570743

Please sign in to comment.