But I'm really not sure how to script that.
Came up with this code and it sort of works the way I was planning.
The evac button will not move back out again until the horncutout switch is pressed and then again turn the evac light off again.
But the thing I want is that the evac button will spring back into place without the light go back off.
If I get you right, this should work:
Code:
<PartInfo>
<Name>oh_evac_signal_horncut_switch</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:oh evac signal cutout,bool) 50 *
</Code>
<Lag>300</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Evac Signal Horn Cutout</TooltipText>
<MouseFlags>LeftSingle+LeftRelease+LeftDrag</MouseFlags>
<CallbackCode>
(M:Event) 'LeftSingle' scmp 0 ==
if{ 1 (>L:oh evac signal cutout,bool) 0 (>L:oh evac signal command,bool) }
els{ 0 (>L:oh evac signal cutout,bool) }
</CallbackCode>
</MouseRect>
</PartInfo>
<PartInfo>
<Name>oh_evac_signal_command</Name>
<AnimLength>50</AnimLength>
<Animation>
<Parameter>
<Code>
(L:oh evac signal command,bool) 50 *
</Code>
<Lag>300</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>Command Evac Signal</TooltipText>
<MouseFlags>LeftSingle</MouseFlags>
<CallbackCode>
<CallbackCode>
1 (>L:oh evac signal command,bool)
</CallbackCode>
</CallbackCode>
</MouseRect>
</PartInfo>
<PartInfo>
<Name>oh_evac_visible</Name>
<Visibility>
<Parameter>
<Code>
(A:ELECTRICAL MASTER BATTERY,bool)
(L:oh evac signal command,bool) and
</Code>
</Parameter>
</Visibility>
</PartInfo>
Now, a bit of conceptuals:
Code:
[FONT="Courier New"]! (>L:oh evac signal command,bool)[/FONT]
works in your example because, as the stack is empty at the beginning of the script, it is the same as writing
Code:
[FONT="Courier New"]1 (>L:oh evac signal command,bool)[/FONT].
However, if there is a chance that the stack could not be empty, the value assigned could be uncertain so it is preferable to use the last format. Also
> can be replaced with
> without trouble, which improves the reading.
When you test for one to several conditions for a true/false value, it is not necessary to
conditionaly check for the result of the previous condition as it is already stored in the stack.
For example
Code:
[FONT="Courier New"](A:ELECTRICAL MASTER BATTERY, bool)
(L:oh evac signal command,bool) and [/FONT]
stores 1 in the stack if it is true, else stores 0
so, if it is
true:
1
if{ 1 } els{ 0 } returns 1
and if it is
false:
0 if{ 1 }
els{ 0 } returns 0
Then the the entire if{} els{} is redundant and can be discarded.
In case you need an inverse result, ie 0 -> 1 and 1 -> 0 , negating the conditional gives the same:
Code:
[FONT="Courier New"](A:ELECTRICAL MASTER BATTERY, bool)
(L:oh evac signal command,bool) and [B]![/B]
[/FONT]
Also remember that every if{ and els{ must end with a }, to ensure that the script will execute properly. Sometimes, like in your example:
Code:
[FONT="Courier New"]<Code>
(A:ELECTRICAL MASTER BATTERY,bool) 0 !=
if{
(L:oh evac signal command,bool) 1 == if{ 1 } els{ 0 }
</Code>
[/FONT]
it will work ok because the end of the script finishes the parsing, but if it is otherwise it could turn debuggin into a nightmare.
Tom