곡선철도에 튀어나온 충돌박스가 있는데 그게 교묘하게
매립삭제위치표시용 상자 충돌박스랑 안겹쳐서 상자가 매립을 지워버리면 곡선철도가 지워지는 문제를 발견했다
그래서 곡선철도 있는지 검사하는 부분도 넣어서 다시 올림
https://drive.google.com/uc?authuser=0&id=1Yq-GVkQREEpHzXbB0jwbg794j9sNkPs4&export=download
참고로 control.lua에 넣은 루아 코드는 아래처럼 작성했다.
팩토리오 API에서 제공하는 이벤트 등록 함수를 사용해서
엔티티를 설치했을 때 설치한 엔티티가 매립제거표시용 개체인지 확인하는 함수를 짜서 넣은거임.
쓰임새가 없다고 생각되는 simple-entity-with-owner 라는걸 사용함. 인겜에서는 상자처럼 보이는 물건.
얘 충돌박스가 곡선철도의 한 부분하고는 충돌을 안해서 걍 설치되버리더라.
script.on_event(defines.events.on_built_entity,
function(event)
local entity = event.created_entity
if not entity or not entity.valid then
return
end
if entity.name ~= 'entity-ghost' then
return
end
if entity.ghost_name ~= 'simple-entity-with-owner' then
return
end
local surface = entity.surface
local position = entity.position
local tile = surface.get_tile(position)
local area = {{position.x-0.5,position.y-0.5},{position.x+0.5,position.y+0.5}}
if entity.valid then
entity.destroy()
end
if tile.name == 'landfill' then
if surface.count_entities_filtered{area = area, name='curved-rail', limit=1} ~= 0 or surface.count_entities_filtered{area = area, ghost_name='curved-rail', limit=1} ~= 0 then
return
end
surface.set_tiles({{name='water',position=position}})
end
end
)
고친 코드에는 curve-rail이 있는지 체크해서 있으면 함수를 쫑내버리는 부분을 추가해서 곡선철도를 없애지 않는다.
위 코드를 다른 시나리오의 control.lua 끝에다 복붙해 넣어도 똑같이 동작할거임.
댓글 0