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?
var ve = system.addVisualEffect("dataKeyOfAVisualEffect", player.ship.position);
ve.remove();
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.
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?
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.
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.
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.
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.
(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)
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.