PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

50M Downloads

addArea CC API Filled AreaType not Working?

jebjordan opened this issue ยท 4 comments

commented

Minecraft Version

1.16.5

Forge Version

36.1.32

Mod Version

pneumaticcraft-repressurized-1.16.5-2.13.0-199.jar

Describe your problem, including steps to reproduce it

Not sure on steps.. but a few things I can't seem to understand why they won't work with the cc api:

First, as far as I can tell, both getDroneName and getOwnerID don't work. They returned nil both timed I attempted to use them.
Could be some other problem though not sure.

Anyways though, main thing here is that when I try to use the "Filled" areaType it does not work.
Although a few others do. That one in particular, and also I believe it was Walls did not work too.

This is on the ATM6 1.6.14 modpack version if that helps.

Lua Code

Any other comments?

If I'm doing something wrong here, please do let me know.

commented

by the way, while I'm here,
What's the reasoning that the api isn't more direct?
Why can't I just go setAction('pneumaticcraft:teleport', area)
yknow?
Why all the addArea, clearArea, etc.
why not just local newArea = Area(1, 2, 3, 5, 5, 5);
Area.Point1, Area.Point2 etc yknow?

ignore my rant

(also, why is there no constant variable for dronePosition in the normal programming table?)

commented

OK, there are some bugs here:

  • getDroneName() and getOwnerId() will return the drone's name and owner's UUID in the next release
  • addArea() will take a Filled area type in the next release (currently it's Fill but that's wrong - getAreaTypes() shows Filled, which is what it should be)

What's the reasoning that the api isn't more direct?

The API is very low-level, that's how it was designed originally (I didn't write it). It corresponds quite closely to how drones are programmed in the Programmer; you define parameters with calls like addArea() or setSides() (which are either puzzle pieces in the Programmer, or options set via the progwidget's GUI), and then you tell the drone what its current action should be.

The best way of making this friendlier would be a Lua API layer on top of the low-level interface, which could add calls like drone.dig(<area>, <params...>) but that's not something I personally plan to add. There's a lot to consider in making it a robust and clean API - optional parameter handling, some kind of callback system for the drone to indicate when its current action is done, etc. It's highly non-trivial to do this properly.

why is there no constant variable for dronePosition in the normal programming table

There is - drone.getVariable("$drone_pos") will do exactly that. Special vars (ones that start with "$") are documented in the manual; see the "Variables" page.

commented

There's a second reason for the indirectness of the API - multithreading. ComputerCraft runs in its own Java thread, and Minecraft is not really a multithreaded game. In particular, any changes to the world must not happen from a separate thread, like the one CC runs in (or you risk game crashes, world corruption, etc).

But the CC/Drone integration doesn't directly change the world; it just sets various parameters in the drone (including what its next action should be), and the drone picks up that information in the main thread and goes and does its stuff.

commented

Fixed in 2.13.3 release