Lost on how printf function was included

the cartridge.h file was open from the very beginning of the video, and I am really lost about how to include the print function myself in another project. we’re told that it’s something we’ll want to do, but not really told how to do it.

Have a look here: FString | Unreal Engine Documentation
The Printf function is available within FString as a static method so can be called as FString::Printf and returns an FString that has been formatted according to your call.

Hope this helps.

1 Like

I think you might be conflating PrintLine and FString::Printf?

The latter is always available for you as, as @beegeedee mentioned, it’s a static member function of FString. If you want to create a formatted FString you can create that with Printf e.g.

// where Name is an FString created elsewhere
FString WelcomeText = FString::Printf(TEXT("Hello %s, how are you?"), *Name);
1 Like

I was mostly confused about the file open throughout the video where the function was set up. there was a file simply called ‘cartridge.h’ and at the end of the lecture, it was shown that some prebuilt functionality had been set up within it. I just don’t know what/where that file is.

I tried to screenshot the lecture but the screen was just coming up as plain black every time. it’s the file where the ‘PrintLine’ function was set up initially so you didn’t have to manually type 'FString::Printf(TEXT(“your text”)). I just didn’t really understand where that was set or how to set it myself.

That is a file that comes with the project and was mostly written by Sam. You can find that code within your Console directory.

Link on GitHub:
BullCowGame/BullCowGame-starter-kit/Source/BullCowGame/Console at master · UnrealCourse2019/BullCowGame · GitHub

That isn’t what is being talked about as something for you to do yourself. What was mentioned is using FString::Printf in your own code. Wanting to have a function that forwards arguments to it isn’t something you really need to do unless you have a similar need and implementing it is not beginner level stuff.

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

Privacy & Terms