Author Topic: Two types of cargo in one railcar  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

Offline passengerpigeon

Two types of cargo in one railcar
« on: June 03, 2017, 12:51:44 PM »
Hello all,
I am currently creating a vehicle pack, and want to include a regional railbus that carries both passengers and mail (in a single carriage). Is this possible? If so, how do you configure this in the .dat file?
Thanks,
Passengerpigeon.

Offline Ves

Re: Two types of cargo in one railcar
« Reply #1 on: June 03, 2017, 01:55:46 PM »
Hi,
A vehicle can not hold more than one type of cargo. You can get around this by making your vehicle consist of two "vehicles" bound together by constraints, one containing passengers and the other mail. There are different ways to do graphics wise: The Czech pakset have two graphical halfs of a vehicle and when connecting they become a complete vehicle, pak Britain have with their boats the complete boat graphics in one vehicle, and then small icons "vehicles" that represents different good types. Or you can make the second vehicle without any graphical representation at all.

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #2 on: June 03, 2017, 02:00:14 PM »
You can get around this by making your vehicle consist of two "vehicles" bound together by constraints, one containing passengers and the other mail.
Sure, but they would still have an articulated connection unless there was some way to "nest" one vehicle within another - is there? How does Pak128.Britain accomplish this, exactly?

Offline Ves

Re: Two types of cargo in one railcar
« Reply #3 on: June 03, 2017, 02:22:20 PM »
Pak Britain have the good icons trailing the ships at sea. It doesn't look that bad in fact, it's consistently used on all ships so you get used to it and it helps you differentiate between the ships.
You can nest one within the other if you make the second "vehicle" invisible by defining empty graphics. If this is a railway car or similar you would need to assign the primary car one length shorter than it should be and give that to the invincible part. Then there will be no visible artifacts at all in the game.

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #4 on: June 03, 2017, 02:36:28 PM »
If this is a railway car or similar you would need to assign the primary car one length shorter than it should be and give that to the invincible part. Then there will be no visible artifacts at all in the game.
Thanks, but would this invisible mail carrier be invisible in the depot menu, or could I add an icon somehow?

Offline Ves

Re: Two types of cargo in one railcar
« Reply #5 on: June 03, 2017, 09:46:08 PM »
It would be invincible but would have its own vehicle window in the depot. It is not possible to make a specific icon unfortunately.

Offline Vladki

Re: Two types of cargo in one railcar
« Reply #6 on: June 04, 2017, 04:39:00 PM »
In the czech pakset, both parts have the same graphics. I think the trick is to set the first vehicle's length to zero. You can look at sources on sourceforge.net. For example rail bus class 810 and 814 have such cars.

I'm also thinking about using the cargo holds system from british boats for railway flat cars with containers. Thus you could put two different containers on one flat car.
« Last Edit: June 04, 2017, 06:50:15 PM by Vladki »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8764
  • Total likes: 307
  • Helpful: 229
  • Languages: De,EN,JP
Re: Two types of cargo in one railcar
« Reply #7 on: June 06, 2017, 12:10:36 AM »
In the depot, the loaded graph is show, so the vehicle freight icon is visible.

Offline Ves

Re: Two types of cargo in one railcar
« Reply #8 on: June 06, 2017, 06:55:47 AM »
I think the trick is to set the first vehicle's length to zero.
I believe i was experimenting with that on some Swedish cars and it would not work at all with a length of zero. It needed at minimum a length of one.

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #9 on: June 06, 2017, 10:04:11 AM »
OK, so I have now compiled my pak, and both the trains and the mail workaround seem to be working OK in game, but I have run into two problems:

Firstly, there is a blue box around all of my vehicles. I tried to use the same blue background that was in the train-making template, but something must have gone wrong and I ended up with a slightly off shade of blue that didn't render as transparent. How do I make sure the background is the correct color, using the Mac color picker?
Secondly, whenever I build the VME Diesel Rail Motor rear unit, or the VME DRM single railcar (the two trains that my mail compartment is designed to work with) in my depot, the invisible mail thingy attaches automatically. The code I currently use for constraints is below:
Constraint[Prev][0]=VME Diesel Rail Motor (Rear)
Constraint[Prev][1]=VME Diesel Rail Motor (Railcar)
Constraint[Next][0]=none
How do I modify this so that the mail carrier only attaches to these two vehicles, but does not attach automatically (only when selected in the depot)?
Thanks,
Passengerpigeon.

Offline Leartin

Re: Two types of cargo in one railcar
« Reply #10 on: June 06, 2017, 11:12:54 AM »
there is a blue box around all of my vehicles. I tried to use the same blue background that was in the train-making template, but something must have gone wrong and I ended up with a slightly off shade of blue that didn't render as transparent. How do I make sure the background is the correct color, using the Mac color picker?
It is possible by now to use transparency, rather than that special shade of blue. Perhaps it's easiest to just delete any color, no color picking required.

