Hi all
One thing I'd like someone to explain to me: how do you code the duration of an animation?
Thank you for your help.
<!-- Primer -->
<animation>
<type>pick</type>
<object-name>PrimerLever</object-name>
<visible>true</visible>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>c172p.pumpPrimer();</script>
</binding>
<binding>
<command>nasal</command>
<script>c172p.click("primer-in", 1.2)</script>
</binding>
<binding>
<command>nasal</command>
<script>c172p.click("primer-out", 1.2)</script>
</binding>
</action>
<hovered>
<binding>
<command>set-tooltip</command>
<tooltip-id>primer</tooltip-id>
<label>Engine primer (%1d)</label>
<property>controls/engines/engine/primer</property>
</binding>
</hovered>
</animation>
<animation>
<type>translate</type>
<object-name>PrimerLever</object-name>
<property alias="/params/controls/primer-lever-animation"/>
<factor>0.04</factor>
<axis>
<x>1.0</x>
<y>0.0</y>
<z>0.0</z>
</axis>
</animation>
# Toggles the state of the primer
var pumpPrimer = func {
var push = getprop("/controls/engines/engine/primer-lever") or 0;
if (push) {
var pump = getprop("/controls/engines/engine/primer") or 0;
setprop("/controls/engines/engine/primer", pump + 1);
setprop("/controls/engines/engine/primer-lever", 0);
}
else {
setprop("/controls/engines/engine/primer-lever", 1);
}
};
<filter>
<name>Controls Primer Lever</name>
<type>noise-spike</type>
<max-rate-of-change>1.1</max-rate-of-change>
<enable>
<condition>
<not>
<property>/sim/freeze/replay-state</property>
</not>
</condition>
</enable>
<input>
<property>/controls/engines/engine/primer-lever</property>
</input>
<output>
<property>/sim/model/c172p/cockpit/primer-lever-animation</property>
</output>
</filter>
# doors ============================================================
var leftDoor = aircraft.door.new( "/sim/model/door-positions/leftDoor", 2, 0 );
var rightDoor = aircraft.door.new( "/sim/model/door-positions/rightDoor", 2, 0 );
var leftWindow = aircraft.door.new( "/sim/model/door-positions/leftWindow", 2, 0 );
var rightWindow = aircraft.door.new( "/sim/model/door-positions/rightWindow", 2, 0 );
var baggageDoor = aircraft.door.new( "/sim/model/door-positions/baggageDoor", 2, 0 );
var oilDoor = aircraft.door.new( "/sim/model/door-positions/oilDoor", 1, 0 );
var gloveboxDoor = aircraft.door.new( "/sim/model/door-positions/gloveboxDoor", 1, 0 );
<channel name="Flaps">
<kinematic name="fcs/flaps-control">
<input>fcs/flap-cmd-norm</input>
<traverse>
<setting>
<position>0</position>
<time>0</time>
</setting>
<setting>
<position>8</position>
<time>3</time>
</setting>
<setting>
<position>15</position>
<time>3</time>
</setting>
<setting>
<position>25</position>
<time>4</time>
</setting>
<setting>
<position>42</position>
<time>4</time>
</setting>
</traverse>
<output>fcs/flap-pos-deg</output>
</kinematic>
<lag_filter name="/model/canopy-norm">
<input>/model/canopy-input</input>
<c1>4.0</c1>
</lag_filter>
To open and close the nose door and unfold the access ramp as well as open and close the left door for the crew and its staircase
var oilDoor = aircraft.door.new( "/sim/model/door-positions/oilDoor", 1, 0 );
<multiplay>
<chat_display>1</chat_display>
<generic>
~~~~~~
<float n="18" alias="/sim/model/door-positions/oilDoor/position-norm"/>
~~~~~~~
</generic>
</multiplay>
<!-- Oil door pick -->
<animation>
<type>pick</type>
<object-name>oildoor</object-name>
<visible>true</visible>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<condition>
<and>
<not>
<property>/engines/active-engine/running</property>
</not>
<or>
<property>/fdm/jsbsim/gear/unit[1]/WOW</property>
<property>/fdm/jsbsim/gear/unit[19]/WOW</property>
<property>/fdm/jsbsim/gear/unit[23]/WOW</property>
<property>/fdm/jsbsim/hydro/active-norm</property>
</or>
<or>
<not>
<property>/sim/current-view/internal</property>
</not>
<property>/nasal/tutorial/loaded</property>
</or>
</and>
</condition>
<command>nasal</command>
<script>
var engine = getprop("controls/engines/active-engine");
if (!engine)
fgcommand("dialog-close", props.Node.new({"dialog-name": "c172p-oil-dialog-160"}));
else
fgcommand("dialog-close", props.Node.new({"dialog-name": "c172p-oil-dialog-180"}));
setprop("sim/model/show-dip-stick", 0);
c172p.oilDoor.toggle();
</script>
</binding>
<binding>
<condition>
<and>
<property>/engines/active-engine/running</property>
<property>/engines/active-engine/oil_consumption_allowed</property>
</and>
</condition>
<command>nasal</command>
<script>
gui.popupTip("You can't check the oil level with the engine running!", 2);
</script>
</binding>
<binding>
<condition>
<and>
<not>
<or>
<property>/fdm/jsbsim/gear/unit[1]/WOW</property>
<property>/fdm/jsbsim/gear/unit[19]/WOW</property>
<property>/fdm/jsbsim/gear/unit[23]/WOW</property>
<property>/fdm/jsbsim/hydro/active-norm</property>
</or>
</not>
<property>/engines/active-engine/oil_consumption_allowed</property>
</and>
</condition>
<command>nasal</command>
<script>
gui.popupTip("You can't check the oil level while in the air!", 2);
</script>
</binding>
</action>
<hovered>
<binding>
<condition>
<and>
<not>
<property>/engines/active-engine/running</property>
</not>
<or>
<property>/fdm/jsbsim/gear/unit[1]/WOW</property>
<property>/fdm/jsbsim/gear/unit[19]/WOW</property>
<property>/fdm/jsbsim/gear/unit[23]/WOW</property>
<property>/fdm/jsbsim/hydro/active-norm</property>
</or>
<or>
<not>
<property>/sim/current-view/internal</property>
</not>
<property>/nasal/tutorial/loaded</property>
</or>
</and>
</condition>
<command>set-tooltip</command>
<tooltip-id>oil-door</tooltip-id>
<label>Oil Door</label>
</binding>
</hovered>
</animation>
<!-- Oil door animation -->
<animation>
<type>rotate</type>
<object-name>oildoor</object-name>
<property alias="../../params/doors/oil/property"/>
<interpolation>
<entry>
<ind>0.0</ind>
<dep>0.0</dep>
</entry>
<entry>
<ind>0.5</ind>
<dep>-45.0</dep>
</entry>
<entry>
<ind>1</ind>
<dep>-90.0</dep>
</entry>
</interpolation>
<axis>
<x1-m>-0.80485</x1-m>
<y1-m> 0.23079</y1-m>
<z1-m> 0.16388</z1-m>
<x2-m>-0.88058</x2-m>
<y2-m> 0.2303</y2-m>
<z2-m> 0.16328</z2-m>
</axis>
</animation>
Octal450 wrote in Sun Mar 19, 2023 3:16 am:Any value in JSBsim is updated like that...
Octal450 wrote in Tue Mar 21, 2023 4:38 am:I believe that the animation is re-rendered with whatever value is present when it do it, regardless of if the value changed or not.
Users browsing this forum: No registered users and 12 guests