My code failing to compile

So, First off; I have already deviated a fair bit from the lecture code. I am asking this here because I am not certain where else to look for assistance. In any case, when I try to compile my code in Unreal, it fails. However, VS Code isn’t showing me any errors.

My code is as follows:

Blockquote
#include “BullCowCartridge.h”

// Fill out your copyright notice in the Description page of Project Settings.



FString HiddenWord;



TArray<FString> isograms;

   

int assignWord(){

    int32 numWords = isograms.Num();

    int32 index = FMath::RandRange(0, (numWords - 1));



    HiddenWord = isograms[index];

}



void UBullCowCartridge::BeginPlay() // When the game starts

{

    Super::BeginPlay();

    PrintLine("Allo Allo this is cow game\n");

    PrintLine("Press Tab to focus yourself upon this here terimal screen for the typing\n");

    PrintLine("You can has be typing stuff into younder terminal to accomplish things");

    PrintLine("do be pressing \"enter\" to sumbit.\n");



    //now, add isograms to the potential word list

    isograms.Add(TEXT("Cake"));

    isograms.Add(TEXT("World"));

    isograms.Add(TEXT("Ambidextrously"));

    isograms.Add(TEXT("Mario"));

    isograms.Add(TEXT("Wario"));

    isograms.Add(TEXT("Cow"));

    isograms.Add(TEXT("Ox"));

    isograms.Add(TEXT("Calf"));

    isograms.Add(TEXT("Lamp"));

    isograms.Add(TEXT("Oil"));

    isograms.Add(TEXT("Morshu"));

    isograms.Add(TEXT("rope"));

    isograms.Add(TEXT("lizard"));

    isograms.Add(TEXT("bird"));

    isograms.Add(TEXT("Corvid"));

    isograms.Add(TEXT("Crow"));

    isograms.Add(TEXT("Raven"));

    isograms.Add(TEXT("Jay"));

    isograms.Add(TEXT("Magpie"));



    //make sure we have a hidden word

    assignWord();

}



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

{

    ClearScreen();

    PrintLine(HiddenWord);

    assignWord();

}

The code shown here is the only code I have touched, and so must contain the error.

What, in this code, is causing unreal engine to be unable to compile my code?

With what error message?

I’m not actually sure, but I managed to find help elsewhere. The problems were as follows:

The function “assignWord” was specified to return an int, but it didn’t return anything

assignWord was not defined in the header file

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

Privacy & Terms