Advanced Peripherals

Advanced Peripherals

29M Downloads

ME Bridge have getCraftingCPUs() include CPU names in result

TheIncgi opened this issue ยท 8 comments

commented

Describe your idea

For the ME Bridge the getCraftingCPUs() function listing idle CPUs you see results like

{
  {
    storage = 1024,
    coProcessors = 0,
    isBusy = false
  }
}

My suggestion is to include the CPU name

{
  {
    storage = 1024,
    coProcessors = 0,
    isBusy = false,
    name = "CPU #1" --or name set by anvil
  }
}

Describe alternatives you've considered if you've any

Not sure yet if the order of multiple CPUs is always the same (after network resets), but names could be hardcoded in lua or as a config.

Additional context

I wanted to find CPUs that have a name matching some format. Something like this.

local automationCPUs = {}
local prefix = "Automation #"
for i, cpu in ipairs( meBridge.getCraftingCPUs() ) do
  if cpu.name:sub(1, #prefix) == prefix then
    table.insert( automationCPUs, cpu )
  end
end

Also, I'm using 1.19.2

Linked Issues

No response

commented

I've implemented a name key to the table. However, I can't set the name of non anvil named CPUs. AE calculates they names only in the container/menu of the status screen in the terminal. They aren't set per CPU.

So name will either be the actual name of the CPU or Unnamed

If it's just the one's named with an anvil that's fine by me, even if they can have the same name.
I was looking for a way to get some subset of CPU's based on name and this accomplishes that.

If you want, you can download and test it yourself from here

I'll check it out,
Thanks! ๐Ÿ˜„

commented

I've implemented a name key to the table. However, I can't set the name of non anvil named CPUs. AE calculates they names only in the container/menu of the status screen in the terminal. They aren't set per CPU.

So name will either be the actual name of the CPU or Unnamed

commented

If you want, you can download and test it yourself from here

commented

So name will either be the actual name of the CPU or Unnamed

Maybe Unnamed-#(id|index)

commented

So name will either be the actual name of the CPU or Unnamed

Maybe Unnamed-#(id|index)

The point is, AE does not provide any ID or Index
I could provide an index, but that would not be the same as the index you see in the crafting status terminal menu, so I wouldn't be sure if this is useful

I will probably just add an ID and add a proper documentation to this system

commented

I think make the name unique is useful, but I'm not sure if AE2 will ensure two CPU must have different names

commented

ok, then nvm

commented

I think make the name unique is useful, but I'm not sure if AE2 will ensure two CPU must have different names

AE2 does not care about these. You could give all the CPUs the same name