Receive Logs
1. We will open the Chat Widget from the 2nd Tutorial and Bind the Event LogReceived from the Chat Component inside the Function onStart.
Of course we create inside the Create Event Delegate the Function like we did it for MessageReceived, which i call LogReceived.
2. Then we will create another Function, which we call MakeCustomLog and add as Input following:
Type [GameplayTag]
SubType [Name]
Color [LinearColor]
And as Output:
UseCustomLog [Bool]
We will leave this function for now empty.
2. Inside the Function LogReceived we need to do following:
First we need to call MakeCustomLog. I will explain this later.
Create a local Variable called, local_message with the Type Text.
Then we need to check, if we use the custom Message from MakeCustomLog.
If yes, do nothing
If no, create our Message Widget like in the 2nd Tutorial..
After that we can create our Message Widget like in the 2nd Tutorial.
EDIT: You need to make a Connection between SP8_S_Log Message to create Widget Message!
I have forgot to remove the local_message Variable.
Now we should be able to receive Logs.
Make Custom Log
I will make an example with the Log Info_Interval.
This will be called, when the Player needs to wait till he can send a new Message.
The SubType of the Log will be overwritten with the Seconds till he can make a new message.
1. First of all we need to create a new Gameplay Tag inside Project Settings - GameplayTags.
We call it Log.Type.Custom.SendMessageInterval.
Read more about Gameplay Tags!
2. Open your Player BP and add an Item to the Chat Logging Array and set the Key to Info_Interval and the Type to your new Gameplay Tag.
Additional we do not want that it will have the same Color as the default Log Color, so we add an Item to the LogColorsByType and set the Key to our GameplayTag and the Color to Yellow.
If we would put something into the Message field of the Chat Logging, this will be the Text on ReceiveLog, but we want to make a custom one.
3. Create a new Macro called ReverseForLoopWithDelay.
It’s a simple For Loop, which will make a delay in each Loop and it will go from high Number to low.
I will not explain it any further, because it’s not relevant for this Tutorial.
4. Now we can go to our MakeCustomLog Function inside our Chat Widget and do following:
Make a switch on the Type and add to it your new Gameplay Tag.
Convert the SubType to a String and check if it’s numeric
If yes we will call a new Event, which we call ChatInterval with the Input Seconds as Type Integer and Color as Linear Color.
Set the return Value to true.
4. Go to the new Event ChatInterval and do following:
Create Message Widget like in the 2nd Tutorial and do Format Text on the Message.
Write there whatever you want and add {Seconds} as Playerholder for the Text.
I wrote: You have to wait {Seconds} seconds, till you can write a new Message!
Add the seconds to the Format.
After that we need a Delay for one Second.
Now we need to call our new Macro ReverseForLoopWithDelay and set the First Index to the Seconds minus 1 and the second to 0. We want that it will loop every second.
Inside the Loop we do again Format Text, with the same text and add the Index from the Loop to the Seconds of the Format.
Now we can set the Message Text to the new Format.
If the Player now sends a Message, the Message will be send, but if he sends a second Message right after it, thsi Function will be called.
Now a yellow Message with the Content You have to wait <Seconds> seconds, till you can write a new Message!
Each second the <Seconds> will decrease by one, till it reached 0.