Page 1 of 1

car/vehicle: prevent enter/exit key

Posted: Sat Sep 01, 2018 10:59 am
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)

Re: car/vehicle: prevent enter/exit key

Posted: Sat Sep 01, 2018 9:24 pm
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.

Re: car/vehicle: prevent enter/exit key

Posted: Mon Sep 03, 2018 10:47 am
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.

Re: car/vehicle: prevent enter/exit key

Posted: Mon Sep 03, 2018 12:27 pm
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? :)

Re: car/vehicle: prevent enter/exit key

Posted: Mon Sep 03, 2018 6:16 pm
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)

Re: car/vehicle: prevent enter/exit key

Posted: Mon Sep 03, 2018 9:43 pm
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...

Re: car/vehicle: prevent enter/exit key

Posted: Tue Sep 04, 2018 6:32 am
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.

Re: car/vehicle: prevent enter/exit key

Posted: Sun Jan 21, 2024 11:13 am
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.