Adding sounds to tension belts

User avatar
Eep
Posts: 98
Joined: Mon Nov 26, 2018 6:07 pm

Adding sounds to tension belts

Post by Eep » Fri Dec 07, 2018 9:21 am

Trying to add a sound to tension belts (specifically the Fliegl DPW180 trailer) but I don't understand where to put the <sounds> tag and what to start the tag with. I assume <sounds> goes inside the <tensionBelts> tag but I'm just guessing based on what I see <sounds> in other parts. Here's what I tried but it didn't work:

Code: Select all

    <tensionBelts>
        <tensionBeltsConfigurations>
            <tensionBeltsConfiguration>
                <tensionBelts linkNode="belts" jointNode="flieglDPW180_main_component1" width="0.075" maxEdgeLength="0.1" geometryBias="0.01" ratchetPosition="0.2" defaultOffset="0.1" defaultOffsetSide="0.1" defaultHeight="4" activationTrigger="beltActivationTrigger">
                    <tensionBelt startNode="beltStart1" endNode="beltEnd6" offsetLeft="1.3"/>
                    <tensionBelt startNode="beltStart2" endNode="beltEnd5"/>
                    <tensionBelt startNode="beltStart3" endNode="beltEnd4"/>
                    <tensionBelt startNode="beltStart4" endNode="beltEnd3"/>
                    <tensionBelt startNode="beltStart5" endNode="beltEnd2"/>
                    <tensionBelt startNode="beltStart6" endNode="beltEnd1" offsetRight="1.2"/>
		    <sounds>
			<tensionBelt template="SWITCH_01"/>
	            </sounds>
                </tensionBelts>
            </tensionBeltsConfiguration>
        </tensionBeltsConfigurations>
    </tensionBelts>
How do I know what to name the tag inside <sounds>? I just picked "tensionBelt" based on other vehicles but where are the sound tags defined? I know the sound templates are defined in data\sounds\soundTemplates.xml so "SWITCH_01" is defined there. Ideally, I want to have different sounds for fastening (showing) and unfastening (hiding) belts. Any ideas?

User avatar
Eep
Posts: 98
Joined: Mon Nov 26, 2018 6:07 pm

Re: Adding sounds to tension belts

Post by Eep » Sun Dec 09, 2018 10:33 am

Anyone?

User avatar
Eep
Posts: 98
Joined: Mon Nov 26, 2018 6:07 pm

Re: Adding sounds to tension belts

Post by Eep » Sun Dec 16, 2018 8:25 pm

so far I've got

Code: Select all

function TensionBeltSound:onUpdate(dt)

	local spec = self.spec_tensionBelts
	if Input.isKeyPressed(Input.KEY_r)
		loadSample(1,uiClick.ogg,0)
		playSample(1,1,1,0)
	end
but it doesn't play a sound

Bonger76
Posts: 47
Joined: Thu Dec 15, 2016 7:27 am

Re: Adding sounds to tension belts

Post by Bonger76 » Tue Dec 18, 2018 2:12 am

You should post this question over at GDN in the scipting fourm there are some that read the post thier that know how to wright scipts,and you can find the .LUA docs thier wich should help ,I know nothing about scipting.

https://gdn.giants-software.com/forum.php

User avatar
Eep
Posts: 98
Joined: Mon Nov 26, 2018 6:07 pm

Re: Adding sounds to tension belts

Post by Eep » Tue Dec 18, 2018 2:29 am

Yea, that forum is even deader than this one. I've been combing though the FS19 Lua docs but I'm a Lua noob and it's very confusing. I'm learning from talking to scripters like Xentro and 50keda that the FS19 Lua docs are incomplete. 50keda was finally able to get a sound to play using this but I don't understand it or how to get it to work for me:

Code: Select all

g_soundManager:playSample(self.lwSoundSample)
But where is lwSoundSample defined? He replied:

Code: Select all

self.lwSoundSample = g_soundManager:loadSampleFromXML(self.xmlFile, soundKey, "running", self.baseDirectory, self.components[self.lwComponentIndex].node, 0, AudioGroup.VEHICLE, nil, nil)
:hmm: :?:

Bonger76
Posts: 47
Joined: Thu Dec 15, 2016 7:27 am

Re: Adding sounds to tension belts

Post by Bonger76 » Tue Dec 18, 2018 11:58 pm

