The online racing simulator
Extracting and displaying car info (C#)
Simple question - with probably a very complicated answer

I want to extract car data from LFS (for instance, vehicle speed) and display it on the screen.

I think I've found the bit in InSim.txt that refers to the vehicles speed - it says that the IS_MCI packet contains an array of data including..

Quote :word Speed; // speed (32768 = 100 m/s)

The idea is something like this...

InSim.Send_BTN_CreateButton > Speed in real(ish) time.

I assume that the MCI packet is sent on a regular basis - and I think I want to be extracting the Speed value from the MCI?

How do I go about grabbing this data from LFS and displaying it?
Yes, MCI's are sent at regular intervals (if you enable MCI packets when initialising the InSim - you also specify the interval at the same time). You can also request a batch of MCI packets at any time.

You'll want to retrieve the data from the packet (or local array depending on the implementation of the library you're using) then convert it to either mph or km/h and send it in a button to screen.

I'm sorry I can't be more specific, I know very little C# as you know
lol, you know a shed load more than me!

I'm using the base InSIm template that's avaliable here - and hammering the hell out of it as I learn - while also making my own .txt guide as I go along, with info stolen from whoever will have the patience to help!

Therefore I assume that MCI packets are enabled 'by default', and that a time interval is already specified.

Now I need to figure out where in the program this is specified, play with it and try to figure it out.

So.... if I have the MCI packets set to be sent every 1 second for example and have a command in the script that says something like:

Quote :Whenever an MCI packet is recieved, look up the variable 'Speed' and display it on a button.

Or...

Quote :private void MCI_CarInformation(Packets.IS_MCI MCI) <<On recieving an MCI packet?
{
InSim.Send_BTN_CreateButton("MCI_"Speed", Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, 0010, Connections[GetConnIdx(Players[GetPlyIdx(MCI.PLID)].UniqueID)].UniqueID, 2, false);
}

Where: On recieving an MCI packet, make a button, take from this packet of this part and display to this player?

I invented this - so is probably totally wrong - any clarification is gratefully recieved (in n00bspeak if at all possible ).
In pseudo-ish code: (not in any particular language, so the syntax is probably wrong and will likely need to be tweaked to make work with whatever InSim API/Library you're using)

private void MCI_CarInformation(Packets.IS_MCI MCI) [COLOR=Red]<< I assume this is triggered when an MCI packet is received[/COLOR]
{
[COLOR=Lime]InSim.Send_BTN_CreateButton[/COLOR]([COLOR=Magenta]MCI[/COLOR].[COLOR=Blue]Speed[/COLOR] * mpsToMPH, Flags.ButtonStyles.ISB_LIGHT, 7, 66, 2, 67, 0010, Connections[[COLOR=DarkRed]GetConnIdx(Players[GetPlyIdx(MCI.PLID)[/COLOR]].UniqueID)].UniqueID, 2, false);
}

Almost all my knowledge of InSim is just from reading insim.txt - reading it all through gives a very good idea of how it all works. The nitty gritty of how to actually do useful things with it is all in the particular implementation


I should probably take a proper look at the C# InSim library at some point, but I actually find C/C++ simpler for my needs.

FGED GREDG RDFGDR GSFDG