buffer mapped elements in cpu list so as to not lose equivalent cpus

closes #1921
This commit is contained in:
payonel 2018-02-18 13:01:19 -08:00
parent aa84a24325
commit b24e3e6f6b

View File

@ -80,12 +80,17 @@ trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActi
}
@Callback(doc = "function():table -- Get a list of tables representing the available CPUs in the network.")
def getCpus(context: Context, args: Arguments): Array[AnyRef] =
result(tile.getProxy.getCrafting.getCpus.map(cpu => Map(
"name" -> cpu.getName,
"storage" -> cpu.getAvailableStorage,
"coprocessors" -> cpu.getCoProcessors,
"busy" -> cpu.isBusy)))
def getCpus(context: Context, args: Arguments): Array[AnyRef] = {
val buffer = new mutable.ListBuffer[Map[String, Any]]
tile.getProxy.getCrafting.getCpus.foreach(cpu => {
buffer.append(Map(
"name" -> cpu.getName,
"storage" -> cpu.getAvailableStorage,
"coprocessors" -> cpu.getCoProcessors,
"busy" -> cpu.isBusy))
})
result(buffer.toArray)
}
@Callback(doc = "function([filter:table]):table -- Get a list of known item recipes. These can be used to issue crafting requests.")
def getCraftables(context: Context, args: Arguments): Array[AnyRef] = {