Possible to add specializations to Train?

Your forum for all discussions around Modding.
User avatar
dougw133
Posts: 28
Joined: Tue Jan 24, 2017 5:33 am

Possible to add specializations to Train?

Post by dougw133 »

Im simply trying to create a snow plow function for the front of the train so it clear the tracks as it goes. When I add specializations to the modesc it fails.

I get errors like this

Error: Not all prerequisites of specialization 'dischargeable' in vehicle type 'FS22_DELTA.locomotive1' are fulfilled

and then the train will not load obviously. It doesn't seem to accept any specialization outside of the parent. Is tis even possible?
Last edited by dougw133 on Sat Feb 24, 2024 8:24 am, edited 2 times in total.
Haubi
Posts: 1227
Joined: Tue Nov 23, 2021 4:36 pm
Location: JVA Stadelheim

Re: Possible to add specializations to Train?

Post by Haubi »

I think the specialization "dischargeable" requires "fillVolume" and possibly also "trailer" as a prerequisite. VehileType "trainTrailer" also has these, and "dischargeable" works there.
User avatar
dougw133
Posts: 28
Joined: Tue Jan 24, 2017 5:33 am

Re: Possible to add specializations to Train?

Post by dougw133 »

Haubi wrote: Fri Feb 23, 2024 8:58 am I think the specialization "dischargeable" requires "fillVolume" and possibly also "trailer" as a prerequisite. VehileType "trainTrailer" also has these, and "dischargeable" works there.
I've tried many combinations. Looking at examples it seems most mods or snow plows use leveler as the parent..however, locomotive has to be the parent when loading it in the modesc so I'm not sure if it can be done. If it can, I haven't found the right combination yet. My xml for the locomotive as well as the i3d have all the correct parts, nodes, and mapping with no errors. If I change the parent to leveler it breaks the train but loads the specialization correctly in game.
Haubi
Posts: 1227
Joined: Tue Nov 23, 2021 4:36 pm
Location: JVA Stadelheim

Re: Possible to add specializations to Train?

Post by Haubi »

I would try it this way

Code: Select all

<vehicleTypes>
	<type name="locomotiveLeveler" parent="locomotive" className="RailroadVehicle" filename="dataS/scripts/vehicles/RailroadVehicle.lua">
		<specialization name="leveler" />
			if required
		<specialization name="fillVolume" />
		<specialization name="dischargeable" />
		<specialization name="trailer" />
	</type>
</vehicleTypes>
User avatar
dougw133
Posts: 28
Joined: Tue Jan 24, 2017 5:33 am

Re: Possible to add specializations to Train?

Post by dougw133 »

Haubi wrote: Fri Feb 23, 2024 10:25 am I would try it this way

Code: Select all

<vehicleTypes>
	<type name="locomotiveLeveler" parent="locomotive" className="RailroadVehicle" filename="dataS/scripts/vehicles/RailroadVehicle.lua">
		<specialization name="leveler" />
			if required
		<specialization name="fillVolume" />
		<specialization name="dischargeable" />
		<specialization name="trailer" />
	</type>
</vehicleTypes>
Thank you for the help. No luck. Leveler in the specialization always results in the prerequisite error. The common xml code amongst snow removal equipment is like this

Code: Select all

