Zum Inhalt springen
AppgineeringAppgineering
Shop
Schreibgeschützt4 Beiträge · 2,910 Aufrufe · Erstellt 15 Dec 2020, 18:22

Order Drivers by positions gained

Archiviert: Diskussion auf Discord verlagertDiscord
Harold D.Ursprünglicher Verfasser
#1

Nick,

I am trying to generate a ticker based on positions gained. I dont see that as a selection. Is there a way to work around this with a data set?

Thanks,
Harold

Nick ThissenAppgineering
#2

You can easily achieve this with a custom dataset script. These are only available on Beta and Alpha channel at the moment unfortunately but I plan to merge them to stable soon.

Just add a new Script, and in the dialog select the template as "Custom dataset script". The script will get some complicated looking code, but all you need to do is put your own stuff in the "OrderResults" function. That one allows you to sort the results as you want, and after saving and compiling the script you should be able to select it as a dataset.

In your case you'd probably end up with this:

using System;
using System.Linq;
using System.Collections.Generic;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.ThemeModels.DataSets;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemesSDK.Ordering;

namespace Scripts
{
	public class PosGainedDataset : CustomStandingsDataSet
	{	
		protected override IList<IEntitySessionResult> FilterResults(
			ISimulation sim, 
			IList<IEntitySessionResult> results)
        {
        	return results;
        }
        
        protected override IList<IEntitySessionResult> OrderResults(
        	ISimulation sim, 
        	IList<IEntitySessionResult> results, 
        	IDataOrder order)
        {
        	return results.OrderByDescending(r => r.LivePosition - r.StartPosition).ToList();
        }
        
        protected override ISessionResult GetSession(ISimulation sim)
        {
            return sim.Session.Current;
        }
	}
}

There is no 'positions gained' property, but you can easily calculate it just by taking current (optionally: live) position and subtracting their starting position.

#4

Just to inverse the calcul to get in good place ;)
return results.OrderByDescending(r => r.StartPosition - r.LivePosition ).ToList();

Dieser Thread ist archiviert.

Neue Antworten finden auf Discord statt.

Auf Discord weiterlesen