joe7575 / signs_bot

A Minetest robot controlled by signs
GNU General Public License v3.0
5 stars 7 forks source link

Can't lay techage tube with signs bot #35

Open gd2shoe opened 11 months ago

gd2shoe commented 11 months ago

I haven't decided yet if this is a bug with signs bot, with techage, or if there's something fundamental that I'm missing.

When the bot places techage stuff (pipe, tube, cable, power line), they don't automatically join together.

At first I thought that the bot was somehow placing nodes without calling their constructor, but chests are fine (have mandatory constructors). Fences placed by the bot connect to each other just fine. It's just the techage stuff that seems incompatible with sign bot somehow.

gd2shoe commented 11 months ago

Update: Mesecons laid down by the bot are also buggy. They might (or might not) appear to join up, but they don't transmit signals unless you break and replace some of them.

joe7575 commented 11 months ago

Yes, that's right. This is currently not possible. The bot would have to call the function after_place_node(pos, placer, itemstack, pointed_thing). The difficult part here is the argument placer which is the player with all its attributes and functions.

To make it short: You can't place techage stuff with the bot.

Eternal-Study commented 2 months ago

I believe this issue can be fixed, and have coded a working proof of concept. There are a couple of answers required before a pull request can be submitted.

By substituting minetest.set_node with the digtron.item_place_node function from the Digtron mod, the bot can set tubes, cables, etc… that will align and connect to each other. Two questions arise from this option:

1) In order to implement digtron.item_place_node, fake player information is required as input. The fake player from the Techage mod works, but it would need to be duplicated into this mod to prevent creating a dependence. This would also require maintaining the code in two different places.

However, if Techage PR 170 is to be implemented, then it would be best to use fakelib here too.

Joe7575, would you prefer a PR using your own Fake_Player code, or fakelib’s?

2) This requires code from Digtron. While creating a dependency for Digtron or only enabling this feature when Digtron is installed would work, a better option is to copy the code into this mod.

Conveniently, the digtron.item_place_node function call is contained in its own file. And is licensed under LGPL 2.1, which can be re-licensed under GPLv3. However, the copyright belongs to other parties, with the accompanying consequences for re-releasing the code under other open or closed licenses.

Joe7575, would you approve the use of Digtron code in a pull request to address this issue?

screenshot_20240727_223418 Screenshot taken from edited mod running the proof of concept code. Note how the three tubes vertically placed by the bot are connected.

joe7575 commented 2 months ago

I could imagine using the fakelib for this. But it would have to be an optional feature, as there are also disadvantages when blocks are set as fake players. A separate command would also be useful here.

I haven't looked at the digitron function yet, but I don't like being dependent on digitron. I would rather integrate the code into Techage under a different license.

There are two ways to place tubes (with and without the shift key). The direction of view or the crosshairs also play a role here. This might not be so easy to implement...

Eternal-Study commented 1 month ago

A separate command would also be useful here.

I'll include it as separate commands, with a description that indicates the commands are to be used for blocks that link to each other. (cables, tubes, etc...)

But it would have to be an optional feature

To be clear, when you say optional feature, do you mean make the command that connects tubes a separate bot command, or that fakelib should be an optional dependency instead of a required one?

I would rather integrate the code into Techage under a different license.

Easily enough done.

There are two ways to place tubes (with and without the shift key). The direction of view or the crosshairs also play a role here. This might not be so easy to implement...

Agreed, it is has not been easy to implement. Instead of making a command that matches the player's ability to place tubes, it is better to not include crosshair nor shift key information. In other words, when Sign Bot places a tube, it will connect to adjacent tubes and machines, but if there are multiple connections available, the player will not be able to specify which connections it makes.

This is still an improvement, as the bot can do most of the work, and the player can still make fixes and adjustments after it is done. Or they can design machines in a way that tubes can only connect in one way.

At a later time, when I'm more familiar with Lua, Minetest, Techage, and Tubelib I can try add the ability to more finely specify how tubes placed by the bot connect.

joe7575 commented 1 month ago

But it would have to be an optional feature

To be clear, when you say optional feature, do you mean make the command that connects tubes a separate bot command, or that fakelib should be an optional dependency instead of a required one?

fakelib should be an optional dependency. If installed the new commands is available.