Code: Select all
this.startUp = function()
{
// expensive computations
}
Code: Select all
04:05:44.136 [script.javaScript.timeLimit]: ***** ERROR: Script "BalancedShipPrices" ran for 9.6251 seconds and has been terminated.
Moderators: winston, another_commander
Code: Select all
this.startUp = function()
{
// expensive computations
}
Code: Select all
04:05:44.136 [script.javaScript.timeLimit]: ***** ERROR: Script "BalancedShipPrices" ran for 9.6251 seconds and has been terminated.
startUp
functions is higher (maybe 30 seconds, or even a minute?), as it doesn't really have any impact on the gameplay. Maybe this could even be a config parameter, but that of course would require a bit more programming ... Code: Select all
this.shipEnteredStationAegis = function()
{
var birds = /bird/i;
var felines = /feline/i;
var frogs = /frog/i;
var humanoids = /humanoid/i;
var insects = /insect/i;
var lizards = /lizard/i;
var lobsters = /lobster/i;
var rodents = /rodent/i;
var colonials = /colonial/i;
if (player.ship.alertCondition == 2)
{
if(system.info.inhabitants.match(birds))
{
this.ship.mainStation.commsMessage("[bird-messages]");
}
if(system.info.inhabitants.match(felines))
{
this.ship.mainStation.commsMessage("[feline-messages]");
}
if(system.info.mainStation.inhabitants.match(frogs))
{
this.ship.commsMessage("[frog-messages]");
}
if(system.info.inhabitants.match(humanoids))
{
this.ship.mainStation.commsMessage("[humanoid-messages]");
}
if(system.info.inhabitants.match(insects))
{
this.ship.mainStation.commsMessage("[insect-messages]");
}
if(system.info.inhabitants.match(lizards))
{
this.ship.mainStation.commsMessage("[lizard-messages]");
}
if(system.info.inhabitants.match(lobsters))
{
this.ship.mainStation.commsMessage("[lobster-messages]");
}
if(system.info.inhabitants.match(rodents))
{
this.ship.mainStation.commsMessage("[rodent-messages]");
}
reconsider: 40;
}
}
You might want to tryRedspear wrote: ↑Thu Jan 06, 2022 12:35 amTrying to get stations to broadcast occasional messages based on system inhabitants.
No error reports which might suggest that something is missing...
I realise that within aegis isn't the same as on scanner (is that available?) but shouldn't the reconsider part mean that messages would come up if the player loitered outside the station?Code: Select all
this.shipEnteredStationAegis = function() { var birds = /bird/i; var felines = /feline/i; var frogs = /frog/i; var humanoids = /humanoid/i; var insects = /insect/i; var lizards = /lizard/i; var lobsters = /lobster/i; var rodents = /rodent/i; var colonials = /colonial/i; if (player.ship.alertCondition == 2) { if(system.info.inhabitants.match(birds)) { this.ship.mainStation.commsMessage("[bird-messages]"); } if(system.info.inhabitants.match(felines)) { this.ship.mainStation.commsMessage("[feline-messages]"); } if(system.info.mainStation.inhabitants.match(frogs)) { this.ship.commsMessage("[frog-messages]"); } if(system.info.inhabitants.match(humanoids)) { this.ship.mainStation.commsMessage("[humanoid-messages]"); } if(system.info.inhabitants.match(insects)) { this.ship.mainStation.commsMessage("[insect-messages]"); } if(system.info.inhabitants.match(lizards)) { this.ship.mainStation.commsMessage("[lizard-messages]"); } if(system.info.inhabitants.match(lobsters)) { this.ship.mainStation.commsMessage("[lobster-messages]"); } if(system.info.inhabitants.match(rodents)) { this.ship.mainStation.commsMessage("[rodent-messages]"); } reconsider: 40; } }
The relevant descriptions.plist has been written.
Any help gratefully received.
Code: Select all
this.ship.commsMessage(expandDescription("[rodent-messages]"));
Good idea but didn't work.montana05 wrote: ↑Thu Jan 06, 2022 2:29 amYou might want to tryCode: Select all
this.ship.commsMessage(expandDescription("[rodent-messages]"));
Code: Select all
if (player.ship.bounty > 20)
{
this.ship.target = player.ship;
this.launchPatrol(true);
this.ship.alertCondition++;
if (!this.playerWelcomed) this.ship.commsMessage(expandDescription("[spacebar-warning]"));
}
if (player.ship.bounty === 0)
{
this.ship.alertCondition--;
if (!this.playerWelcomed) this.ship.commsMessage(expandDescription("[spacebar-greeting]"));
}
Code: Select all
if (system.inhabitantsDescription.indexOf("Rodent") >= 0) this.ship.commsMessage(expandDescription("[rodent-message]"));
if (system.inhabitantsDescription.indexOf("Frog") >= 0) this.ship.commsMessage(expandDescription("[frog-message]"));
rinse and repeat for the different types of inhabitants. The indexOf is a useful test as it just means "includes the word", so you don't have to worry about whetehr they are furry, harmless, fat etc as it will detect the type of inhabitant as all variations include the word bird, frog, insect etc.
I did some tests this morning, however the result was the same as mentioned here: https://bb.oolite.space/viewtopic.php?f=3&t=5209. I would guess that this error is still pending.Redspear wrote: ↑Thu Jan 06, 2022 8:37 pmGood idea but didn't work.montana05 wrote: ↑Thu Jan 06, 2022 2:29 amYou might want to tryCode: Select all
this.ship.commsMessage(expandDescription("[rodent-messages]"));
I tried getting rid of the this. part and using system.mainStation as well but no luck.
At least I have another (albeit less desirable) way that I know works.
Thanks.
if (player.ship.alertCondition == 2)
condition means that messages will only be sent if the status is "Yellow" - but quite often, at the point of entering the aegis, my condition level is green (ie 1), so none of the messages will appear. That could also be preventing your messages from being seen.Yeah, I already have it working as a station AI...
Code: Select all
/* Comm Broadcasts */
{
condition: aiconditionPlayerNearby,
behaviour: function() {
if (this.ship.alertCondition !== 3)
this.ship.commsMessage("bird-messages]");
},
reconsider: 40
},
Yes, I was rather afraid of that... A consequence of my learning javascript purely from mucking about with Oolite...
When mass locked by the station however you are yellow - It was my way clumsy way of giving the player a chance to be in scanner range of the station.phkb wrote: ↑Fri Jan 07, 2022 6:53 amWrapping all the comms messages inside the if (player.ship.alertCondition == 2) condition means that messages will only be sent if the status is "Yellow" - but quite often, at the point of entering the aegis, my condition level is green (ie 1), so none of the messages will appear. That could also be preventing your messages from being seen.
I'm working on this.
Code: Select all
/* Comm Broadcasts */
{
preconfiguration: ai.configurationCheckScanner,
condition: ai.conditionScannerContainsPlayer,
//condition: aiconditionPlayerNearby,
behaviour: function() {
if (this.ship.alertCondition !== 3)
this.ship.commsMessage("[bird-messages]");
},
reconsider: 40
},
Code: Select all
this.shipEnteredStationAegis = function(station) {
if (station.isMainStation) {
this.$startTimer();
}
}
this.shipLaunchedFromStation = function(station) {
if (station.isMainStation) {
this.$startTimer();
}
}
this.shipExitedStationAegis = function(station) {
if (station.isMainStation) {
this.$stopTimer();
}
}
this.shipDockedWithStation = function(station) {
if (station.isMainStation) {
this.$stopTimer();
}
}
this.shipDied = function() {
this.$stopTimer();
}
this.$startTimer = function $startTimer () {
this.$stopTimer(); // make sure we stop the timer if it's already running
this._myTimer = new Timer(this, this.$sendMessageTimer, 1, 40); // first timer will fire after 1 sec, but after that will fire every 40 secs
}
this.$stopTimer = function $stopTimer () {
if (this._myTimer && this._myTimer.isRunning) this._myTimer.stop();
}
this.$sendMessageTimer = function $sendMessageTimer () {
var p = player.ship;
var stn = system.mainStation;
var dist = p.position.distanceTo(stn.position);
if (dist >= stn.scannerRange && dist < stn.scannerRange * 2) { // only send a message if the player is greater than scanner range and less than aegis range (2 * scanner range)
if (p.alertCondition != 3) { // only send if the player is not at condition red
this.$sendStationMessage();
}
}
}
this.$sendStationMessage = function $sendStationMessage () {
var birds = /bird/i;
var felines = /feline/i;
var frogs = /frog/i;
var humanoids = /humanoid/i;
var insects = /insect/i;
var lizards = /lizard/i;
var lobsters = /lobster/i;
var rodents = /rodent/i;
var colonials = /colonial/i;
if(system.info.inhabitants.match(birds))
{
system.mainStation.commsMessage("[bird-messages]");
}
if(system.info.inhabitants.match(felines))
{
system.mainStation.commsMessage("[feline-messages]");
}
if(system.info.inhabitants.match(frogs))
{
system.mainStation.commsMessage("[frog-messages]");
}
if(system.info.inhabitants.match(humanoids))
{
system.mainStation.commsMessage("[humanoid-messages]");
}
if(system.info.inhabitants.match(insects))
{
system.mainStation.commsMessage("[insect-messages]");
}
if(system.info.inhabitants.match(lizards))
{
system.mainStation.commsMessage("[lizard-messages]");
}
if(system.info.inhabitants.match(lobsters))
{
system.mainStation.commsMessage("[lobster-messages]");
}
if(system.info.inhabitants.match(rodents))
{
system.mainStation.commsMessage("[rodent-messages]");
}
}
As written it didn't work BUT...
Sadly I'm still dumbfounded. I'm sure there's more to it than replacing "nephthys_phantom_mark_IF_GalCop" with my own unique role name here, but I'm lost.montana05 wrote: ↑Sat Mar 05, 2022 12:33 pmCode: Select all
this.allowSpawnShip = function(shipKey) { var systemGov = system.government; if(system.isInterstellarSpace || system.sun.isGoingNova || system.sun.hasGoneNova) { return false; }; switch(shipKey) { // stable systems will be handled by GalCop police case "nephthys_phantom_mark_IF_bhg": if(systemGov > 2) { return false; }; break; // unstable systems will be handled by BHG, Dictators OXP and Commies OXP got their own police force case "nephthys_phantom_mark_IF_GalCop": if((systemGov < 3) || (systemGov == 3 && worldScripts["dictators.js"]) || (systemGov == 4 && worldScripts["communist_population"])) { return false; }; break; default: break; }; return true; };
If you use a random number in the script you can make a ship(s) mainly appear in poor places. Please note that this script is based on key, not on role. The renovation_multiplier should be sufficient for more frequent maintenance. If you pm me more details, I will be happy to make a draft for you.Old Murgh wrote: ↑Sat Mar 12, 2022 12:12 amI'm approaching a point when I'll need to write a script or two that I expect ought to be written in js rather than the legacy that I did dabble in (decades ago).. Simple scripts, I'm assuming for those in the know, but I'm standing perplexed at the bottom of a large hill.
The one scriptable item is the shipdata pList entry "condition_script" that will refer to a script that dictates these ships are restricted to lower economy systems.
On the subject that riffraff police vipers be restricted to these lowEcos
Sadly I'm still dumbfounded. I'm sure there's more to it than replacing "nephthys_phantom_mark_IF_GalCop" with my own unique role name here, but I'm lost.
Now if I wanted to expand the group to a whole set of riffraff ships that are more frequently seen in poor places, would that merit its own separate script or somehow be baked into this one?
–The other script I imagine I might need would be called from the shipyard pList and dictate that the riffraff ships need more frequent maintenance, or can this be satisfactorily be controlled with the "renovation_multiplier"? What would the experienced scripter do?