ATVO by Appgineering
Download
Read-only

Order Drivers by positions gained

4 posts 2,910 views Started 15 Dec 2020, 18:22
Showing 1–4 of 4 posts
Harold D.
Original poster

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 Thissen Appgineering
Reply #1

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.

Emmanuel S.
Reply #3

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

Archive · Read-only

New replies have moved to Discord.