Board index FlightGear Development Nasal

airportinfo always returns a non-object  Topic is solved

Nasal is the scripting language of FlightGear.

airportinfo always returns a non-object

Postby TheEagle » Mon Aug 09, 2021 8:48 pm

Using this code in an addon:
Code: Select all
130 var aptName = "Uetersen (EDHE)"
131 me.tgt_apt = airportinfo(aptName);
132     
133 # find selected runway
134 foreach (var r; keys(me.tgt_apt.runways)) {
135     var curr = me.tgt_apt.runways[r];
136     if (me.tgt_apt.runways[r].id == rwyName) {
137         me.tgt_rwy = curr;
138         break;
139     }
140 }

gives me following error:
Code: Select all
  562.48 [ALRT]:nasal      Nasal runtime error: non-objects have no members
  562.48 [ALRT]:nasal        at /some/path/fgfs-addons/LandingChallenge/landingChallenge.nas, line 134

Why ? What did I do wrong, and how is it done right ?
Last edited by TheEagle on Mon Aug 09, 2021 10:04 pm, edited 1 time in total.
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: airportinfo always returns a non-object  

Postby TheEagle » Mon Aug 09, 2021 10:03 pm

ARGH :x this one was sneaky … In the end, it turned out that aptInfo's content was the cause:
Code: Select all
print(aptName)

Output:
Uetersen (EDHE)

Setting aptInfo to EDHE resolved the whole issue !
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: airportinfo always returns a non-object

Postby Gijs » Tue Aug 10, 2021 9:11 am

Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9544
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests