PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

50M Downloads

[Question] Drone check items in inventory and more.

duncanwebb opened this issue ยท 8 comments

commented

Minecraft Version

1.12.2

Forge Version

forge-1.12.2-14.23.5.2768-universal

Mod Version

pneumaticcraft-repressurized-1.12.2-0.10.4-443

Describe your problem, including steps to reproduce it

I've been developing a program to drill core samples and as a result I've some questions

  1. When I place the drone down by right clicking the white wool with the drone the $drone variable shows the height the same a my head position, is this intended?
  2. The condition to check if the inventory has all the items succeeds when there is any one item, do I need three checks, one per item.
  3. Is it possible to tell the drone to select an item in its inventory to be placed down?
  4. Can a item assignment variable hold multiple items?

The program is https://pastebin.com/MXGetZAn

drilling area
drilling program

Any other comments?

If you see anything that can be improved please let me know.
Thanks for you help.

commented

I'll need to do more research on 2 & 4, but:

Q1: Yes, the code does explicitly get the block above the drone's position. Not sure why, but I guess there's some history behind it. I can't really change that now, since it would break any existing programs, so if you need to, you can subtract one from the Y by using a Coordinate Operator in add mode and a (0,-1,0) Coordinate piece.

Q3: No, but I have been thinking about adding an "Equip Item" piece for a while now. It would take one or more Item Filter pieces, and the first item in the drone's inventory which matches a filter would be swapped into slot 0 (which is the drone's "equipped slot"). Update: actually, you can just put an Item Filter piece onto your Place Block piece to restrict what it can place. The Drone does search its entire inventory for placeable blocks, and will pick the first item that matches any filters if filters are attached.

Bear in mind that I didn't write a lot of the existing code - the mod is originally MineMaarten's creation, with the 1.12.2 port & most of the more recent code coming from me. The drone programming stuff in particular is nearly all MineMaarten's, so it's still a learning experience for me sometimes :)

commented

For Q2, I think you're just trying to count three non-stackable items, right? In the Condition: Items piece, you should be able to set a count of "3" and an operator of >= or =. That way it will only be true if at least 3 items match.

commented

Q1: thanks, I did that in the code so it is consistent, sort of concerned if I was standing a block above or below the block where the drone was placed.

Q2: I see the sum of all the items, rather that each item being one or more, makes a lot of sense.

Q3: I tried the filter but it didn't seem to work, I tried this with both the capacitor and the core sample. I could only place the core sample when everything was placed in the chest and only it was selected. It does work with the tool (pickaxe) the program swapped these over.

Q4: I'm trying to find a good use for the item assignment operator, its use seems to be limited.

I really appreciative of your help and the amount of work that you are doing on the mod, I'm sure as the mod has so many feature there is a ton of code to understand and the drone part is tricky. I spent quite a few days thinking about this program before trying to write it.

commented

Q3: both the capacitor & core sample are likely to have a bunch of NBT data; did you ensure NBT/meta was being ignored? I'll have a play with this too in the next couple of days, it's entirely possible there's a bug there.

commented

Q3: I just tested with this much simpler program: https://pastebin.com/A0rDBCz8

Given a chest with drills and capacitors, the drone will place a drill beside the chest and a capacitor beside it. With dispenser upgrades, it pulled all drills & capacitors out, and correctly placed the blocks and activated the core drill. So filtering does appear to work with block placing...

commented

Finally, regarding Q4: item assignment isn't something I've used myself but as I understand it, a variable can only store 1 item. The primary use is in the For Each Item piece; a "subroutine" is called for each attached item filter, where the item in each filter is assigned to the variable in turn. And you can use the Assign Item piece to explicitly assign an item to a variable (including an empty filter, which is useful to break out of the For Each Item loop).

It's all fairly advanced esoteric stuff for which I'm sure @MineMaarten had some uses for when he designed it :)

commented

Q3: That works just fine, wonder why I couldn't get this to work earlier. Many thanks. Placing the capacitor on the drill is much neater than what I was doing.

I tried to use the area tool with both positions on the chest to change the coordinate but it set the coordinate to 0,0,0, instead of one of the points.

Q4: Neat, the for loop is just what I needed, it will cut the program right down, thanks for this hint!
Now I see the purpose of the item assignment widget.

commented

Interesting the for each coordinate widget is not consistent, the order seems to be random and the capacitor needs to be placed on the side, not the top as there is no connector on the top.

When I place the drone on the test zone it goes se, sw, ne, nw but at another place is goes through different patterns.

https://pastebin.com/fVdCNVgW places blocks for each coordinate, the chest needs a drill, capacitor and an iron pick.