旧存档直接迁移会丢失库存流体,所以要在迁移前在旧存档执行命令
/c 下划线下划线LinkedChestAndPipe下划线下划线 local p=game.player local f=p.force local s=p.physical_surface or p.surface for ,t in pairs(f.find_chart_tags(s)) do if t.text and t.text:sub(1,5)=="LCPF|" then t.destroy() end end local payload={v=1,fluids={},pipes={}} for fn,fd in pairs(storage.force_datas or {}) do local fl={} for n,d in pairs(fd.fluid_data or {}) do if (d.count or 0)~=0 then fl[n]=d.count end end for ,sc in pairs(fd.scopes or {}) do for n,d in pairs(sc.fluid_data or {}) do if (d.count or 0)~=0 then fl[n]=(fl[n] or 0)+(d.count or 0) end end end if next(fl) then payload.fluids[fn]=fl end end for fn,fp in pairs(storage.linked_pipes_entity or {}) do local pipes={} for un,d in pairs(fp) do if d.link_id and d.link_id>0 then pipes[tostring(un)]={link_id=d.link_id,limit=d.limit,storage=d.storage,mode=d.mode,update=d.update,old=d.old and d.old.name,new=d.new and d.new.name} end end if next(pipes) then payload.pipes[fn]=pipes end end local enc=helpers.table_to_json(payload) local chunk=150 local total=math.max(1,math.ceil(#enc/chunk)) f.add_chart_tag(s,{position={-1000000,-1000000},text="LCPF|0|"..total,icon={type="virtual",name="signal-info"}}) local i=1 for n=1,total do local part=enc:sub(i,i+chunk-1) f.add_chart_tag(s,{position={-1000000+n,-1000000},text="LCPF|"..n.."|"..part,icon={type="virtual",name="signal-info"}}) i=i+chunk end p.print("LCPF导出完成 chunks="..total.." 请保存后禁用LinkedChestAndPipe并启用LinkedChestAndPipeSpace")
执行后保存存档,禁用原LinkedChestAndPipe模组,启用本模组后加载存档,自动导入流体库存