The online racing simulator
SMALL_LCS Inside InSimDotNet
(14 posts, started )
SMALL_LCS Inside InSimDotNet
Hello, I am coding a local InSim so I did not found the packet SMALL_LCS on the InSim, there are the other packets but did not have this one (LocalCarSwitches).
Can someone help me?

*I know how to do this with socket connection but I want to do this inside my InSimDotNet project without doing two connections.
Hello, all info needed are inside InSim.txt file in docs folder Smile


Send this packet to control lights/horn/siren:

insim.Send(new IS_SMALL {ReqI = 0, SubT = (InSimDotNet.Packets.SmallType)9, UVal = 0});

UVal is the number that detects the configuration. It is the SUM of everything that you want to edit.


SIGNALS:
+1 (turn signals off), +257 (turn left indicator on), +513 (turn right indicator on), +769 (hazard on)


FLASH:
+2 (turn flash off), +1026 (turn flash on)


HEADLIGHTS:
+4 (turn headlights off), +2052 (turn headlights on)


HORN:
+8 (turn horn off), +65544 (turn horn1 on), +131080 (turn horn2 on), +196616 (turn horn3 on), +262152 (turn horn4 on), +327688 (turn horn5 on)


SIREN:
+16 (turn siren off), +1048592 (turn FastSiren on), +2097168 (turn SlowSiren on)
Thank You very much Big grin
I will try, soon I will answer if works.
Big grin
Thank You again.
Works Big grin
Thank You
Just one more question, how did You got these numbers?
Just taking the binary numbers from InSim.txt and converting them in decimal ones.

For example, Let's say we want to turn on "fast siren":


#define LCS_SET_SIREN 0x10 //bit 4

- "bit 4" means that we have to set the 4th bit at 1, to enable siren control.
- Bin Number: "10000" -----> Decimal Number: "16".
- (bits are counted from right to left, starting from zero)


// bits 20-21 (Switches & 0x300000) - Siren (0 off / 1 fast / 2 slow)

- "bits 20-21" means that we must create a bin number with 2 digits.
- "1 fast" means that we have to create the bin number 1, that is: "01".
- Now lets create the complete bin number (because these 2 bits didnt start from zero position, but from 20th slot): "0100000000000000000000" -----> Decimal: "1048576".


Then let's sum: 16 + 1048576 = 1048592.
So, if I want to turn on the hazards I should do this:

#define LCS_SET_SIGNALS 1 // bit 0

- bit 0 means that we have to set nothing at 1 to turn on the hazard.
- Binary 1 = 1 Decimal

// bits 8-9 (Switches & 0x0300) - Signal (0 off / 1 left / 2 right / 3 hazard)

- 3 hazard means that we have to create the bin number 3, that is 3.
- So the binary will be 0000001100000000
Decimal = 768

768 + 1 = 769

Right?
Yea. "bit 0" means that you have to set at 1 the bit at position zero, though.

I suggest also to define constants in your project, like this:

const long FastSiren = 1048592;
const long Hazard = 769;

So then you can use names instead of numbers for UVal:

UVal = FastSiren + Hazard, for example

And you understand better what your code actually does Smile
The hazard doesnt work here :/
Probably because you are sending multiple is_small packets at the same time. Send only one containing the whole configuration.
Anyway, I see DarkTimes is adding this stuff in his library Smile
Ty Big grin
I missed an InSim release last year, which is why this packet wasn't included. I don't check the forum often, so had been relying on people notifying me when any InSim changes are made.

I released a new version of InSim.NET (2.3.2) which lets you set the car switches like this:


<?php 
// Turn siren on
insim.Send(new IS_SMALL
{
    
SubT SmallType.SMALL_LCS,
    
UVal LocalCarSwitches.LCS_SIREN_SLOW
});

// Turn multiple switches on (horn & flash) with bitwise OR operator
insim.Send(new IS_SMALL
{
    
SubT SmallType.SMALL_LCS,
    
UVal LocalCarSwitches.LCS_HORN_1 LocalCarSwitches.LCS_FLASH_ON
});

// You can turn switches off as well
insim.Send(new IS_SMALL
{
    
SubT SmallType.SMALL_LCS,
    
UVal LocalCarSwitches.LCS_HORN_OFF
});
?>

There are more options available in the LocalCarSwitches class. Hope it works!
Great work. Thumbs up
Thank You DarkTimes Big grin

SMALL_LCS Inside InSimDotNet
(14 posts, started )
FGED GREDG RDFGDR GSFDG