I'm making a lot of car mods lately. My newest "car" mod is a stationary bunker. It cannot move but shoot.
It has a collision_box of {{-4.5, -3.7}, {4.5, 3.7}}. Whenever I try to exit the "car" after I entered it, it won't let me. No obstacles in the way, just me and the "car" in an empty testing area.
I tested around a bit and i found out that cars won't let you out if their collision_box width is bigger than their length. So {{-10, -10}, {10, 10}} works but {{-10.1, -10}, {10.1, 10}} doesn't. If the width and length are really small (e.g. {{-1.9, -1}, {1.9, 1}}) it may work but on larger scale it's more clearly.
[Lou][1.1.34] Car prototype collision_box width to length ratio prevents exiting of car
[Lou][1.1.34] Car prototype collision_box width to length ratio prevents exiting of car
- Attachments
-
- factorio-current.log
- (70.33 KiB) Downloaded 173 times
Re: [1.1.34] Car prototype collision_box width to length ratio prevents exiting of car
I tried to fix it with a custom-input where I would be teleported out of the bunker per script but it seems the game doesn't wanna do that too. I used the script from the cargo ships mod and adapted it to my use. It works on all other car/train prototypes but not my bunker.
kj_tile_player_test_item has the following important properties:
collision_mask = {"water-tile", "player-layer"}
collsion_box = {{-1,-1.2},{1,1.2}}
Code: Select all
function ExitBunker(e)
local player_index = e.player_index
local pos = game.players[player_index].position
local X = pos.x
local Y = pos.y
game.print("Player pressed the button.")
if game.players[player_index].vehicle == nil then
game.print("Player not in a vehicle.")
else
game.print("Player in a vehicle.")
local new_pos = game.players[player_index].surface.find_non_colliding_position("kj_tile_player_test_item", pos, 10, 0.5, true)
game.print("Searching for position.")
if new_pos ~= nil then
game.print("Position found!")
local old_vehicle = game.players[player_index].vehicle
if old_vehicle.name == "kj_40kbunker" then
local driver = old_vehicle.get_driver()
if driver ~= nil and driver.type == "character" then
driver = driver.player
if driver ~= nil and driver == game.players[player_index] then
old_vehicle.set_driver(nil)
end
end
local passenger = old_vehicle.get_passenger()
if passenger ~= nil and passenger.type == "character" then
passenger = passenger.player
if passenger ~= nil and passenger == game.players[player_index] then
old_vehicle.set_passenger(nil)
end
end
else
old_vehicle.set_driver(nil)
end
game.players[player_index].driving = false
game.players[player_index].teleport(new_pos)
game.print("Teleporting "..game.players[player_index].name.." to: "..new_pos.x.."|"..new_pos.y)
else
game.print("No free space!")
end
end
end
script.on_event("kj_exit_bunker", ExitBunker)
collision_mask = {"water-tile", "player-layer"}
collsion_box = {{-1,-1.2},{1,1.2}}
Re: [1.1.34] Car prototype collision_box width to length ratio prevents exiting of car
Can you provide a copy of the mod for testing?
Re: [1.1.34] Car prototype collision_box width to length ratio prevents exiting of car
Re: [Lou][1.1.34] Car prototype collision_box width to length ratio prevents exiting of car
Hello! Thank you for the feedback. The behaviour is fixed for the next release - cause was an issue with the mechanics of exiting car.