Josh Babcock wrote:
> OK, this works great: (other than the fact that it doesn't actually do
> anything yet)
> 
> gearLightCheck = func {
>     for (i=0; i<3; i=i+1) {
>         thisProp = "/gear/gear[" ~ i ~ "]/position-norm";
>         if ( getprop(thisProp) == 1 ) {
>             print("green");
>         } elsif ( getprop(thisProp) == 0 ) {
>             print("off");
>         } else {
>             print("red");
>         }
>     }
>     settimer(gearLightCheck, 5);
> }
> 
> but this
> 
> gearLightCheck = func {
>     for (i=0; i<3; i=i+1) {
>         thisProp = "/gear/gear[" ~ i ~ "]/position-norm";
>         if ( getprop(thisProp) == 1 ) {
>             print("green");
>         } elsif ( getprop(thisProp) < 1 ) {          <---- Line 143
>             print("red");
>         } else {
>             print("off");
>         }
>     }
>     settimer(gearLightCheck, 5);
> }
> 
> produces this error:
> Nasal runtime error: nil used in numeric context
>    at /usr/local/share/FlightGear/data/Aircraft/b29/b29.nas, line 143
> 
> I know these props are set, because I put the following in the set.xml file:
> 
>  <controls>
>   <gear>
>    <nosewheel-caster type="bool" archive="y">true</nosewheel-caster>
>    <antiskid type="bool" archive="y">false</antiskid>
>    <gear num="0">
>     <position-norm>0</position-norm>
>    </gear>
>    <gear num="1">
>     <position-norm>0</position-norm>
>    </gear>
>    <gear num="2">
>     <position-norm>0</position-norm>
>    </gear>
>    <gear num="3">
>     <position-norm>0</position-norm>
>    </gear>
>   </gear>
>  </controls>
> 
> As an aside, the initial output looks like this:
> b29-common.xml initialized
> 0: red
> 1: red
> 2: red
> 3: red
> WARNING: Legacy engine definition in YASim configuration file.  Please fix.
> WARNING: Legacy engine definition in YASim configuration file.  Please fix.
> WARNING: Legacy engine definition in YASim configuration file.  Please fix.
> WARNING: Legacy engine definition in YASim configuration file.  Please fix.
> 0: green
> 1: green
> 2: green
> 3: green
> 0: green
> 1: green
> 2: green
> 3: green
> 
> Any thoughts?
> 
> Josh
> 
> _______________________________________________
> Flightgear-devel mailing list
> Flightgear-devel@flightgear.org
> http://mail.flightgear.org/mailman/listinfo/flightgear-devel
> 2f585eeea02e2c79d7b1d8c4963bae2d
> 

Umm, never mind. I was setting /controls/gear/... instead of /gear/...
I had the solution a while ago, just typoed it away. Just a case of
NASAL starting up before YASim gets a chance to  create the node.
Mea culpa.

Josh

_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to