Unreal crashes everytime I hit play with %i or %s in the code

every time I click play it crashes if there’s %i or %s in the code, turning them into comments fixes the problem but I can proceed like this.

Could you how your code for BullCowCartridge.cpp?

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

void UBullCowCartridge::BeginPlay() // When the game starts
{
    SetupGame();

    PrintLine(TEXT("The HiddenWord is: %s. \n is %i characters long"), *HiddenWord, HiddenWord.Len()); //Debug code
    Super::BeginPlay();
    PrintLine(TEXT("Welcome to the game\n")); 
    PrintLine(TEXT("guess the %i letter word\npress tab and then enter to play"), HiddenWord.Len());
}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter
{
    ClearScreen();
    if (Input == HiddenWord)
    { 
        PrintLine(TEXT("good job"));
    }
    else
    {
         PrintLine(TEXT("please try again"));

         if (HiddenWord.Len() != Input.Len())
         {
           PrintLine (TEXT("some are cows or smoething"));
         }
         else
         PrintLine (TEXT("please enter the %i letters of the Hidden Word"), HiddenWord.Len()); 
         
         // is it isogram? if it not says you need an isogram else give how many are cows
         // takes lives
    }
}

void UBullCowCartridge::SetupGame()
{
    HiddenWord = TEXT("Plain");
    Lives = 4;
}

Super::BeginPlay needs to be called first as that’s what sets the Terminal variable which PrintLine uses.

thanks that solved the problem, I cant believe such a simple logic problem eluded me.

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

Privacy & Terms