entity.remove() does not throw an error for inValid entity.

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

entity.remove() does not throw an error for inValid entity.

Post by Capt. Murphy »

As the subject says......

entity.remove() does not throw an error for an inValid entity.

I kind of think it probably should..... :?
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: entity.remove() does not throw an error for inValid enti

Post by Switeck »

The sort of error that stops the rest of the script or the sort of error that sends a message to Latest.log but continues running?
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: entity.remove() does not throw an error for inValid enti

Post by Capt. Murphy »

The sort that logs a warning in latest.log but lets the script carry on.

I can see some scratching chins as to why a notification that something you are trying to invalidate is already in that state is necessary, but if the function could do one of several things to said entity depending on circumstances it might be handy to remind scripters (i.e. me) to include appropriate validation. :roll:
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: entity.remove() does not throw an error for inValid enti

Post by Switeck »

A warning in latest.log is more than I get for the sort of problems I have. :lol:
(These are mostly self-inflicted due to a typo or logic error on my part, so I won't trouble you with them.)

Still anyone who is writing an OXP script should be checking latest.log both for errors and warnings. If not, the community may well correct them. :mrgreen:

Timing of a removal can be tricky if something else kills it at that same moment. Would something like an if(entity != null) check before removing it help in your case?
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: entity.remove() does not throw an error for inValid enti

Post by Kaks »

To be honest, I think the best behaviour here would be it returning false if the entity to remove couldn't be removed because it was being removed already.

IIRC, that's consistent with a number of other functions...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Post Reply