Schall Overseas Railway


A tiny mod allowing rails (with rail signals) to be placed over water tiles. (Locale: English, Deutsch, 正體中文, 简体中文, Português Brasileiro)

Tweaks
6 months ago
0.16 - 1.1
6.58K
Trains

b [Pending] Unable to build rails on Shallow Water

2 years ago

Sometimes I'm unable to build rails on water. The message says that I cannot build on Shallow Water.
It's better if I could build rails on any kind of water!

Thanks.

1 year, 7 months ago

I looked at the code, after some wiki search I found out there is not much on collision doc, it's unclear what is what. Shallow Water is sort of ground title so any object with ground tile collision refuse to go on shallow water.

I changed code of data-updates.lua to:

local collision_masks =
{
  pole        = { "object-layer" },
  rail        = { "object-layer", "rail-layer" },
  railsignal  = { "object-layer", "rail-layer" }, 
}

local dr = data.raw

dr["straight-rail"]["straight-rail"].collision_mask = collision_masks.rail
dr["curved-rail"]["curved-rail"].collision_mask = collision_masks.rail
dr["rail-signal"]["rail-signal"].collision_mask = collision_masks.railsignal
dr["rail-chain-signal"]["rail-chain-signal"].collision_mask = collision_masks.railsignal

if settings.startup["overseasrailway-big-pole-modify"].value then
    dr["electric-pole"]["big-electric-pole"].collision_mask = collision_masks.pole
end

This work quite well.

6 months ago

Sorry for late reply. Just revisiting the game and re-picking up the modding.

Does the problem still persist?
Just tested on 1.1.91, where I can place rails, big electric pole and both rail signals on shallow water. Can build without any problem.

If still failing, are there any other mods that may change the masks settings?
(Please read the blue tooltip line when hovering over those items.)

6 months ago

It's working now, but maybe I have change some things in the code!
I'll search and answer here!

Thanks.

6 months ago

Just updated to 1.1.1.
I have added "rail-layer" to collision masks of rails and rail signals. (It was added in game 1.1.0, but I overlooked that when rushing to make the mod working again...) So please check if it matters in your games.

6 months ago

Hi, the updated version doens't allow me to build rail on shallow water!

I changed the file "config-1.lua":

config.collision_masks =
{
default = { "object-layer", "train-layer" },
rail = { "object-layer", "rail-layer" },
railsignal = { "rail-layer" },
remove = nil,
}

And now it's working!

Thanks.

6 months ago
(updated 6 months ago)

By comparing with your modified code, I guess the critical change lies in "floor-layer".
There is no official explanation about what each layer does exactly, so it is hard to figure why it is so. (Just like what "floor-layer" & "item-layer" exactly do???)
Anyway, my guess is one(+) of your used mods has modified "floor-layer" to a great extent. Are you using some swimming mods or something to do with terrain?
Maybe I shall add an extra option to remove "floor-layer" to the next version. Would it be a proper way to make this mod working (no code editing needed) for your mod set?
BTW, I would like to know what is the cause. Which mod has caused this? I will add such info to the option tooltip and compatibility list, if I can know this.

P.S. 1: Curious about your line of default (applied to big electric pole). It is not present in vanilla nor my original code. Do you need this extra "train-layer" to make it work?

default = { "object-layer", "train-layer" },

P.S. 2: The remove = { "water-tile", "item-layer", "player-layer" } line is a failsafe line to remove water-related masks, in case the collision masks values are no longer nil by vanilla default (e.g., some mods who are introducing their own set of layers, or some overhaul mods.) So are you sure setting it to nil is needed to make it works in your game?

6 months ago

I'm not sure what I have done and if it have any unintended consequences! I move this modification from the previous versions and appears to be working fine!

Maybe could be useful to inform that I'm using water tiles provided by the mod "Safe Waterfill" (https://mods.factorio.com/mod/safefill)

Thanks.

New response