For test results, bug reports, announcements of new builds etc.
Moderators: winston , another_commander , Getafix
phkb
Impressively Grand Sub-Admiral
Posts: 4830 Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.
Post
by phkb » Wed Oct 28, 2015 11:04 pm
I'm running this code to determine if a ship has missiles:
Code: Select all
if (ship.missiles) {
...some code to run when there are missiles...
}
However, if there are no missiles installed I get this error:
Code: Select all
Error: Native exception: Tried to init array with nil object
I tried doing
if (ship.missiles.length > 0)
and even adding a check for
missileCapacity
but neither solution worked. In the end I put the code into a try/catch block to work around the issue.
Norby
---- E L I T E ----
Posts: 2577 Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:
Post
by Norby » Wed Oct 28, 2015 11:23 pm
Norby
---- E L I T E ----
Posts: 2577 Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:
Post
by Norby » Fri Oct 30, 2015 11:47 am
Working well at me, thank you!