<leveler fillUnitIndex="1" maxFillLevelPerMS="25" ignoreFarmlandState="true">
        <levelerNode node="levelerNode" width="2.8" zOffset="0" minDropWidth="2.5" maxDropWidth="3.2" minDropDirOffset="1" maxDropDirOffset="2" alignToWorldY="false"/>

        <force node="jump320_main_component1" maxForce="30" direction="1" />

        <pickUpDirection>1</pickUpDirection>

        <effects>
            <effectNode effectNode="effectMesh" effectClass="ShaderPlaneEffect" materialType="leveler" fadeTime="0.5" speed="10" />

            <effectNode effectClass="SnowPlowMotionPathEffect" effectType="SNOW_PIECES" linkNode="snowEffectNode">
                <motionPathEffect textureFilename="$data/vehicles/samasz/jump320/snowArray.dds" numRows="13" rowLength="27" minFade="0.15" />
                <snowPlowEffect shaderPlane="effectMesh" minScale="1 0.44 0.53" maxScale="1 0.95 0.95" scrollSpeed="-5"/>
            </effectNode>
            <effectNode effectClass="SnowPlowMotionPathEffect" effectType="SNOW_DUST" linkNode="snowEffectNode">
                <motionPathEffect textureFilename="$data/vehicles/samasz/jump320/snowArray.dds" numRows="13" rowLength="27" minFade="0.15" />
            </effectNode>
        </effects>
    </leveler>
If you remove specialization leveler, everything loads but the error then says 2 components present but only 1 loaded, meaning it doesn't know what you want to do with the above section yet. So, somehow i need to have leveler called in the specialization but am striking out.
User avatar
dougw133
Posts: 28
Joined: Tue Jan 24, 2017 5:33 am

Re: Possible to add specializations to Train?

Post by dougw133 »

Alright. Getting somewhere finally.

Got it working and functioning. I am left with this error/warning to figure out

Code: Select all

Warning ("""locomotive04.xml): I3D file offers '2' objects, but '1' components have been loaded!
I used the selfPropelledLeveler parent and then added the locomotive specializations. This is what I did in the modesc:

Code: Select all

<vehicleTypes>
	
		<type name="locomotive1" parent="selfPropelledLeveler" className="RailroadVehicle" filename="$dataS/scripts/vehicles/RailroadVehicle.lua">
		    <specialization name="baseMaterial" />
            <specialization name="wheels" />
            <specialization name="splineVehicle" />
            <specialization name="dynamicallyLoadedParts" />
            <specialization name="ikChains" />
            <specialization name="speedRotatingParts" />
            <specialization name="animatedVehicle" />
            <specialization name="dashboard" />
            <specialization name="enterable" />
            <specialization name="fillUnit" />
            <specialization name="motorized" />
            <specialization name="drivable" />
            <specialization name="locomotive" />
            <specialization name="lights" />
            <specialization name="attacherJoints" />
            <specialization name="cylindered" />
            <specialization name="connectionHoses" />
            <specialization name="honk" />
            <specialization name="wipers" />
	    </type>
    </vehicleTypes>
User avatar
dougw133
Posts: 28
Joined: Tue Jan 24, 2017 5:33 am

Re: Possible to add specializations to Train? SOLVED

Post by dougw133 »

And this error:

Code: Select all

Warning ("""locomotive04.xml): I3D file offers '2' objects, but '1' components have been loaded!
Was because I left a third camera in the scenegraph I was using...Duh.


EDIT: Not so fast.....Everything works perfectly in game. It loads up, no errors and functions. However, during testing I realized if i save a game, and then go to load it I get this error
Error: Running LUA method 'loadSharedI3DFileAsyncFinished'.
dataS/scripts/vehicles/specializations/SplineVehicle.lua(242) : attempt to perform arithmetic on field 'splinePositionSpeed' (a nil value)
and the game freezes on load. So close! I wonder if this will end being possible. Really, I just need to load the leveler specialization to the locomotive but cannot figure out what "Prerequisites" it's missing when it errors in that config.

EDIT 2: SOLVED
Alright, way less headache than it should have been and much simpler and sensible solution. It was bunkerSiloInteractor that leveler needed as a prerequisite. Here is the XML code that has me up and running error free.

Code: Select all

<vehicleTypes>
		<type name="locomotive1" parent="locomotive" className="RailroadVehicle" filename="$dataS/scripts/vehicles/RailroadVehicle.lua">
			 <specialization name="bunkerSiloInteractor" />
			 <specialization name="leveler" />
	    </type>
   </vehicleTypes>
Post Reply