Railway Motor Car

by S3bulon

Adds a railway motor car as an equipment to ride the railway without placing a locomotive manually.

Content
7 months ago
1.0 - 1.1
10.3K
Trains

i Smoothing compatibility with undrivable Spidertrons

8 months ago

Hello. I'm having a very annoying interaction with "Companion Drones" mod. In most cases I can't get into the motor car because of companions flying around.
Demo: https://i.imgur.com/a/9qEnO7O

I tried to reduce spidertron search radius in scripts/use_equipment.lua 123 line, but it raised the exception (condition) on line 210 "...not data.motorcar.get_driver()..." if I tried to enter the motor car near the companions (within 3-4 units radius).

So, my idea is to additionally filter enteties with type "spider-vehicle" by the property "allow_passengers" or at least "name". Is it possible? Maybe the problem is in "enter vehicle" event override and should be fixed in "Companion Drones" mod?

Here are some properties of the Companion entity: https://i.imgur.com/N8iwOnZ.png

8 months ago
(updated 8 months ago)

On the other side, 0.3.2 version (before the commit "spidertron preferred") interacts with Companions as expected (https://i.imgur.com/HRwQUzh.mp4), while ordinary use causes a known error. So the problem is fixable, if only I could resolve all these changes since 0.3.2 (scratching backhead).

UPD, BUG: Actually the problem is in commit 1b52fe27 (1.1.87 fix) – new method is bugged when if there's any vehicle near rails: https://i.imgur.com/PIB0yQa.mp4, so the filter should be also extended to detect any drivable vehicle.

8 months ago

Yes, Wube changed the "toggle-driving" event (entering the vehicle) with 1.1.87, and my old logic was not usable anymore.
Thanks for the suggestion of the filters - I will look into it.

8 months ago

I should thank you for spending your time :)
The old logic is still usable for solving the case: (Vehicle is in range of N) && (IsItDriveable==false).

I see this kind of logic: https://github.com/XyuNaBlude/tmp/commit/9dfa4a80.
But it needs proper implementation.

8 months ago

The mod ignores undriveable vehicles with 0.4.3.
But duplicates are still created, this might be a bug in Factorio.

7 months ago

Finally fixed with 0.4.4.

It is still possible that duplicates are created, or that the motorcar cannot be entered, but it should be less frequent.

7 months ago

Hey, I just came to offer my workaround try (https://github.com/XyuNaBlude/railway-motor-car/commits/Duplications_Workaround) and thank you for your previous commit with proper filter.
So, yeah, there's something weird with driving toggle event (raise, call or whatever) and radii. I was working on it, minimizing the probability of unacceptable interactions. Tried several unsuccessful solutions and returned to the radii manipulating (avoiding full code rework).
I have doubts about shared radius=5 in your current commit. 5 was good for drivable vehicles (to prevent unacceptable interactions), but not for undrivable. I'll test it sometime and give you a feedback.
Thanks.

7 months ago

Yep, radius should be adjusted for un/drivable vehicles.
Here's my workaround: https://i.imgur.com/POJ7qlv.mp4; comparing to yours: https://i.imgur.com/U12tMCS.mp4.
I'm (still) working on it: https://github.com/S3bulon/railway-motor-car/compare/master...XyuNaBlude:railway-motor-car:Radii_Fix. Radii from my prev workaround doesn't fit here.

7 months ago
(updated 7 months ago)

Someway calculating radius from var "position" (motorcar's position) instead of "player.position" works consistently.
Use the link above to check the final changes, the last commit is ready to merge. Also there're couple of comments in commits view section if something seems senseless.
Demo gif is the same.

7 months ago

Thanks for your hard work, I integrated it with 0.4.5.

Regarding the change at line 247 / adding the "data.motorcar.destroy()": Other mods my not teleport the motorcar, but clone / create a new locomotive and copy the contents.
And if I delete the old motorcar, an exception occurs, e.g. when using the space elevator in https://mods.factorio.com/mod/space-exploration
Thats the reason for the cleanup-comment.

7 months ago

Oh, that thing, an omnipresent NullReferenceException. Makes sense.
Thanks for the cooperation, it could be painful to make this fix by myself (#Lua♥).

New response