When I implemented the solution for slow compile times as stated in https://community.gamedev.tv/t/slow-compile-times-after-adding-word-list-on-bullcowgame/118958 I cannot use “Words” in my GetValidWords function.
Since it is not declared in a separate header file, it does not have scope in the GetValidWords function, and I cannot use it.
I have tried putting the solution code into a header file by itself, but that didn’t work. I have also tried putting the solution code into the GetValidWords function, but it didn’t work.
Please help. I’m really stuck.
Here’s some code snippets:
GetValidWords function
TArray<FString> UBullCowCartridge::GetValidWords(TArray<FString> WordList) const
{
TArray<FString> ValidWords;
for (int32 Index = 0; Index < WordList.Num(); Index++)
{
if (Words[Index].Len() >= 4 && Words[Index].Len() <=8)
{
ValidWords.Emplace(Words[Index]);
}
}
return ValidWords;
}
BeginPlay()
#include "FIleHelper.h"
#include "Paths.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
TArray<FString> WordsList;
const FString WordsListPath = FPaths::ProjectContentDir() / TEXT("HiddenWordList.txt");
FFileHelper::LoadFileToStringArray(WordsList, *WordsListPath);
SetupGame();
PrintLine(TEXT("The Hidden Word is %s."), *HiddenWord); // Debug Line
}