[Lou][1.1.34] Car prototype collision_box width to length ratio prevents exiting of car

This subforum contains all the issues which we already resolved.
Post Reply
TheKingJo
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Jan 02, 2021 1:22 am
Contact:

[Lou][1.1.34] Car prototype collision_box width to length ratio prevents exiting of car

Post by TheKingJo »

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.
Attachments
factorio-current.log
(70.33 KiB) Downloaded 134 times

TheKingJo
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Jan 02, 2021 1:22 am
Contact:

Re: [1.1.34] Car prototype collision_box width to length ratio prevents exiting of car

Post by TheKingJo »

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.

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)
kj_tile_player_test_item has the following important properties:
collision_mask = {"water-tile", "player-layer"}
collsion_box = {{-1,-1.2},{1,1.2}}

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5148
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [1.1.34] Car prototype collision_box width to length ratio prevents exiting of car

Post by Klonan »

Can you provide a copy of the mod for testing?

TheKingJo
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Jan 02, 2021 1:22 am
Contact:

Re: [1.1.34] Car prototype collision_box width to length ratio prevents exiting of car

Post by TheKingJo »

Klonan wrote:
Sun Jun 06, 2021 2:26 pm
Can you provide a copy of the mod for testing?
Both 1.1.0 and 1.1.1 have the bug:
https://mods.factorio.com/mod/kj_40kbunker/downloads

User avatar
Lou
Factorio Staff
Factorio Staff
Posts: 58
Joined: Mon Nov 30, 2020 10:50 am
Contact:

Re: [Lou][1.1.34] Car prototype collision_box width to length ratio prevents exiting of car

Post by Lou »

Hello! Thank you for the feedback. The behaviour is fixed for the next release - cause was an issue with the mechanics of exiting car.

Post Reply

Return to “Resolved Problems and Bugs”