System: make auto hold usable

This commit is contained in:
Sidi Liang 2020-04-20 14:36:26 +08:00
parent 4b9e9d4f2f
commit 8ab7dda6ee
No known key found for this signature in database
GPG Key ID: 79F0A6B20B72F42F
7 changed files with 101 additions and 4 deletions

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>parkingbrake</name>
<inherits-from>/Effects/model-combined-deferred</inherits-from>
<parameters>
<!-- Light Map -->
<lightmap-enabled type="int">1</lightmap-enabled>
<lightmap-multi type="int">1</lightmap-multi>
<texture n="3">
<image>../Interior/luxury/autohold_switch.png</image>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
</texture>
<lightmap-factor type="float" n="0">1</lightmap-factor>
<lightmap-factor type="float" n="1">1</lightmap-factor>
<lightmap-factor type="float" n="2">1</lightmap-factor>
<lightmap-color type="vec3d" n="0"> 1. 0. 0. </lightmap-color>
<lightmap-color type="vec3d" n="1"> 0. 1. 0. </lightmap-color>
<lightmap-color type="vec3d" n="2"> 0. 0. 1. </lightmap-color>
<lightmap-factor type="float" n="3">0</lightmap-factor>
</parameters>
</PropertyList>

Binary file not shown.

After

(image error) Size: 32 KiB

View File

Before

(image error) Size: 9.9 KiB

After

(image error) Size: 9.9 KiB

View File

@ -2041,7 +2041,7 @@ kids 0
OBJECT poly
name "autohold_switch"
loc 1.49125 0.76676 -0.0165006
texture "autohold.png"
texture "autohold_switch.png"
crease 45.000000
numvert 8
-0.0125815 0.00182033 -0.0114677

View File

@ -97,6 +97,70 @@
</animation>
<!-- Auto hold -->
<!--<effect>
<inherits-from>Aircraft/followme_e-tron/Models/Effects/autohold</inherits-from>
<object-name>autohold_switch</object-name>
</effect>-->
<animation>
<type>pick</type>
<object-name>autohold_switch</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>autohold.toggleAutoHold()</script>
</binding>
</action>
</animation>
<animation>
<type>material</type>
<object-name>autohold_switch</object-name>
<condition>
<equals>
<property>systems/auto_hold_enabled</property>
<value>1</value>
</equals>
</condition>
<texture>autohold_switch_LIT.png</texture>
</animation>
<animation>
<type>material</type>
<object-name>autohold_switch</object-name>
<condition>
<equals>
<property>systems/auto_hold_enabled</property>
<value>0</value>
</equals>
</condition>
<texture>autohold_switch.png</texture>
</animation>
<animation>
<type>material</type>
<object-name>autohold_LIT</object-name>
<condition>
<equals>
<property>systems/auto_hold_working</property>
<value>1</value>
</equals>
</condition>
<texture>autohold_LIT.png</texture>
</animation>
<animation>
<type>material</type>
<object-name>autohold_LIT</object-name>
<condition>
<equals>
<property>systems/auto_hold_working</property>
<value>0</value>
</equals>
</condition>
<texture>panel_black.png</texture>
</animation>
<!-- Hand brake -->
<effect>
<inherits-from>Aircraft/followme_e-tron/Models/parkingbrake</inherits-from>

View File

@ -1,7 +1,9 @@
#//Auto hold system by Sidi Liang
print("Auto hold system loaded");
var active = 0;
var activeNode = props.getNode("systems/auto_hold_enabled", 1);
var working = 0;
var workingNode = props.getNode("systems/auto_hold_working", 1);
var targetSpeed = 0;
var throttleNode = props.getNode("/controls/engines/engine/throttle",1);
var speedNode = props.getNode("sim/multiplay/generic/float[15]", 1);
@ -18,18 +20,21 @@ var autoHoldMainLoop = func(){
if(!door1.getpos() and !door2.getpos() and !door3.getpos() and !door4.getpos() and engineNode.getValue()){
followme.brakeController.applyBrakes(1);
working = 1;
workingNode.setValue(1);
}else{
stopAndSwitchToParking();
}
}else if(!math.round(currentSpeed)){
followme.brakeController.applyBrakes(0);
working = 0;
}
workingNode.setValue(0);
}
}
}
var stopAndSwitchToParking = func(){
followme.brakeController.applyBrakes(0);
working = 0;
workingNode.setValue(0);
followme.brakeController.enableHandBrake();
}
@ -38,21 +43,25 @@ var autoHoldTimer = maketimer(0.05,autoHoldMainLoop);
var startAutoHold = func(){
autoHoldTimer.start();
active = 1;
activeNode.setValue(1);
}
var stopAutoHold = func(){
active = 0;
activeNode.setValue(0);
autoHoldTimer.stop();
currentSpeed = speedNode.getValue();
if(followme.brakeController.applyingFeetBrake){
working = 0;
workingNode.setValue(0);
followme.brakeController.applyBrakes(0);
}else{
}else if(!math.round(currentSpeed)){
stopAndSwitchToParking();
}
}
var toggleAutoSpeed = func(){
var toggleAutoHold = func(){
if(!autoHoldTimer.isRunning) startAutoHold();
else stopAutoHold();
}

View File

@ -117,6 +117,8 @@ props.getNode("systems/pmodel-enable", 1).setValue(1);
props.getNode("systems/decorations-enable", 1).setValue(0);
props.getNode("systems/interior/type", 1).setValue("Default");
props.getNode("systems/safety/aeb_activated", 1).setValue(0);
props.getNode("systems/auto_hold_enabled", 1).setValue(0);
props.getNode("systems/auto_hold_working", 1).setValue(0);
#var Led = {
#