Some mods use surface cloning. eg. Space Exploration uses it to launch spaceships.
I'm using the following code to allow a moon logic combinator to function on spaceships.
Any chance something like that could be added to the mod?
Thanks.
local function on_entity_cloned(ev)
if ev.destination.name == 'mlc-core' then
ev.destination.destroy()
return
end
if not (ev.source.name == 'mlc' and ev.destination.name == 'mlc') then return end
local uid_src, uid_dst = ev.source.unit_number, ev.destination.unit_number
global.combinators[uid_dst] = tdc(global.combinators[uid_src])
local mlc_dst, mlc_src = global.combinators[uid_dst], global.combinators[uid_src]
mlc_dst.e, mlc_dst.core, mlc_dst.next_tick = ev.destination, bootstrap_core(ev.destination), 1
guis.history_insert(global.guis[uid_dst], mlc_src, mlc_src.code or '')
end
script.on_event(defines.events.on_entity_cloned, on_entity_cloned)