Improvement: Behavior of item name field in anvil menu #4486

Open
opened 2024-07-02 21:26:27 +02:00 by Laudrin · 3 comments

Feature

  • If you open the anvil menu (right click on anvil), any old name should be deleted from the naming field. At the moment the name you entered last will be shown.
  • If put a named item in the item slot, the name should appear in the name slot, giving you the option to delete it, change it or leave it as it is.

Why

At the moment, the old name will be shown, possibly leading to naming problems (unintentionally changed or deleted names). Also leaving the name of an item or changing it will be easier.

### Feature - If you open the anvil menu (right click on anvil), any old name should be deleted from the naming field. At the moment the name you entered last will be shown. - If put a named item in the item slot, the name should appear in the name slot, giving you the option to delete it, change it or leave it as it is. ### Why At the moment, the old name will be shown, possibly leading to naming problems (unintentionally changed or deleted names). Also leaving the name of an item or changing it will be easier.
Contributor

Hmmm, this is actually an annoying issue. The reason is that the anvil is like an inventory - the item you take out of the output slot exists all the time, but will delete the input item when you take it.
This means that the output item (and its name) is stored in the anvil metadata.
(The formspec which appears on rightclicking the anvil is also stored in the anvil's metadata, and even if it weren't this would still be an issue as the inventory item must be)

This basically means that the formspec (and the rename) must be the same for all players who use the anvil, and there appears to be no good solution for resetting the name - imagine the case where a different player had the formspec open the whole time you were away.

Does anyone know how to fix this?

Hmmm, this is actually an annoying issue. The reason is that the anvil is like an inventory - the item you take out of the output slot exists all the time, but will delete the input item when you take it. This means that the output item (and its name) is stored in the anvil metadata. (The formspec which appears on rightclicking the anvil is also stored in the anvil's metadata, and even if it weren't this would still be an issue as the inventory item must be) This basically means that the formspec (and the rename) must be the same for all players who use the anvil, and there appears to be no good solution for resetting the name - imagine the case where a different player had the formspec open the whole time you were away. Does anyone know how to fix this?
Author

@WillConker, if I understand you correctly, the problem is that different players can use the anvil simultaneously and the name is stored in the anvil's metadata?

But then it should be possible (and please correct me if I'm wrong) that the naming/renaming is also on a per-player-basis:

  1. Player opens the anvil menu.
  2. The anvil "provides" a menu / inventory for this player.
  3. When the player places an item into the slot, the name will be shown in the name field. It does not have to be saved after the player closes the UI, as the name is only important for this "session".
  4. Player repairs / enchants / (re-)names item and takes the output item out of the output slot or the input item out of the input slot. If there is a (new) name, it will be saved with the item, no need to save it in the anvil variable / formspec (I read the description but am not sure if I understood everything)
  5. UI closes and anvil "forgets" the name.

If the player leaves the UI without taking the item out of the input or output slot, either the content will be saved (the name can be saved but does not have to be, as when you open the UI it can take the name from the item in the input slot) or the anvil will drop the input item like with other tables/workplaces/machines.

So the only thing that changes IMHO is that the name won't be saved in the anvil metadata for this player, the UI will always get it from the item in the input slot either if there's one present if you open the UI (not taken out before closing the UI last time) or if the player puts one in there when the UI is open.

@WillConker, if I understand you correctly, the problem is that different players can use the anvil simultaneously **and** the name is stored in the anvil's metadata? But then it should be possible (and please correct me if I'm wrong) that the naming/renaming is also on a per-player-basis: 1. Player opens the anvil menu. 2. The anvil "provides" a menu / inventory for this player. 3. When the player places an item into the slot, the name will be shown in the name field. It does not have to be saved after the player closes the UI, as the name is only important for this "session". 4. Player repairs / enchants / (re-)names item and takes the output item out of the output slot or the input item out of the input slot. If there is a (new) name, it will be saved with the item, no need to save it in the anvil variable / formspec (I read the [description](https://api.minetest.net/formspec/) but am not sure if I understood everything) 5. UI closes and anvil "forgets" the name. If the player leaves the UI without taking the item out of the input or output slot, either the content will be saved (the name can be saved but does not have to be, as when you open the UI it can take the name from the item in the input slot) or the anvil will drop the input item like with other tables/workplaces/machines. So the only thing that changes IMHO is that the name won't be saved in the anvil metadata for this player, the UI will always get it from the item in the input slot either if there's one present if you open the UI (not taken out before closing the UI last time) or if the player puts one in there when the UI is open.
Contributor

Yes, this might be possible. We would have to make it more like the crafting table, we (i think) the crafting table slots are stored as an extension of the player's inventory.

Yes, this might be possible. We would have to make it more like the crafting table, we (i think) the crafting table slots are stored as an extension of the player's inventory.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#4486
No description provided.