I think the line is telling the game to load the sound that is in your .xml

<sounds>
<tensionBelt template="SWITCH_01"/>
</sounds>
it makes it load what ever sound you put thier in your .xml

Dribbly Midget
Posts: 306
Joined: Sat Dec 23, 2017 7:09 pm

Re: Adding sounds to tension belts

Post by Dribbly Midget » Wed Dec 19, 2018 12:41 am

The Modding community appears very active on the Giants Discord. It suggest putting this up there. :)
James G / Derplodactyl / Ye Olde Derp
PC & Xbox One
PC Specs:
-AMD Ryzen 5 2400G - Windows 10 Pro
-AMD Radeon RX 590 8GB
-16GB DDR4
-1TB/500GB Storage
-Samsung 55'' Q8D QLED 4K (HDR 1500) TV

User avatar
Eep
Posts: 98
Joined: Mon Nov 26, 2018 6:07 pm

Re: Adding sounds to tension belts

Post by Eep » Wed Dec 19, 2018 1:24 am

Yea, Dribbly, I'm there which is where I talked to Xentro and 50keda.

User avatar
Eep
Posts: 98
Joined: Mon Nov 26, 2018 6:07 pm

Re: Adding sounds to tension belts

Post by Eep » Wed Dec 19, 2018 3:18 am

Bonger76 wrote:
Tue Dec 18, 2018 11:58 pm
I think the line is telling the game to load the sound that is in your .xml

<sounds>
<tensionBelt template="SWITCH_01"/>
</sounds>
it makes it load what ever sound you put thier in your .xml
Yes but there's no <sound> tag defined in the tensionBelts.lua specialization so it looks like, upon further info from 50keda on FS discord:
got sound modifiers working, by registering my own type o.O

Code: Select all

g_soundManager:registerModifierType("LOGS_WINCH", LogsWinch.pitchModifierFunc, LogsWinch.pitchModifierMinFunc, LogsWinch.pitchModifierMaxFunc)
Anyone tried using g_soundManager:registerModifierType already, to define his own modifiers?

by official luadoc it accepts three functions. However signature of them is unknown,. I know what their return values have to be, but do not know how to connected them to sound samples.

oh yeah sounds finally work as they should

with custom modifier type
so for tajfun I got sound defined like this:

Code: Select all

        <sounds>
            <running file="$data/sounds/vehicles/retarder/retarder_loop_01.ogg">
                <volume indoor="1.0" outdoor="1.0">
                    <modifier type="LOGS_WINCH" value="0.00" modifiedValue="0.3" />
                    <modifier type="LOGS_WINCH" value="1.00" modifiedValue="0.75" />
                </volume>
                <pitch indoor="1.0" outdoor="1.0" >
                    <modifier type="LOGS_WINCH" value="0.00" modifiedValue="0.8" />
                    <modifier type="LOGS_WINCH" value="0.50" modifiedValue="0.61" />
                    <modifier type="LOGS_WINCH" value="1.00" modifiedValue="0.65" />
                </pitch>
            </running>
        </sounds>
"value" and "modifiedValue" are like keyframes in animations. So "value" defines timeline of modifier, where usually we have timeline from 0 to 1 and modifiedValue on the otherhand is a factor with which indoor/outdor values are multiplied in given time. so

Code: Select all

<modifier type="LOGS_WINCH" value="0.00" modifiedValue="0.8" />
-> actually gives you outdoor*modifiedValue when modifier is at value 0. now "value" for the timeline is sth that was causing problems to me. I didn't know how to change it in code. it turns out that it is return value from registerModifierType "func" argument

PölöToday at 3:03 PM
Does it increase/decrease in linear manner between the values, or by stepping always to next stage when the value is reached? :thinking:

50kedaToday at 3:04 PM
well that is on the code to decide, "func" function is sth that you write for your modifier type, so it's on you what you return. I currently don't have any interpolation done, but could have

Eep²Today at 3:25 PM
still no generic way to play a sound without having to define a mod type?

50kedaToday at 3:25 PM
niouce everything with sounds finally works as it should :smile:
sure it is
but old way of changing pitch and volume dynamically doesn't work as expected
which makes perfect sense to me now as I understand how modifiers work
you have zero extra code for any sound change
only thing you care is setting your modifier value on sound sample properly
So he's made progress and hopefully he'll release his Tajfun log winch soon at least.

Post Reply