Panakotta00 / FicsIt-Networks

Control, Monitor, Manage and Automate your Satisfactory.
https://ficsit.app/mod/FicsItNetworks
GNU General Public License v3.0
166 stars 53 forks source link

Inventory issues #117

Closed m-dyke closed 3 years ago

m-dyke commented 3 years ago

Calling GetInventory on a specific factory connector works OK for Output connectors, but input queues return NIL. Also calling GetInventories on different machines returns a spare (NIL) inventory and only one input inventory when more than one is required (e.g. a Foundry has two inputs and one output, but Getinventories returns one input and one output inventories). All input/output inventories are non-empty when examining the machine outside of the network access.

Panakotta00 commented 3 years ago

Wdym?

The whole machine has only one inventory, the differnt slots for the different inputs and outputs are just mapped to specific slots in the inventory. f.e. there is only one inventory, on slot 0 is the input1, on slot 1 is the input2 and on slot 3 is the output.

Or what do you mean?

m-dyke commented 3 years ago

When you're looking at a specific factory connection, then the "getInventory" routine should return the inventory for that connection only and not all of the inventories for the machine. When doing a "GetInventory" on the complete machine, then you should get all of the inventories for the machine but if there are multiple inputs on the machine then the GetInventory doesn't return them. The documentation doesn't mention the different slots, but doing a loop using Pairs on the response from GetInventory should cycle through all of them.

Panakotta00 commented 3 years ago

._.

  1. What you want doesn't sound like you need the factory connector... just the factory (aka machine it self)
  2. The machine has only one inventory... ther is usualy just one... but this single inventory... has multiple slots... where each slot corresponds to one slot in the UI of the machine, or conveyor connection point...
machine = component.proxy("...")
inv = machine:getInventories()[1] -- get the single inventory of the machine
input1Stack = inv:getStack(0) -- returns the stack that is currently on the 1th slot in the inventory (aka the first input)
input2Stack = inv:getStack(1) -- returns the stack that is currently on the 2th slot in the inventory (aka the second input)
outputStack = inv:getStack(2) -- returns the stack that is currently on the 3th slot in the inventory (aka the output)
m-dyke commented 3 years ago

So in order to know what the stacks mean, I have to know what the machine is beforehand? What happens if I don't know what it is? i.e. I'm passed the proxy ID value in a parameter to a procedure and need to have a general routine to handle any sort of machine. Currently, I loop through the factory connectors for that machine to determine inventory. So if I go through them with a count then I can use getStack(count) to get their inventory and not need to use the GetInventory routine on the factoryconnector. Correct?

Panakotta00 commented 3 years ago

Nope, the factory connectors inventory has at first nothing to do with the inventory of the machine... you simply need to know the machine is before hand... with the next update, the reflection update, you will be able to better understand what machine you have there you are working with, so that you can then like have standard implementations for generators, manufacturers and such... then you can still make very neat implementation ^^

m-dyke commented 3 years ago

OK, so what does the factory connectors Getinventory do? Why is it needed?

Panakotta00 commented 3 years ago

To be honest... I'm not sure either... CSS placed it there... still don't know what it does xD

m-dyke commented 3 years ago

I could understand it if it returned the stack associated with that factory connector i.e. Connector number 1 is an Input Conveyer which has 30 Iron ore on it, Connector number 2 is an input conveyor which has 20 coal on it, Connector number 3 is an output Conveyor which has 2 Steel Ingots on it. Hmmm, does the order in the machine Getinventories() match the factory connector data? i.e. first inventory is for the first factory connector, second for the second factory connector etc.

Panakotta00 commented 3 years ago

I doubt it... It returns the order I get from UE... So... idk

As said... dont use GetInventories() on factory connectors since we just dont know what is does right now.

m-dyke commented 3 years ago

OK, I think we've gone as far as we can with this problem, we'll just have to wait until the Reflection update comes along and see if that helps. If you're happy to close this problem, then do so. Thanks for your help.