grorp / ggraffiti

Graffiti mod for Minetest
GNU Affero General Public License v3.0
8 stars 4 forks source link

ggraffiti entities should be able to be picked up #10

Open KaylebJay opened 1 year ago

KaylebJay commented 1 year ago

My idea would be that they could be picked up by some tool and converted into an item in the inventory. The items would all look alike (probably), but have different metadata, so that when placed, they look like the painting which was picked up (spawning a new ggraffiti entity and putting the proper metadata onto it). Another potential hardship is that the picked-up painting could have to be in a possibly new orientation when it is placed again, depending on the user's facedir(?) - a possible fix to this is just keeping the original painting in it's original orientation, but it is less snazzy :-)

This allows for a flurry of new features which would enhance this mod greatly, namely:

  1. It would allow for people to move their paintings - currently, there is no way to do this except by brute force (removing and re-painting).

  2. It would allow for (possibly) creating pieces of jigsaw puzzles and solving them!

  3. Paintings could then be sold to other players as well.

grorp commented 1 year ago

Sorry for the long response time. I have been thinking about this feature a bit, and I would like to implement it as follows:

Spray-painted nodes simply keep their graffiti when they are dug and placed again. In the inventory, spray-painted nodes still stack normally (like nodes that are not spray-painted). You could have a stack of 99 Stone, and some of the nodes in that stack could have graffiti on them and some not.

Because inventory items with metadata don't stack in Minetest, this is unfortunately not possible with Minetest. That's why I'm not sure how I'll continue here.

KaylebJay commented 1 year ago

I think doing it with a node is going to be really really hard, but possible.

One way to do this (and it is currently possible with the minetest API) might be to have a special item (called ggraffiti:picked_up_node or something), which can be created by right-clicking a node with some ggraffiti tool. This would "pick up" the node, storing it in the item metadata, allowing it to be placed (with any ggraffiti entities that were attached to it) somewhere else. Each item (unstackable) would represent a single node. The slight problem is that that node could have complicated metadata / inventories which also could need to be handled - a possible way to prevent this is only to allow items to be picked up that don't have metadata like that, but that's very complicated in itself.

grorp commented 4 months ago

Actually, picking up metadata shouldn't be a big problem - just doing minetest.swap_node to prevent callbacks + clearing and restoring metadata/inventory by yourself should be enough for most nodes like furnaces. Problems would arise with stuff like Travelnets or Hyperloop, where the metadata depends on the exact position of the node.

Still, I don't really like having a "graffiti pickup tool", it feels like breaking immersion. The approach I described in https://github.com/grorp/ggraffiti/issues/10#issuecomment-1711996475 would feel much better. If I had lots of free time and support from other core devs, I'd probably add per-item (not per-itemstack) metadata to Minetest to make it possible.

KaylebJay commented 4 months ago

That approach would be totally fine too - just not supported by current Minetest. I did think about minetest.swap_node, but would that also update the ggraffiti entities? Would it respect the facedir placement of the user?