Secondly, whenever I build the VME Diesel Rail Motor rear unit, or the VME DRM single railcar (the two trains that my mail compartment is designed to work with) in my depot, the invisible mail thingy attaches automatically. The code I currently use for constraints is below:
Constraint[Prev][0]=VME Diesel Rail Motor (Rear)
Constraint[Prev][1]=VME Diesel Rail Motor (Railcar)
Constraint[Next][0]=none
How do I modify this so that the mail carrier only attaches to these two vehicles, but does not attach automatically (only when selected in the depot)?
Sounds like you used
Constraint[Next][0]=//mail compartment//
without adding
Constraint[Next][1]=none
 in the trains. Perhaps just by using wrong indices (the numbers in constraints need to start with 0 and increase by 1).

Without "[Next][INDEX]=none" the train won't work without any following car, and if there is only one possible car defined, it will be added automatically.

Offline Ves

Two types of cargo in one railcar
« Reply #11 on: June 06, 2017, 11:55:40 AM »
I would make sure that the graphics is in the "first" vehicle. Then that need to be constrained to only use the invincible vehicle and the invincible vehicle should be constrained to match the prior vehicle. If you plan to use the invincible part on more vehicles, do the same with them and add them to the prev constraints.

Edit:
Leartin posted while I was writing and I also misread what you wrote. You should do as Leartin describes.
I do, however, think that it is not possible to click in the depot on a vehicle without graphics, but I might be wrong?
« Last Edit: June 06, 2017, 12:31:54 PM by Ves »

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #12 on: June 06, 2017, 01:02:30 PM »
I do, however, think that it is not possible to click in the depot on a vehicle without graphics, but I might be wrong?
Correct, as I just found out in a test. I assume assigning it a blank sprite will fix this while still keeping it invisible. Also, I changed all of my backgrounds from blue to transparent, only for my blue boxes to be replaced by black ones. I am also having clipping issues with rail vehicles, despite using the templates from the Wiki and setting the lengths according to them. Could someone please take a look at my (small number of) files to see if I am doing anything wrong? If it's relevant, the Makeobj .exe said that it was "deleting the alpha layers" in my .png images when I made the pak files.
Thanks,
Passengerpigeon.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8764
  • Total likes: 307
  • Helpful: 229
  • Languages: De,EN,JP
Re: Two types of cargo in one railcar
« Reply #13 on: June 06, 2017, 01:08:16 PM »
There is no Mac makeobj which supports transparency (since none of the developers has a mac). So you must use RGB 231 255 255.

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #14 on: June 06, 2017, 01:12:10 PM »
There is no Mac makeobj which supports transparency (since none of the developers has a mac). So you must use RGB 231 255 255.
I'm only drawing on a Mac. The makeobj I used is Version 54 for Windows.

Offline Ves

Re: Two types of cargo in one railcar
« Reply #15 on: June 06, 2017, 04:23:58 PM »
To find the correct length, the sum of all the "length" values must match the graphics length.
If you want to have be flexible with your invincible slot and omit it in some convoy constellations, I don't know if there is anything you easily can do as the sum of the length will not match the graphics.
I would suggest that you hardcode the slot to the vehicle so the two of them will always be connected. If you want a version without the slot, you can duplicate the vehicle and have a correct length in that one.

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #16 on: June 06, 2017, 10:29:59 PM »
To find the correct length, the sum of all the "length" values must match the graphics length.
If you want to have be flexible with your invincible slot and omit it in some convoy constellations, I don't know if there is anything you easily can do as the sum of the length will not match the graphics.
I would suggest that you hardcode the slot to the vehicle so the two of them will always be connected. If you want a version without the slot, you can duplicate the vehicle and have a correct length in that one.
OK, but how do I fix the transparency issues? Does makeobj version 54 not support transparency?

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #17 on: June 07, 2017, 07:56:15 AM »
Alright, so with transparency obviously not being supported in my version of Makeobj, I went back to Cyan, and got the correct shade this time which resolved the background issues. I also hardcoded the mail compartment into the railcars, which now works (it costs nothing extra to run anyway). However, I am still having issues with clipping, and also with vehicles being offset from the track by one pixel (compare the default locomotive in the second image with my rake of Peterson New Format carriages) and being off-centre (they seem to "overhang" the track more than normal cars on corners). Could somebody take a look at the files in the .zip I posted earlier and tell me what I am doing wrong with regards to length or image alignment? I used the rail vehicle template and each tile seems to be 64x64, but I may have my sprites a few pixels off.
« Last Edit: June 07, 2017, 01:26:53 PM by passengerpigeon »

