MOARdV / AvionicsSystems

MOARdV's Avionics Systems for Kerbal Space Program - a new generation of IVA enhancement.
Other
52 stars 26 forks source link

Make 'volume =' and 'sound =' dynamic values #9

Closed MOARdV closed 7 years ago

MOARdV commented 8 years ago

So volume can be adjusted, and maybe more than one sound option.

DeputyLOL commented 8 years ago

Could we have the ability to make a sound have to finish playing instead of being cut off the second its variable goes out of range? Kind of like RPMs MustBePlayedOnce.

Also can we have variable pitch of the sound? We could make engine or wind noises.

Alexustas commented 8 years ago

Also can we have variable pitch of the sound? We could make engine or wind noises.

I think the engine sound effects are set in the engines config

    power_dry
        {
            AUDIO
            {
                channel = Ship
                clip = sound_jet_deep
                volume = 0.0 0.0
                volume = 0.05 0.4
                volume = 1.0 0.9
                pitch = 0.0 0.8
                pitch = 1.0 1.4
                loop = true
            }
        }
DeputyLOL commented 8 years ago

I know, but i mean a different engine noise that plays in the IVA. I find that the engines are very quite when flying. Im mostly going to use it for wind noise that changes with speed.

MOARdV commented 8 years ago

Okay:

I did not make 'sound' a variable yet - that looks like it is easy to change, but I need to figure out the right way to handle errors if an invalid sound clip is provided.

EDIT: And it is available on DropBox.

DeputyLOL commented 8 years ago

I have a problem with all my alarms now:

[ERR 18:41:49.003] [AvionicsSystems] INITIALIZATION ERROR: GetVariable with empty variableName

[ERR 18:41:49.004] [AvionicsSystems] INITIALIZATION ERROR: Failed to configure prop #15 (AC_K320_GPWS)

[ERR 18:41:49.005] [MASComponent] Failed to configure prop #15 (AC_K320_GPWS)

[ERR 18:41:49.005] [MASComponent] System.ArgumentException: [MASFlightComputer] Trying to GetVariable with empty variableName at AvionicsSystems.MASFlightComputer.GetVariable (System.String variableName, .InternalProp prop) [0x00000] in :0 at AvionicsSystems.MASFlightComputer.RegisterNumericVariable (System.String variableName, .InternalProp prop, System.Action`1 callback) [0x00000] in :0 at AvionicsSystems.MASActionAudioPlayer..ctor (.ConfigNode config, .InternalProp internalProp, AvionicsSystems.MASFlightComputer comp) [0x00000] in :0 at AvionicsSystems.MASComponent.CreateAction (.ConfigNode config, .InternalProp prop, AvionicsSystems.MASFlightComputer comp) [0x00000] in :0 at AvionicsSystems.MASComponent.Start () [0x00000] in :0

DeputyLOL commented 8 years ago

Is pitch a require field now?

MOARdV commented 8 years ago

No. I had a copy-paste error that I just now noticed and fixed. Re-download, please

DeputyLOL commented 8 years ago

LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER! LONG LIVE COPY PASTER!

EDIT: whoops, i meant long live copy paste... :D

DeputyLOL commented 8 years ago

I dont know what the problem is but now all my stock parts are missing and all of my ships are broken... my log is full of this:

[LOG 20:52:57.036] PartLoader: Compiling Part 'Squad/Parts/Aero/cones/avionicsNoseCone/PART' [ERR 20:52:57.037] PartCompiler: Part config requires value 'name' is defined

[ERR 20:52:57.038] PartCompiler: Cannot compile part

[LOG 20:52:57.038] PartLoader: Compiling Part 'Squad/Parts/Aero/cones/ConeA/PART' [ERR 20:52:57.039] PartCompiler: Part config requires value 'name' is defined

[ERR 20:52:57.039] PartCompiler: Cannot compile part

[LOG 20:52:57.040] PartLoader: Compiling Part 'Squad/Parts/Aero/cones/ConeB/PART' [ERR 20:52:57.041] PartCompiler: Part config requires value 'name' is defined

[ERR 20:52:57.041] PartCompiler: Cannot compile part

[LOG 20:52:57.042] PartLoader: Compiling Part 'Squad/Parts/Aero/cones/noseConeAdapter/PART' [ERR 20:52:57.042] PartCompiler: Part config requires value 'name' is defined

DeputyLOL commented 8 years ago

Do you know what I should do?

MOARdV commented 8 years ago

Did you delete something you shouldn't have by accident? Nothing in my code would do that, and I haven't had a problem here.

DeputyLOL commented 8 years ago

I dont think so. I tried validating game cache and it replaced 2 files. But the game was still broken. I restarted my computer and it still didn't work. so im reinstalling the game. If it still doesn't work then i dont know whats wrong.

DeputyLOL commented 8 years ago

If you have time, theres been something thats been nagging at me. I'm still new to programming in lua and have been using notepad+ as it has handy tools and features to help. Theres something i've noticed however. image

Notepad+ has a line on the left of the page to show you the beginning and end of a function, but if the function has more than one 'IF' statements, the line goes pass the function as if its missing an 'end' statement. (notice the red line showing the wind noise function continuing down the page.)

Does every IF statement needs its own 'end'?

The script still works (when KSP is working) so i don't have much to complain about, im just wondering if the way i've set up the functions is ok.

DeputyLOL commented 8 years ago

Whatever was broken with KSP is fixed now.

Alexustas commented 8 years ago

Does every IF statement needs its own 'end'?

As far as I understand, yes. Every "if" must to be "closed" by "end" On your screen two "if" and function, so you need three "end"

MOARdV commented 8 years ago

Does every IF statement needs its own 'end'?

Yes:

if somecondition then
   someaction
end

or, for compound cases,

if somecondition then
   someaction
elseif someOtherConditon then
  someOtherAction
end

Note that it is elseif as one word, not two.

DeputyLOL commented 8 years ago

On your screen two "if" and function, so you need three "end"

Ok. The scripts still work like this. Should i use 'elseif'?

MOARdV commented 8 years ago

Should i use 'elseif'?

If you're doing compound checks, it is probably more efficient to use elseif.

I discovered that GitHub supports Lua syntax highlighting for code blocks:

if somecondition then
   someaction
elseif someOtherConditon then
  someOtherAction
end

if you add 'Lua' after the triple-backtick (eg ```Lua to start the code block, and triple-backtick by itself to end it)

DeputyLOL commented 8 years ago

Ok thank you.

MOARdV commented 8 years ago

Using a variable for sound = is going to be tricky - I have some optimizations to convert some variables from Lua to C#, and that optimization needs to be smarter to recognize unquoted string literals.

MOARdV commented 7 years ago

sound remains a static (unchanging) sound clip for the common use case. Omit sound and use dynamicSound instead, and the sound clip can be changed in-flight.