Bull Cows Terminal Problem

The terminal screen does not clear when I press enter. And when I type, it just types over the welcome message.
I’m using Mac OS Catalina, XCode 11.5, and Unreal Editor 4.25.1

Here’s my code. I tried a few variations, but this one is an exact copy of what was done in the lecture.

// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"

void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();
    PrintLine("Welcome to Bull Cows!");
    PrintLine("Press enter to continue...");
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
    ClearScreen();
}

And here is the output of the terminal in the game:

*edit: As I’ve been playing with it since posting this originally, it seems like my OnInput() method isn’t getting called. Nothing I add to that method seems to run.
I traced it back to the Terminal.cpp file and a function in Terminal called AcceptInputLine(). Here’s the code for the AcceptInputLine:

void UTerminal::AcceptInputLine()
{
	Buffer.Emplace(GPrompt + InputLine);
	auto Cartridge = GetOwner()->FindComponentByClass<UCartridge>();
	if (Cartridge != nullptr)
	{
		Cartridge->OnInput(InputLine);
	}
    else {
        PrintLine("NULL");
    }
	InputLine = TEXT("");

I added the else statement to check what was happening, and every time I press enter using the terminal in the game it prints NULL. In my mind, that would mean that Cartridge in the code above is a null pointer, correct? And that’s why my OnInput() function never gets called. But I do not know what to do about it.

Could you show the details panel of your terminal?

Sure thing. Couldn’t fit in all in one screenshot


You are missing the BullCowCartridge which was added towards the end of Actors And Components

1 Like

I reverted to the original download of the game last night to rebuild it and see if I missed something. I thought I had done that when I originally went through that lecture, but I guess not because it is working now! Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms