Community Forum

Steering wheel rotation

Forum Overview >> Scripting

CategoryScripting
Created26.10.2019 16:44


Raphal Ce (roffcoff) 26.10.2019 16:44
I want to make a super simple script that changes the outdoor sterring wheel rotation from 30 to 540 degrees. I usually modify each tractor with the following values in the .xml
<steeringWheel node="steeringWheel" indoorRotation="30" outdoorRotation="540"/> to <steeringWheel node="steeringWheel" indoorRotation="540" outdoorRotation="540"/>
Since the Claas DLC vehicles are inaccessible to modify I want to create this script, no UI only a function that sets the current vehicles outdoor steering to 540.
Can someone point me in the right direction in the documentation?

Bilbo Beutlin (BBeutlin) 26.10.2019 22:14
You need to bypass certain functions in the drivable.lua and replace by yours.
But it looks like you have barely experience in FS scripting. That's not suitable for beginners.

Start with examining ready scripts eg. those available on ModHub.

Raphal Ce (roffcoff) 26.10.2019 23:25
Yeah, I'm currently modifying a realistic steering speed script. Think I understand the basic code for creating a bypass. Now only trying to decipher the code that controls the rotation, found it under drivable.updateSteeringWheel in the documentation. Wish me luck..

Raphal Ce (roffcoff) 27.10.2019 13:22
Trying the very simplest solution I found a script that changes the default camera to inside and modified it. Original script works and my modification seems to load without a problem according to the log. It creates a specialization that performs a functionwhen entered in the vehicle. Since steeringWheel angle is camera dependent I figured I could use the indoor camera script but make it change the rotation instead. Not that simple I guess... Whats wrong with this function:

function SteeringRotation:init(vehicle)
vehicle.SteeringRotation = {};
vehicle.SteeringRotation.initialized = true;

if vehicle.spec_enterable ~= nil then
for camIndex, camera in pairs(vehicle.spec_enterable.cameras) do
if camera.isOutside then
vehicle.spec_drivable.steeringWheel:setOutdoorRotation(540);
end;
end;
end;
end;

function SteeringRotation:onEnterVehicle()
if self.spec_enterable ~= nil then
if self.SteeringRotation == nil then
SteeringRotation:init(self);
else
if self.lastCam ~= nil then
if g_gameSettings:getValue("resetCamera") and (self.lastCam ~= self.spec_enterable.camIndex) then
self.spec_enterable:setActiveCameraIndex(self.lastCam);
end;
end;
end;
end;
end;

function SteeringRotation:onLeaveVehicle()
if self.spec_enterable ~= nil then
self.lastCam = self.spec_enterable.camIndex;
end;
end;

Raphal Ce (roffcoff) 27.10.2019 13:25
double post

Bilbo Beutlin (BBeutlin) 28.10.2019 03:25
What is "vehicle.spec_drivable.steeringWheel:setOutdoorRotation(540)" ? *g*

Set the rotation limits (x degrees) with
- vehicle.spec_drivable.steeringWheel.indoorRotation = math.rad(x)
respectively
- vehicle.spec_drivable.steeringWheel.outdoorRotation = math.rad(x)

See also LUADOCs -> drivable.lua


Note: Log in to post. Create a new account here.