Skip to content

Commit

Permalink
Better support for evaluating arbitrary ink on command line
Browse files Browse the repository at this point in the history
  • Loading branch information
joethephish committed Jul 27, 2016
1 parent 1b6254d commit bde59a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ink-engine-runtime/Story.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ string ContinueInternal()
Error("Thread available to pop, threads should always be flat by the end of evaluation?");
}

if( currentChoices.Count == 0 && !state.didSafeExit ) {
if( currentChoices.Count == 0 && !state.didSafeExit && _temporaryEvaluationContainer == null ) {
if( state.callStack.CanPop(PushPopType.Tunnel) ) {
Error("unexpectedly reached end of content. Do you need a '->->' to return from a tunnel?");
} else if( state.callStack.CanPop(PushPopType.Function) ) {
Expand Down
22 changes: 19 additions & 3 deletions inklecate/CommandLineTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ void ExitWithUsageInstructions()
opts.playMode = true;
}

PrintMessages (authorMessages, ConsoleColor.Green);
PrintMessages (warnings, ConsoleColor.Blue);
PrintMessages (errors, ConsoleColor.Red);
PrintAllMessages ();

if (story == null || errors.Count > 0) {
Environment.Exit (ExitCodeError);
Expand All @@ -181,6 +179,8 @@ void ExitWithUsageInstructions()
// the test script is also played
if (opts.playMode) {

_playing = true;

// Always allow ink external fallbacks
story.allowExternalFunctionFallbacks = true;

Expand Down Expand Up @@ -224,6 +224,9 @@ void OnError(string message, ErrorType errorType)
errors.Add (message);
break;
}

// If you get an error while playing, just print immediately
if( _playing ) PrintAllMessages ();
}

void PrintMessages(List<string> messageList, ConsoleColor colour)
Expand All @@ -237,6 +240,17 @@ void PrintMessages(List<string> messageList, ConsoleColor colour)
Console.ResetColor ();
}

void PrintAllMessages ()
{
PrintMessages (authorMessages, ConsoleColor.Green);
PrintMessages (warnings, ConsoleColor.Blue);
PrintMessages (errors, ConsoleColor.Red);

authorMessages.Clear ();
warnings.Clear ();
errors.Clear ();
}

bool ProcessArguments(string[] args)
{
if (args.Length < 1) {
Expand Down Expand Up @@ -342,5 +356,7 @@ void TimeOperation(string opDescription, Action op)
List<string> errors;
List<string> warnings;
List<string> authorMessages;

bool _playing;
}
}

0 comments on commit bde59a9

Please sign in to comment.