Oolite Bulletins

For information and discussion about Oolite.
It is currently Tue Sep 19, 2017 11:48 am

All times are UTC




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Jul 17, 2017 11:03 am 
Offline
Average
Average

Joined: Wed Jul 12, 2017 12:53 pm
Posts: 15
Hi,

I've been debugging a broken OXP and I got a bit confused about the behaviour of the missionVariables object. The OXP I'm looking at checks to see if a missionVariable exists using missionVariables.hasOwnProperty('mission_prop');. This is probably redundant in the case in question anyway, but it seems like this returns false even if the property does exist and has a value. Does missionVariables use some dark JS magic that prevents properties showing up to hasOwnProperty? If not it's possible that I'm just getting confused, but I thought I'd check before I waste any more time trying to work out what's going on!

Cheers,


Top
   
PostPosted: Mon Jul 17, 2017 10:42 pm 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1701
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
I ran this test:
Code:
	log(this.name, "test 1 " + (missionVariables.hasOwnProperty("myTest") === true ? "yes" : "no"));
	missionVariables.myTest = "hello world";
	log(this.name, "test 2 " + (missionVariables.hasOwnProperty("myTest") === true ? "yes" : "no"));
The output was:
Code:
	test 1 no
	test 2 yes
So on the surface at least it seems to work.

_________________
My OXP's


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: gsagostinho and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited