FreeSpace Releases > Scripting Releases

Simple script to automatically shut off engine glows

<< < (2/3) > >>

xenocartographer:
@m!m: Ah, damn. That does make sense (I guess I'd been under the impression that destroyed or departed ships would become invalid instead of reshuffling the entire list). Amended.

@Nightstorm: Interesting idea, but that'd also shut off navigation lights and so on, which is undesirable. I'll look into it.

Nightstorm:
True enough, in Diaspora ships don't have navigation lights however.  Take for instance the fighters all have a GlowMap for the cockpit lights and such but they only use GlowPoints for the engine glows, that is different than the aurora glow your script already turns off.

I've written it in a SEXP form in my missions to "activate-glow-points" or "deactivate-glow-points" but I have to write that into every mission.  Having it scripted is a way better option :)

Thank you!

xenocartographer:
Well, if you're sure that's what you want, this should work:


--- Code: ---#Conditional Hooks

$Application: FS2_Open

$On Game Init: [
   ThrusterCache = {}
   THRUSTER_ACTIVE_THRESHOLD = .01
]

$On Mission Start: [
   ThrusterCache = {}
]

$State: GS_STATE_GAME_PLAY
$On Frame: [
   local numShips = #mn.Ships
   for i=1, numShips do
      local ship = mn.Ships[i]
      if ship:isValid() then
         local signature = ship:getSignature()
         local thrust = ship.Physics.ForwardThrust
         local engines = (thrust > THRUSTER_ACTIVE_THRESHOLD)
         if engines ~= ThrusterCache[signature] then
            local name = ship.Name
            mn.runSEXP("(set-thrusters-status !" .. tostring(engines) .. "! !" .. name .. "!)")
            if engines then
                mn.runSEXP("(activate-glow-points !" .. name .. "!)")
            else
                mn.runSEXP("(deactivate-glow-points !" .. name .. "!)")
           end
            ThrusterCache[signature] = engines
         end
      end
   end
]

#End

--- End code ---

Nightstorm:
Thank you.  I'm getting an error on game Init.  Unexpected symbol near ? and the question mark has a black diamond around it.  I'll attach a screen cap.

The first one runs and shuts off the glow affect that you originally intended but the second one crashes out with this error.

*EDIT* I got it working.  I don't know what was causing the error, I think it was some formatting change or something happening with Noteapad++.  I reconstructed the new version line by line based on a working copy of the old one and it works now.

Thank you very much!

[attachment stolen by Russian hackers]

coffeesoft:
Do you think it would be possible to modify the script , just to rotate the engines ?

The X-Wings of my game can rotate wings  but the engines do not, so they looks out of position, and i donĀ“t know how to fix them.

Thanks a lot !!   :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version