Oolite Bulletins

For information and discussion about Oolite.
It is currently Fri Jul 28, 2017 12:44 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Apr 07, 2017 10:54 pm 
Offline
Deadly
Deadly

Joined: Thu Aug 27, 2015 4:24 pm
Posts: 184
1] Can the number of entities a ship be randomized?
(For example the number containers a cargoship carries on his hull)

2] Does the shipdata list have any conditional options to do such a thing?


Top
   
PostPosted: Sat Apr 08, 2017 12:12 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2311
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
HammerHead contain a solution. The shipdata contain twelve cargo subentities and a line:
Code:
script = "aquatics_hammerHead.js";
The relevant lines in this ship script:
Code:
this.shipSpawned = function()
	{
	this.randomiseCargo();
	}

this.randomiseCargo = function()
	{
	if(Math.random() < (Math.random() / 3) 
		&& this.ship.subEntities && this.ship.subEntities.length > 2)
		{
		this.ship.subEntities[0].remove();
		this.randomiseCargo();
		}
	}

_________________
OXPs by Norby


Top
   
PostPosted: Sat Apr 08, 2017 12:51 pm 
Offline
Deadly
Deadly

Joined: Thu Aug 27, 2015 4:24 pm
Posts: 184
Thanks, if I read this correctly,

1) define all subentities in the shipdata.
2) when spawning the ship remove a random number of subentities ( which in this case are all the same ) via an external .js script.


Top
   
PostPosted: Sat Apr 08, 2017 2:24 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2311
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Yes. If your subentities are not the same then check the dataKey first.

_________________
OXPs by Norby


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

All times are UTC


Who is online

Users browsing this forum: No registered users 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