おまけ3 レッサープログラマブルロジスティクスで書かれた、並列処理ライブラリの一部とか。
world.machine_insert(string: machine_uuid, string: input_uuid, table: recipe)
指定されたストレージから、指定した機械へ、1対1で指定レシピの搬入を試みる。
搬入が出来た場合、trueを返し、搬入が出来なかったり、素材が足りないと、falseを返す。
素材が足りなかったら、搬入は行われない。
world.machine_pull(string: machine_uuid, string: output_uuid)
指定された機械から、成果物の回収を試み、成功した場合はtrueを返しストレージに返される。
失敗した場合は、falseを返す。
local _module = {}
_module["machines"] = {}
function _module.register_machine(uuid, machine_name)
if not _module["machines"][machine_name] then
_module["machines"][machine_name] = {}
end
table.insert(_module["machines"][machine_name], uuid)
end
function _module.parallel_machine_insert(machine_name, input_uuid, recipe)
if not _module["machines"][machine_name] then
return
end
for _, value in ipairs(_module["machines"][machine_name]) do
while world.machine_insert(value, input_uuid, recipe) do
end
end
end
function _module.parallel_machine_pull(machine_name, output_uuid)
if not _module["machines"][machine_name] then
return
end
for _, value in ipairs(_module["machines"][machine_name]) do
world.machine_pull(value, output_uuid)
end
end
return _module




