Tiny Trains deprecated


Tiny trains for your tiny needs. Makes rails and wagons 1 wide, and shortens the wagons to 3 height. Now you can fit a train in between your assemblers and beacons. Rails still move on a 2x2 grid.

Content
4 years ago
0.17 - 0.18
13
Trains

b Wrong collision_mask of rails breaks Factorio >= 0.17.75

4 years ago
(updated 4 years ago)

Your mod causes a crash on loading the game with Factorio >=0.17.75. Since that version, all rails must have "object-layer" in their collision_mask. However, your mod sets a collision_mask for vanilla rails (and thus, overwrites the default):

data.raw["straight-rail"]["straight-rail"].collision_mask = {"item-layer", "floor-layer", "water-tile"}
data.raw["curved-rail"]["curved-rail"].collision_mask = {"item-layer", "floor-layer", "water-tile"}

This is on line 475/476 of prototypes/entity/rails.lua.

I've just updated my rail-fix mod to reset the collision_mask of the vanilla rails to the default values, but you probably should fix that in your mod, too! :-)

4 years ago

Funny you should say that. Really stupid of me to upload a mod in 0.17.75 that doesn't work for 0.17.75 is it?

I was the one that submitted that bug report that made that change..
https://forums.factorio.com/viewtopic.php?t=77479

You just need to have any collision mask on a rail, doesn't matter which one. So "object-layer" is not required.

Did you even try to load my mod without any other mods loaded?

I am guessing (hoping) you are using mods together with this mod that introduce rails with collision masks that doesn't contain "floor-layer", because for some reason all rails need to share at least one collision mask (doesn't matter which one).
Can you tell me which mod(s) that would be? Maybe we can come to a consensus to add a common unused layer to all rails. "layer-15"?. Then you can use "layer-15" instead "object-layer" in your "rail-fix" mod. (because you don't need "object-layer"..)

So next time please test a mod first before you submit a bug report with what you think is wrong :-)

4 years ago
(updated 4 years ago)

I wasn't the one that came up with that solution, it originally came from a thread in Bio Industries board. "object-layer" was used there originally, but together with "not-colliding-with-itself", so jamiech1 just removed the latter and kept "object-layer" -- and as it was working, this has been used in a couple of mods now. I've been guilty of making the rail-fix mod because I saw people complaining about the same bug with different mods and thought just installing a mod would be an easier way to fix the bugs than manually changing the files.

Did you even try to load my mod without any other mods loaded?

Of course, and of course it worked -- because there was no other mod that could conflict with it. :-)

I am guessing (hoping) you are using mods together with this mod that introduce rails with collision masks that doesn't contain "floor-layer", because for some reason all rails need to share at least one collision mask (doesn't matter which one).

I think none of the mods I tried used floor-layer. There were problems with Bio Industries, Cargo Ships, and Space Exploration.

Maybe we can come to a consensus to add a common unused layer to all rails. "layer-15"?. Then you can use "layer-15" instead "object-layer" in your "rail-fix" mod. (because you don't need "object-layer"..)

I'm not sure. The vanilla rails use the default mask (actually, in the data stage, they have collision_mask = nil, so the default mask is added when the data stage is completed), and the default mask is set to {"item-layer", "object-layer", "player-layer", "water-tile"}. I have a gut feeling that it would be better not to mess with the vanilla rails' mask, because it will be used by all mods copying the prototype. Therefore, I'm a bit wary of adding a new layer. Also, "layer-15" is unused now -- but do you know it will be unused forever?

By the way, I tried to be careful with my mod: I don't overwrite the collision_mask completely, I just add "object-layer" to any other layers that may already exist, remove "not-colliding-with-itself", and ignore any rail type that doesn't set a collision_mask (because it will inherit the default mask eventually).

4 years ago
(updated 4 years ago)

I see, thanks. Sorry if I came over bit agitated, was a long day.
For my "tiny-straight-rail" (and curve) I can't use "object-layer" unfortunately. (Since objects need to be placed on the rail)

As for the vanilla ones.. I agree I should be careful overwriting them.
Reason I removed the object-layer mask at the vanilla ones was that the tiny rails spawn invisible entities that do contain the "object-layer". Meaning it wouldn't be possible to cross a tiny rail with a vanilla rail.
Basically the invisible_box.collision_mask can't contain any of straight-rail.collision_mask nor of tiny-straight-rail.collision_mask, but should contain at least one of the default. {"item-layer", "object-layer", "player-layer", "water-tile"}
Can't be player-layer, since then the player can't walk through tiny rails.
Can't be water-tile, or you'd be able to place regular rails on water. (I could hack that the same way I currently do with tiny- though)
So that leaves object-layer and item-layer, I choose to remove object-layer. Otherwise you'd be able to place heatpipes, transportbelts and landmines on the rails (and any other modded entity that can have items on them).

I don't think it is a problem to remove the "object-layer". Even if other mods copy over the vanilla entity.
All entities that contain "object-layer" also contain "water-tile" as collision_mask. The only entities that can now be placed on vanilla rails are entities that contains the "object-layer" but not "item-layer", "floor-layer" or "water-tile". Can't see a usecase for such a set (except.. my invisible box).

"layer-11" to "layer-15" were made especially for modding in mind. The only problem will arise if other mods also use the layer for something.

Rail collision_boxes and masks are such a headache.
I wonder why all rails should have at least one collision_box in common. And since that is the case, why not make a "rail-layer" that rails should have. Maybe we could suggest it to Wube.

Enough rambling. So unfortunately I have to remove object-layer from rails.
I can make a change so that it only removes object-layer (and not hard code the 3 layers) as I do now, similar as you do.
And probably will also add a final-fixes to add layer-15 to all rails myself.

4 years ago
(updated 4 years ago)

I see, thanks. Sorry if I came over bit agitated, was a long day.

That's OK, no hard feelings on my part. :-)

"layer-11" to "layer-15" were made especially for modding in mind. The only problem will arise if other mods also use the layer for something.

Rail collision_boxes and masks are such a headache.
I wonder why all rails should have at least one collision_box in common. And since that is the case, why not make a "rail-layer" that rails should have. Maybe we could suggest it to Wube.

If "layer-11" to "layer-15" are there for modders, you really can't rule out that other mods will use the same layer -- with unpredictable results. So, yes, a special "rail-layer" sounds very appealing! Would you propose that on the forum? It's your idea after all, I don't want to steal it. :-D

Enough rambling. So unfortunately I have to remove object-layer from rails.
I can make a change so that it only removes object-layer (and not hard code the 3 layers) as I do now, similar as you do.

Removing "object-layer" from the vanilla rails will probably break all other mods that use it …

And probably will also add a final-fixes to add layer-15 to all rails myself.

This seems better -- as long as there isn't a dedicated "rail-layer". If you add "layer-15", please remember to add it to the vanilla rails as well! As their collision_mask is nil during data stage, the correct way to do it would be

collision_mask = {"item-layer", "object-layer", "player-layer", "water-tile", "layer-15"}

Also, I'd recommend a hidden optional dependency on my mod in info.json:

"dependencies": [ "base >= 0.17", "(?)rail-fix-1775" ],

This way, if my mod is installed, you can be sure it will get loaded before yours (and can't overwrite your changes). Also, by making it a hidden dependency, you wouldn't promote my mod -- it's just a means to allow players to use whatever mods they like.

New response