Background: I try to improve the elevators on the FG aircraft carriers because they are way too slow.
As the speed depends on a tied property (transition-time) which is hardcoded to 150 (seconds I guess) I try to implement an alternative solution using the
aircraft.door..... mechanism which allows me to speed this up to 15 sec which is a lot more realistic for todays carrier elevators.
Problem:
I define the elevators in the XML <nasal><load> part of the carrier, as seen below
- Code: Select all
<nasal>
<load>
print("LOAD Vinson from ", cmdarg().getPath());
var fg_root = getprop("/sim/fg-root");
var self = cmdarg();
###########
# elevators
var elevator1 = aircraft.door.new("/surface-positions/elevator[0]", 15);
var elev1_node = self.getNode("surface-positions/elevator[0]/position-norm", 1);
# loop
var loop = func(id) {
...
var elev1 = getprop("/surface-positions/elevator[0]/position-norm");
elev1_node.setValue(elev1);
...
}
</load>
</nasal>
and later on I want to use this in an animation within the same carrier XML file, like below ...
- Code: Select all
<animation>
<type>pick</type>
<object-name>Elevator-1</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>
elevator1.toggle();
</script>
</binding>
</action>
</animation>
When I try this I get a Nasal error on the console which says:
"Nasal runtime error: undefined symbol: elevator1"
So obviously the variable of the nasal/open script is not known in the XML binding part.
What is the solution to this namespace problem ?
Thanks
Mike-DE