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?
[?] Can the number of entities a ship be randomized
Moderators: winston, another_commander
- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: [?] Can the number of entities a ship be randomized
HammerHead contain a solution. The shipdata contain twelve cargo subentities and a line:
The relevant lines in this ship script:
Code: Select all
script = "aquatics_hammerHead.js";
Code: Select all
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();
}
}
Re: [?] Can the number of entities a ship be randomized
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.
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.
- Norby
- ---- E L I T E ----
- Posts: 2577
- Joined: Mon May 20, 2013 9:53 pm
- Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
- Contact:
Re: [?] Can the number of entities a ship be randomized
Yes. If your subentities are not the same then check the dataKey first.