질문글 : [질문] 진열판 모드 복붙할때 아이콘이 사라지는데





Display Plates 모드는 기본적으로 청사진 복붙을 잘 지원한다




.



근데 Bulk rail loader 모드를 사용하면 고장나버린다

참조 : [정보] 레일로더에 관한 글 이것 저것




왼쪽은 청사진을 생성할 때 레일로더 모드에서 일어나는 일

오른쪽은 청사진을 생성할 때 진열판 모드에서 일어나는 일


왼쪽의 일이 먼저 일어나고 그 이후에 오른쪽의 일이 일어나도록 되어있다



결론만 요약하자면 레일로더에서는 레일로더 상자의 크기 제한이 몇으로 되어있었는지에 대한 정보를 청사진에 태그로 추가해주고 있고

진열판 모드에서는 무슨 아이템을 표시하고 있었는지에 대한 정보를 태그로 추가해주고 있음


단 그 매커니즘에 차이가 있는데

레일로더에서는 청사진에 들어있는 모든 엔티티를 직접 순회하면서 그 엔티티가 레일로더 상자라면 태그를 추가하고, 그렇지 않으면 스킵. 완성된 정보들을 바탕으로 청사진을 재구축하도록 되어있음


진열판 모드에서는 좀 다른데, 블루프린트를 생성하는 이벤트에는 mapping이라는 정보를 사용해서 엔티티를 순회하고 그 엔티티가 진열판이라면 태그를 추가해주고 있음


https://lua-api.factorio.com/latest/events.html#on_player_setup_blueprint


문제는 어떤 다른 모드가 청사진을 건드렸다면 나중에 그 청사진을 건드리는 모드에서는 mapping이라는 정보가 유효하지 않게 되어버림

그래서 태그를 못달고 버그가 발생하게 됨



두 개 이상의 모드가 순차적으로 청사진을 건드리기 위해서는 레일로더의 방식으로 통일하는게 맞아 보이고, 즉 진열판 모드의 control.lua 파일을 수정해주어야함


script.on_event(defines.events.on_player_setup_blueprint, function(event)

local player = game.players[event.player_index]

local blueprint = nil

if player and player.blueprint_to_setup and player.blueprint_to_setup.valid_for_read then

blueprint = player.blueprint_to_setup

elseif player and player.cursor_stack.valid_for_read and player.cursor_stack.name == "blueprint" then

blueprint = player.cursor_stack

end

if blueprint then

-- Dont crash when updating blueprint

if blueprint.get_blueprint_entity_count() == 0 then

if player.mod_settings["display-plates-no-update"].value then

player.print({ "blueprints.no-update" })

end

return

end

for index, entity in pairs(event.mapping.get()) do

local stype, sname = get_render_sprite_info(entity)

if stype and sname then

blueprint.set_blueprint_entity_tag(index, "display-plate-sprite-type", stype)

blueprint.set_blueprint_entity_tag(index, "display-plate-sprite-name", sname)

blueprint.set_blueprint_entity_tag(index, "display-plate-sprite-map-marker", get_has_map_marker(entity))

end

end

end

end)


이 부분을 (511줄쯤에 있음)


script.on_event(defines.events.on_player_setup_blueprint, function(event)

local player = game.players[event.player_index]

local blueprint = nil

if player and player.blueprint_to_setup and player.blueprint_to_setup.valid_for_read then

blueprint = player.blueprint_to_setup

elseif player and player.cursor_stack.valid_for_read and player.cursor_stack.name == "blueprint" then

blueprint = player.cursor_stack

end

if blueprint then

-- Dont crash when updating blueprint

if blueprint.get_blueprint_entity_count() == 0 then

if player.mod_settings["display-plates-no-update"].value then

player.print({ "blueprints.no-update" })

end

return

end

local entities = blueprint.get_blueprint_entities()

for index, entity in pairs(entities) do

if DID.displays[entity.name]~=nil then

local display_entity = player.surface.find_entities_filtered{ type = "simple-entity-with-owner", position = entity.position }[1]

local stype, sname = get_render_sprite_info(display_entity)

if stype and sname then

if entity.tags==nil then entity.tags={} end

entity.tags["display-plate-sprite-type"] = stype

entity.tags["display-plate-sprite-name"] = sname

entity.tags["display-plate-sprite-map-marker"] = get_has_map_marker(display_entity)

end

end

end

blueprint.set_blueprint_entities(entities)

end

end)


이걸로 고친다


파일 바로 받으려면 아래 링크로


https://drive.google.com/file/d/19JFQmFTkJwwfBp3LQPOGeJ5GlsxB2hsB/view?usp=drive_link

DisplayPlates_1.5.1.zipDisplayPlates_1.5.1.zipdrive.google.com



만약 멀티로 할거라면 당연하지만 모든 사람이 다 같은 파일 써야함


아무래도 야매로 고친거다 보니 버그가 전혀없다고는 장담할 수 없음

그거 감안해서 쓰길