Scripters cove
Moderators: winston, another_commander
- JazHaz
- ---- E L I T E ----
- Posts: 2991
- Joined: Tue Sep 22, 2009 11:07 am
- Location: Enfield, Middlesex
- Contact:
Re: Scripters cove
If you want a better guide then 4 credits are not going to go far!
Sheesh! Cheapskates!
Sheesh! Cheapskates!
Re: Scripters cove
JazHaz wrote:If you want a better guide then 4 credits are not going to go far!
Sheesh! Cheapskates!
*sigh* Here... 125 creds.... that should be enough....right?
Also how long did it take everyone to learn these Scripting practices....?
Commander: Gouanaco
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
Ship: { Cobra Mark III }
Galaxy: [1]
Legal Status: Clean
Rating: Average (63)
Career: Trader/Bounty Hunter
Cash: 12 956.4@ (credits)
- Tricky
- ---- E L I T E ----
- Posts: 821
- Joined: Sun May 13, 2012 11:12 pm
- Location: Bradford, UK. (Anarchic)
Re: Scripters cove
Use this site, JavaScript | MDN - Mozilla Developer Network, as your bible, especially the Javascript Reference link from that page.
The version that Oolite uses is a cut down version of SpiderMonkey (v1.8 - ECMAScript edition 5).
Ignore all references to the Document Object Model (DOM),
The version that Oolite uses is a cut down version of SpiderMonkey (v1.8 - ECMAScript edition 5).
Ignore all references to the Document Object Model (DOM),
console.log
and alert
. Those only work for web based javascripts.Re: Scripters cove
This is my attempt to create E:D-like engine trails, based on fuel leaks from CSOB's custom shields.
Now what do I do in order to test it, apart from sticking it in EngineTrails.oxp/Scripts? I want it to be applied to all non-player ships.
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;
}
}
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Scripters cove
Dear all
I'd be grateful with help on the following.
I'm trying to remove, via world script, visual effects - witchspace rings, sparks, etc. I think I can see how to generate an array of such things; indeed my code does this already, and tries to remove the entities in the array, but I am not sure (the script does complex things, so it is hard to tell) whether it works. Do OXP scripts have write-access to such entities?
Thanks.
I'd be grateful with help on the following.
I'm trying to remove, via world script, visual effects - witchspace rings, sparks, etc. I think I can see how to generate an array of such things; indeed my code does this already, and tries to remove the entities in the array, but I am not sure (the script does complex things, so it is hard to tell) whether it works. Do OXP scripts have write-access to such entities?
Thanks.
- 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: Scripters cove
You can remove any effects you made:
if you insert a script="myvescript.js"; line into your effectdata.plist and put the following content into this .js file then you will get a message into your log when you remove your effect.
If you want to remove another effects then you can search your target in the system.allVisualEffects array based on dataKey, position or any other properties you see in VisualEffect or Entity. But you can not modify effects created by the core game which is not in this array.
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!");
}
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Scripters cove
Thanks Norby! But can you tell me how to pick out, within system.allVisualEffects, the effects that show up in the log as OOSparkEntity and OORingEffectEntity? Or are those among the unmodifiable (and perhaps even undetectable via system.allVisualEffects) effects?
- 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: Scripters cove
I do not see these in system.allVisualEffects. I used the following code when several ships arrived near the witchpoint and I saw many witchspace rings around the ships, but the result log contained effects created by OXPs only.
Code: Select all
for(var i = 0; i < system.allVisualEffects.length; i++)
log("ve", i+". "+system.allVisualEffects[i].dataKey);
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
(Help, please!) This doesn't seem to work, and I don't know why:-
It is falling through to the default, and returning 0 every time. Why? What sort of values does player.ship.currentWeapon hold or point to?
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;
}
}
}
Re: Scripters cove
player.ship.currentWeapon
returns an EquipmentInfo
.Try
this._numberForWeaponType(player.ship.currentWeapon.equipmentKey);
Re: Scripters cove
You should also put a
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.My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Re: Scripters cove
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.
(Also, JS switch/case, like its C inspiration, has fall-through, so once one case comparison matches if you don't break or return out of the switch the rest get executed unconditionally)
- Wildeblood
- ---- E L I T E ----
- Posts: 2453
- Joined: Sat Jun 11, 2011 6:07 am
- Location: Western Australia
- Contact:
Re: Scripters cove
Thanks, guys.
Another question now: can I reset the exit screen of a mission screen while it is displayed? I want to have options "Exit to chart screen" or "Back to interfaces screen" on the mission screen.
Another question now: can I reset the exit screen of a mission screen while it is displayed? I want to have options "Exit to chart screen" or "Back to interfaces screen" on the mission screen.
Re: Scripters cove
Setting
mission.exitScreen
inside the callback should work.-
- ---- E L I T E ----
- Posts: 288
- Joined: Sat May 31, 2014 9:02 pm
- Location: Melbourne, Australia
Re: Scripters cove
Any chance of making this default to the screen the mission screen was called from?cim wrote:Settingmission.exitScreen
inside the callback should work.
- Neelix
Talaxian Enterprises: [wiki]Vacuum Pump[/wiki] [wiki]Waypoint Here[/wiki]