Fix script not showing execution results.

This commit is contained in:
BruceChen 2023-01-15 19:59:57 +08:00
parent 8db0467f69
commit 338f534239
5 changed files with 88 additions and 7 deletions

View file

@ -5,6 +5,7 @@ using System.IO;
using System.Reflection;
using System.Text;
using System.Threading;
using MinecraftClient.CommandHandler;
using MinecraftClient.Scripting;
namespace MinecraftClient.ChatBots
@ -85,7 +86,7 @@ namespace MinecraftClient.ChatBots
public static bool LookForScript(ref string filename)
{
//Automatically look in subfolders and try to add ".txt" file extension
char dir_slash = Path.DirectorySeparatorChar;
char dir_slash = Path.DirectorySeparatorChar;
string[] files = new string[]
{
filename,
@ -210,11 +211,22 @@ namespace MinecraftClient.ChatBots
sleepticks = ticks;
break;
default:
if (!PerformInternalCommand(instruction_line))
CmdResult response = new();
if (PerformInternalCommand(instruction_line, ref response))
{
if (instruction_name.ToLower() != "log")
{
LogToConsole(instruction_line);
}
if (response.status != CmdResult.Status.Done || !string.IsNullOrWhiteSpace(response.result))
{
LogToConsole(response);
}
}
else
{
Update(); //Unknown command : process next line immediately
}
else if (instruction_name.ToLower() != "log") { LogToConsole(instruction_line); }
break;
}
}