Offline Ves

Re: Two types of cargo in one railcar
« Reply #18 on: June 07, 2017, 01:54:32 PM »
Regarding your out of alignment with the track, you can just move the entire vehicle down in the picture editor. Start with one pixel down and see if that looks better and then another one if wasn't enough.
Drawing guidelines can be old, and might not reflect the status of the current pakset although I don't know anything about your pakset.
The clipping issues: keep the invincible vehicle to length 1, and then try and add 1 to the length of the primary vehicle until the combination becomes too long. Bear in mind that one "length" in the datfile represents a tile divided by 16, so I think it is 2 pixels in pak 64 (it is 4 pixels in pak128) in the n-a and e-w directions. If you custom painted your vehicle however, it might not fit that 2 pixel rule and you would have to correct the pixeling. On the diagonals the proportions are a little different and you could either calculate the correct amount of pixels or find it by trial and error.

Offline passengerpigeon

Re: Two types of cargo in one railcar
« Reply #19 on: June 07, 2017, 02:53:44 PM »
Regarding your out of alignment with the track, you can just move the entire vehicle down in the picture editor. Start with one pixel down and see if that looks better and then another one if wasn't enough.
Drawing guidelines can be old, and might not reflect the status of the current pakset although I don't know anything about your pakset.
The clipping issues: keep the invincible vehicle to length 1, and then try and add 1 to the length of the primary vehicle until the combination becomes too long. Bear in mind that one "length" in the datfile represents a tile divided by 16, so I think it is 2 pixels in pak 64 (it is 4 pixels in pak128) in the n-a and e-w directions. If you custom painted your vehicle however, it might not fit that 2 pixel rule and you would have to correct the pixeling. On the diagonals the proportions are a little different and you could either calculate the correct amount of pixels or find it by trial and error.
Thanks! While extending the lengths, I noticed that for the VME Underground M1 (the old EMU in the third photo) and the VME Electricar (the little old tram), I had forgotten to define a length in the first place. Hopefully, this should eliminate clipping and hovering. I'll report back when I get a chance to test it again. In case you are interested, this vehicle pack will contain vehicles from the transport network of a fictional country that I created in a "world-building" exercise, and while I plan to create vehicles in all categories, the first release will focus on early electric trains, trams and railcars, since these are lacking in the default Pak64.

Offline Vladki

Re: Two types of cargo in one railcar
« Reply #20 on: June 11, 2017, 10:36:24 AM »
Hello, here is a sample of dat files for vehicles with dual cargo:
https://sourceforge.net/p/simutrans/code/HEAD/tree/pak128.CS/vehicles/rail-psg+mail/810/
Have a look at Btax.dat (Pax+Mail) and compare with Btax_bez_bagaze.dat (Pax only).

The main difference is that the first part of such combined vehicle has length=0. The second part has weight=0, and also all costs=0. Then they have almost the same graphics, save for the rotation that is shown in depot, which is in "chequered transparency" to visibly show that it is a two-part vehicle. The semi-transparent parts combined together should fit exactly and form the same image as for single part vehicle. Constraints are set so that you cannot build one part without the other. There is a separate instance of the same car that is for passengers only. It works very well - no clipping issues. The only problem is with reversals in simutrans extended where a "ghost" car can appear at some circumstances. But there are no known problems in simutrans standard.

(Pax only)
Code: [Select]
obj=vehicle
cost=810400
payload=104
speed=80
weight=15
runningcost=9
fixed_cost=46
name=CSD_Blm
waytype=track
freight=Passagiere
copyright=Sim
length=7
emptyimage[w]=Btax_CSD_bez_baglu.1.0,0,4
...

(Combined)
Code: [Select]
obj=vehicle
cost=810400
payload=104
speed=80
weight=15
runningcost=13
fixed_cost=67
name=CSD_Blm-1
waytype=track
freight=Passagiere
copyright=Sim
length=0
Constraint[Next][0]=CSD_Blm-2
emptyimage[w]=Btax_CSD.1.0,0,4
....
-------------------------------
obj=vehicle
cost=00
payload=14
speed=80
weight=0
runningcost=0
fixed_cost=0
name=CSD_Blm-2
waytype=track
freight=Post
copyright=Sim
length=7
Constraint[Prev][0]=CSD_Blm-1
emptyimage[w]=Btax_CSD.3.0,0,4
...

Foreign language window: Bagáž is czech spelling for baggage (luggage), Bágl is czech slang for single piece of baggage (typically backpack). "bez báglu, bez bagáže" means without baggage, i.e. it is the passenger only version. Baggage compartment on trains is often coded as mail in simutrans.