Report post

Are you sure you want to report the post shown below? This will send an email to the ATVO administrators. Please include a short reason for reporting.

Users reporting for no reason may be locked out.


Post

Posted by Nick Thissen
on
Emmanuel Suter wrote:
I try to get different information from different places but in the same widget (so with same data set)

I want to add the track name in combinaison with classname for result title.

I try to catch information with something like that:
IEntitySessionResult result = (IEntitySessionResult) value;
ITrack result1 = (ITrack) value;

var classname = result.Entity.Car.Class.Name;
var track0 = result1.DisplayName;

return track0 + "  " + classname;


But track0 return no good value.
No, it doesn't work that way. I think you misunderstand the way script converters work.

The "value" parameter that the script receives is the value of the data binding you selected. This can be a simple value like a driver name, carnumber, etc. Or it can be an object if you select for example "entitysessionresult_object" or "entity_object" as the binding. In the end, the type of value is only one type. The first line in most of the scripts is called a 'cast', where you tell the compiler that the type of value is a certain type. For example, this tells the compiler "treat value as type IEntitySessionResult":
var result = (IEntitySessionResult) value;


It's important to realize there is no conversion or anything going on here, it is just telling the compiler what the type will be. If value was actually another type, this will fail.

You can't cast value to an IEntitySessionResult and then to an ITrack object; those are different types.


Long story short, to get the track you can find it via the sim.Session property:
ITrack track = sim.Session.Track;