Re: Scripters cove
Posted: Thu Oct 10, 2013 2:07 pm
If you want a better guide then 4 credits are not going to go far!
Sheesh! Cheapskates!
Sheesh! Cheapskates!
For information and discussion about Oolite.
https://bb.oolite.space/
JazHaz wrote:If you want a better guide then 4 credits are not going to go far!
Sheesh! Cheapskates!
console.log
and alert
. Those only work for web based javascripts.Code: Select all
this.name = "customshieldsenginetrails";
this.author = "Zireael";
this.copyright = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Engine trails";
this.version = "0.01";
this.shipSpawned = function()
{
if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
{
this.customshieldsframetime = 0.0;
this.customshieldsframetimelimit = 10.0;
this.ship.velocity = this.ship.velocity.add(this.ship.vectorForward.multiply(10 + (this.customshieldsframetimelimit * 3)));
this.csfl = addFrameCallback(this.customshieldsfuelleaks.bind(this));//----------
return;
}
else
{
this.ship.remove();
return;
}
}
this.customshieldsfuelleaks = function(delta)
{
if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
{
this.customshieldsframetime += delta;
this.customshieldsfuelscooperpossibilities = system.filteredEntities(this, function (entity){return ((entity.fuel < 7.0) && (entity.equipmentStatus("EQ_FUEL_SCOOPS") === "EQUIPMENT_OK") && (entity !== this.ship.target))}, this.ship, 25);//must have space for fuel, working fuel scoops, and not be the one leaking the fuel to begin with
if(player.ship.scoopOverride === false)//if effect is not currently active
{
player.ship.scoopOverride = true;//activate the effect
this.ship.spawnOne("customshieldsfuelleaksscoopoverride");//spawn marker timer for effect control
}
}
if(this.customshieldsframetime >= this.customshieldsframetimelimit)//length of time engine trail exists
{
removeFrameCallback(this.csfl);//----------
this.ship.remove();
return;
}
return;
}
else
{
removeFrameCallback(this.csfl);//----------
this.ship.remove();
return;
}
}
Code: Select all
var ve = system.addVisualEffect("dataKeyOfAVisualEffect", player.ship.position);
ve.remove();
Code: Select all
this.name="myvescript";
this.effectRemoved = function()
{
log("myvescript", "Oh, bye!");
}
Code: Select all
for(var i = 0; i < system.allVisualEffects.length; i++)
log("ve", i+". "+system.allVisualEffects[i].dataKey);
Code: Select all
this._numberForWeaponType(player.ship.currentWeapon);
Code: Select all
this._numberForWeaponType = function (weapon)
{
switch(weapon)
{
case "EQ_WEAPON_PULSE_LASER":
{
return 1;
}
case "EQ_WEAPON_BEAM_LASER":
{
return 2;
}
case "EQ_WEAPON_MINING_LASER":
{
return 3;
}
case "EQ_WEAPON_MILITARY_LASER":
{
return 4;
}
default:
{
return 0;
}
}
}
player.ship.currentWeapon
returns an EquipmentInfo
.this._numberForWeaponType(player.ship.currentWeapon.equipmentKey);
break;
after each of the returns, as once one case has been positively triggered then there's no need to evaluate the remaining ones. Should make the code a very little bit quicker.That would be odd if true - though I suppose it's possible if the JS engine's optimisation of switch/case is a bit odd - because nothing after the return is evaluated should even be considered.Thargoid wrote:You should also put abreak;
after each of the returns, as once one case has been positively triggered then there's no need to evaluate the remaining ones. Should make the code a very little bit quicker.
mission.exitScreen
inside the callback should work.Any chance of making this default to the screen the mission screen was called from?cim wrote:Settingmission.exitScreen
inside the callback should work.