Allow a function to be passed as a comms parameter, for more advanced work

This commit is contained in:
cim 2013-12-31 17:42:31 +00:00
parent 012af4837c
commit 22fca4c705

View File

@ -368,7 +368,14 @@ this.PriorityAIController = function(ship)
{ {
params = this.entityCommsParams(params); params = this.entityCommsParams(params);
} }
if (template instanceof Function)
{
var message = template(key,params);
}
else
{
var message = expandDescription(template,params); var message = expandDescription(template,params);
}
if (message != "") if (message != "")
{ {
this.ship.commsMessage(message); this.ship.commsMessage(message);
@ -6206,7 +6213,9 @@ this.startUp = function()
/* These are temporary for testing. Remove before release... */ /* These are temporary for testing. Remove before release... */
this.$commsSettings.generic.generic.oolite_continuingAttack = "I've got the [oolite_entityClass]"; this.$commsSettings.generic.generic.oolite_continuingAttack = "I've got the [oolite_entityClass]";
this.$commsSettings.police.generic.oolite_continuingAttack = function(k,p) { return "Targeting the "+p.oolite_entityName+". Cover me."; };
this.$commsSettings.generic.generic.oolite_beginningAttack = "Die, [oolite_entityName]!"; this.$commsSettings.generic.generic.oolite_beginningAttack = "Die, [oolite_entityName]!";
this.$commsSettings.police.generic.oolite_beginningAttack = function(k,p) { return "Leave the system or die, "+p.oolite_entityName+"!"; };
this.$commsSettings.generic.generic.oolite_beginningAttackInanimate = "I've got you this time, [oolite_entityName]!"; this.$commsSettings.generic.generic.oolite_beginningAttackInanimate = "I've got you this time, [oolite_entityName]!";
this.$commsSettings.generic.generic.oolite_hitTarget = "Take that, scum."; this.$commsSettings.generic.generic.oolite_hitTarget = "Take that, scum.";
this.$commsSettings.generic.generic.oolite_killedTarget = "[oolite_entityClass] down!"; this.$commsSettings.generic.generic.oolite_killedTarget = "[oolite_entityClass] down!";