Calling Log Event Requests in RT Scripts

A LogEventRequest has attributes that don't work exactly like scriptData. You need a way to include the attribute data in the request. This tutorial provides an example that demonstrates how to include attribute data in a LogEventRequest.

LogChallengeEventRequests? The following applies equally to calling LogChallengeEventRequests from RT scripts.

For the example, we'll create an Event with two Attributes:

Setting Event Attributes

Here's how we can set these Attributes for our log event:

var request = RTSession.newRequest()
        .createLogEventRequest()
        .setEventKey("event");
    request.settestvar("Hey this is a string");
    request.settestvar2({"key":"value"});
    request.setPlayerId(packet.getSender().getPlayerId())
        .send(function(response){
            RTSession.getLogger().debug(response);
        });

Understanding the JSON Constructor

Here are the main points for understanding the JSON constructor:

So, our above code block for setting the Event Attributes will be unpacked into the following JSON:

{"eventKey:"event",testvar:"Hey this is a string",{"testvar2":{"key":"value"}},"playerId":"playerId"};

Formatting Constraints

When using set in these sorts of case, the first character after an instance of set will always be rendered as lower case:

Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here