car/vehicle: prevent enter/exit key

Things that we aren't going to implement
Post Reply
CaveGrinder
Inserter
Inserter
Posts: 35
Joined: Fri Aug 24, 2018 7:42 pm
Contact:

car/vehicle: prevent enter/exit key

Post by CaveGrinder »

Hello again!

currently i am working on a mod that adds an elevator to the game.
The elevator is actually a (invisible) car, i insert and eject the player (as a passenger) via scripts, and control the elevators movements too. This works pretty well actually.
However there are 2 corner cases that i cannot handle nicely: the player can jump out of the elevator in mid-air, and if lucky enough can enter a moving elevator as a driver and then 'steal' it.
The proposal:
I would like to specify that a player cannot enter or leave a vehicle.
For me it is not relevant if this is in the 'data' or 'control' time.
so it could be for example in the car/vehicle data prototype two entries:
allow_player_enter=false
allow_player_exit=false
But maybe someone could find a use for it changing dynamically, so it could also be
LuaEntity::vehicle_interaction_enter_allowed=false
LuaEntity::vehicle_interaction_exit_allowed=false
(or some other better name for it)
if they are set to false, it should still be possible to insert/eject a player via scripts set_passenger/set_driver; just the 'enter/leave vehicle' key should be prevented.
The workarounds:
As suggested in
viewtopic.php?f=28&t=31459
i can 'prevent' a player from entering, by throwing them out after they have entered the driver seat. maybe i could also force a player back into a car when they left too early.
(i made a seperate request thread as the other post did not request to prevent exit too)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: car/vehicle: prevent enter/exit key

Post by Rseding91 »

This is outside of what I want to support mod API wise. A hack to make another hack work in a mod makes no sense.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: car/vehicle: prevent enter/exit key

Post by eradicator »

A method to declare a car prototype "not-rideable" would actually benefit a few other mods. As cars are often used for their unique properties, even when they're not supposed to be cars. I.e. like the old nixie-tubes mod used cars soley for the availability of 64 sprite rotations. And as far as i remember nixie had to prevent players from entering the display elements by putting a fake player entity into each of them.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Bilka
Factorio Staff
Factorio Staff
Posts: 3129
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: car/vehicle: prevent enter/exit key

Post by Bilka »

eradicator wrote:As cars are often used for their unique properties, even when they're not supposed to be cars.
So a hack to make a hack work? :)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

CaveGrinder
Inserter
Inserter
Posts: 35
Joined: Fri Aug 24, 2018 7:42 pm
Contact:

Re: car/vehicle: prevent enter/exit key

Post by CaveGrinder »

yeah, i understand the reasoning, it really was more of a request for a hack.
if put this way, the proper solution for my issue would be the addition of a prototype 'autonomous vehicle', an entity that cannot be controlled by a player but can have passengers. (and doesn't come with all of the rail logic like a cargo-wagon)
the rest could be phrased as a restriction 'boarding-requires-standstill'
i guess i instinctively preferred to suggest a hack as it seems like less effort :oops:
but thanks for thinking about it anyway; i don't think it would be the most important feature (although it probably allows for interesting creations)

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: car/vehicle: prevent enter/exit key

Post by eradicator »

Bilka wrote:
eradicator wrote:As cars are often used for their unique properties, even when they're not supposed to be cars.
So a hack to make a hack work? :)
As using entities in ways not originally intended is the only way to get any sort of new feature modded into the game i have stopped considering this a hack a long time ago. Otherwise 90% of all mods are "hacks". So if anything, it's a request to "make the hack less ugly", like most other API requests. And API features to "stop" certain types of prototype behavior are not exactly new: operable, active, the new inserter-position override, etcpp...
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

CaveGrinder
Inserter
Inserter
Posts: 35
Joined: Fri Aug 24, 2018 7:42 pm
Contact:

Re: car/vehicle: prevent enter/exit key

Post by CaveGrinder »

true; the flexibility we already have allows for far more unique creations (but pushing the intended limits is needed occasionally).
if anyone needs some context for this request, i have zipped the mod i am currently working on. (it requires https://mods.factorio.com/mod/SantasNixieTubeDisplay 0.1.5 as a dependency)
it is of course still work in progress.
it adds skyscrapers as placeable entities, as an alternative to factorissimo. they all come with a staircase, and bigger ones also have an elevator, to travel up and down.
Attachments
Skyscrapers_0.1.1.zip
(292.69 KiB) Downloaded 68 times

User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 286
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

Re: car/vehicle: prevent enter/exit key

Post by SupplyDepoo »

eradicator wrote:
Mon Sep 03, 2018 9:43 pm
As using entities in ways not originally intended is the only way to get any sort of new feature modded into the game i have stopped considering this a hack a long time ago. Otherwise 90% of all mods are "hacks". So if anything, it's a request to "make the hack less ugly", like most other API requests. And API features to "stop" certain types of prototype behavior are not exactly new: operable, active, the new inserter-position override, etcpp...
This! Every time I consider making a mod for Factorio I'm put off by the limited APIs. I don't see a reason why mods should not be able to listen to specific key press events ("enter-vehicle", and "exit-vehicle" or whatever the internal names are). Pressing these keys in multiplayer is already laggy anyway, so there may as well be an event that we can listen to and then call event.preventDefault() or something like that. Give mod makers more flexibility and trust them to use the tools wisely. Caveats like "this will cause significantly increased network traffic or UPS impact" can be added to the API documentation where needed.

Post Reply

Return to “Won't implement”