Test and fix basic commands
This commit is contained in:
parent
f19dc46010
commit
d4db32ccb4
2 changed files with 39 additions and 10 deletions
|
@ -24,18 +24,20 @@ namespace ExtraCommands.Basics
|
||||||
public override void Ready()
|
public override void Ready()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Register<string, string>("Chain", ChainCommand, "Run two commands, one after the other");
|
uREPL.RuntimeCommands.Register<string, string>("Chain", ChainCommand, "Run two commands, one after the other");
|
||||||
uREPL.RuntimeCommands.Register<string, string>("ChainNoFail", ChainCommand, "Run two commands, one after the other even if the first one is invalid");
|
uREPL.RuntimeCommands.Register<string, string>("ChainNoFail", ChainNoFailCommand, "Run two commands, one after the other even if the first one is invalid");
|
||||||
uREPL.RuntimeCommands.Register<string, string>("ChainQuiet", ChainCommand, "Run two commands, one after the other quietly");
|
uREPL.RuntimeCommands.Register<string, string>("ChainQuiet", ChainQuietCommand, "Run two commands, one after the other quietly");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChainCommand(string command1, string command2)
|
private void ChainCommand(string command1, string command2)
|
||||||
{
|
{
|
||||||
bool success1 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1);
|
string command1a = decomma(command1);
|
||||||
|
string command2a = decomma(command2);
|
||||||
|
bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success;
|
||||||
if (!success1) {
|
if (!success1) {
|
||||||
uREPL.Log.Error("First command was not executed successfully");
|
uREPL.Log.Error("First command was not executed successfully");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool success2 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2);
|
bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success;
|
||||||
if (!success2) {
|
if (!success2) {
|
||||||
uREPL.Log.Error("Second command was not executed successfully");
|
uREPL.Log.Error("Second command was not executed successfully");
|
||||||
}
|
}
|
||||||
|
@ -43,11 +45,13 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
private void ChainNoFailCommand(string command1, string command2)
|
private void ChainNoFailCommand(string command1, string command2)
|
||||||
{
|
{
|
||||||
bool success1 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1);
|
string command1a = decomma(command1);
|
||||||
|
string command2a = decomma(command2);
|
||||||
|
bool success1 = uREPL.Evaluator.Evaluate(command1a).type == CompileResult.Type.Success;
|
||||||
if (!success1) {
|
if (!success1) {
|
||||||
uREPL.Log.Error("First command was not executed successfully");
|
uREPL.Log.Error("First command was not executed successfully");
|
||||||
}
|
}
|
||||||
bool success2 = uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2);
|
bool success2 = uREPL.Evaluator.Evaluate(command2a).type == CompileResult.Type.Success;
|
||||||
if (!success2) {
|
if (!success2) {
|
||||||
uREPL.Log.Error("Second command was not executed successfully");
|
uREPL.Log.Error("Second command was not executed successfully");
|
||||||
}
|
}
|
||||||
|
@ -55,8 +59,33 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
private void ChainQuietCommand(string command1, string command2)
|
private void ChainQuietCommand(string command1, string command2)
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command1);
|
string command1a = decomma(command1);
|
||||||
uREPL.RuntimeCommands.ConvertIntoCodeIfCommand(command2);
|
string command2a = decomma(command2);
|
||||||
|
uREPL.Evaluator.Evaluate(command1a);
|
||||||
|
uREPL.Evaluator.Evaluate(command2a);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string decomma(string strIn)
|
||||||
|
{
|
||||||
|
string strOut = "";
|
||||||
|
bool wasCommaLast = false;
|
||||||
|
foreach (char c in strIn)
|
||||||
|
{
|
||||||
|
if (wasCommaLast)
|
||||||
|
{
|
||||||
|
wasCommaLast = false;
|
||||||
|
if (c == ' ')
|
||||||
|
{
|
||||||
|
strOut = strOut.Substring(0, strOut.Length - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c == ',')
|
||||||
|
{
|
||||||
|
wasCommaLast = true;
|
||||||
|
}
|
||||||
|
strOut += c;
|
||||||
|
}
|
||||||
|
return strOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|
|
@ -15,13 +15,13 @@ namespace ExtraCommands.Basics
|
||||||
[CustomCommand("SetTargetFPS", "Set Gamecraft's target FPS")]
|
[CustomCommand("SetTargetFPS", "Set Gamecraft's target FPS")]
|
||||||
class SetTargetFramerateCommandEngine : CustomCommandEngine
|
class SetTargetFramerateCommandEngine : CustomCommandEngine
|
||||||
{
|
{
|
||||||
public SetFOVCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
public SetTargetFramerateCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Ready()
|
public override void Ready()
|
||||||
{
|
{
|
||||||
uREPL.RuntimeCommands.Register<float>("SetTargetFPS", SetFramerateCommand, "Set Gamecraft's target FPS");
|
uREPL.RuntimeCommands.Register<int>("SetTargetFPS", SetFramerateCommand, "Set Gamecraft's target FPS");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetFramerateCommand(int newFoV)
|
private void SetFramerateCommand(int newFoV)
|
||||||
|
|
Loading…
Reference in a new issue