- Messages
- 1,451
- Country
Hello
I have a 3d part knob in the VC which controls the panel and cabin lights. All actions taken by this knob, are meant to be active only if the battery switch is ON and the light master switch is also ON. The solution I came to, provides a fully functional animation for the 4 positions and the code already monitors, controls and activates the Panel Lights as I want to.
Since
Key 0: Both lights Off
Key 25: Cockpit lights ON
Key 50: Cabin lights ON
Key 75: Both lights ON
A left mouse click or mouse wheel up, controls the knob positions from 0 to 3. The reverse switch action is activated with a right mouse click or using the mouse wheel down (from position 3 to 0).
And this is the code I wrote:
If I understood well what Tom Gibson once explained in several threads, it is desireable to have the K events in the mouse section because they only be evaluated once if it exist a mouse action. In my book at least, 1 vs 18 evaluations is the way to go. As a side note, this is the only 3d object which includes the logic in the Part code.
Any help, certainly will be very much appreciated.
In advanced, thank you.
Sergio.
I have a 3d part knob in the VC which controls the panel and cabin lights. All actions taken by this knob, are meant to be active only if the battery switch is ON and the light master switch is also ON. The solution I came to, provides a fully functional animation for the 4 positions and the code already monitors, controls and activates the Panel Lights as I want to.
Since
(A:LIGHT CABIN,bool)
has (K:TOGGLE_CABIN_LIGHTS)
as the only available K event, I am having trouble to control when the cabin lights are ON or OFF. This issue seems to be trivial; however, I can't find the proper conditions to make this work. The basic idea is described below:Key 0: Both lights Off
Key 25: Cockpit lights ON
Key 50: Cabin lights ON
Key 75: Both lights ON
A left mouse click or mouse wheel up, controls the knob positions from 0 to 3. The reverse switch action is activated with a right mouse click or using the mouse wheel down (from position 3 to 0).
And this is the code I wrote:
HTML:
<part>
<name>MD900_CKP_CAB_lt_knob</name>
<animation>
<parameter>
<code>
(L:MD_900_CKP_CAB_lights_knob,number) 25 *
</code>
<lag>300</lag>
</parameter>
</animation>
<mouserect>
<cursor>Hand</cursor>
<tooltip_text>Panel/Cabin Lights UP (LMB)/DOWN (RMB)</tooltip_text>
<mouse_flags>LeftSingle+RightSingle+WheelUp+WheelDown</mouse_flags>
<callback_code>
(M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or
if{
(L:MD_900_CKP_CAB_lights_knob,number) ++ 4 min (>L:MD_900_CKP_CAB_lights_knob,number)
<!-- Click Sound Effect -->
1 (>L:MD_900_Click, number)
<!-- Switch position 0, both lights OFF -->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 0 == and
if{
(A:LIGHT PANEL,bool) if { (>K:PANEL_LIGHTS_OFF) }
(A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
<!-- Switch position 1: Cockpit light ON, Cabin lights OFF -->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 1 == and
if{
(A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
(A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
<!-- Switch position 2: Cockpit light OFF, Cabin lights ON -->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 2 == and
if{
(A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_OFF) }
(A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
<!-- Switch position 3, both lights ON-->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 3 == and
if{
(A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
(A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
}
(M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or
if{
(L:MD_900_CKP_CAB_lights_knob,number) -- 0 max (>L:MD_900_CKP_CAB_lights_knob,number)
<!-- Click Sound Effect -->
1 (>L:MD_900_Click, number)
<!-- Switch position 0, both lights OFF -->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 0 == and
if{
(A:LIGHT PANEL,bool) if { (>K:PANEL_LIGHTS_OFF) }
(A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
<!-- Switch position 1: Cockpit light ON, Cabin lights OFF -->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 1 == and
if{
(A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
(A:LIGHT CABIN,bool) if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
<!-- Switch position 2: Cockpit light OFF, Cabin lights ON -->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 2 == and
if{
(A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_OFF) }
(A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
<!-- Switch position 3, both lights ON-->
(L:Battery_switch_position,number) 1 == (L:MD_900_LT_Master_Switch,bool) and (L:MD_900_CKP_CAB_lights_knob,number) 3 == and
if{
(A:LIGHT PANEL,bool) ! if { (>K:PANEL_LIGHTS_ON) }
(A:LIGHT CABIN,bool) ! if{ (>K:TOGGLE_CABIN_LIGHTS) }
}
}
</callback_code>
</mouserect>
</part>
If I understood well what Tom Gibson once explained in several threads, it is desireable to have the K events in the mouse section because they only be evaluated once if it exist a mouse action. In my book at least, 1 vs 18 evaluations is the way to go. As a side note, this is the only 3d object which includes the logic in the Part code.
Any help, certainly will be very much appreciated.
In advanced, thank you.
Sergio.
Last edited: