#(josephb_4) Saving/Setting inventory

45 messages · Page 1 of 1 (latest)

meager ridge
#

Hello! I have a question about saving a player's inventory. I'm creating a character system where each character would have their own inventory and on switch the inventory would be set to that character's. Everything is currently being saved into a data yml file.

I tried using inventory.list_contents but that only returned the item IDs (wooden_axe). I want to be able to save the items fully (custom names, lore, enchantments, etc).

lilac spokeBOT
#

(josephb_4) Saving/Setting inventory

lilac spokeBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

meager ridge
#

Is there a tag that gets me everything basically?

#

As well as armor and offhand items

meager ridge
low herald
#

you should note the inventory

#

now for armor i dont know if noting the inventory would suffice

meager ridge
low herald
#

basically you save the whole inventory as-is

#

not the list of contents, the InventoryTag itself

meager ridge
low herald
#

!t equipment

silver oceanBOT
# low herald !t equipment
Cannot Specify Searched Tag

Multiple possible tags: <InventoryTag.equipment>, <EntityTag.equipment>, <InventoryTag.equipment_map>, <EntityTag.equipment_map>, <EntityTag.equipment_drop_chance>.

low herald
#

!t inventory.equipment

silver oceanBOT
low herald
#

!t entity.equipment

silver oceanBOT
low herald
#

!t entity.equipment_map

silver oceanBOT
low herald
#

this should be better than the inventory counterpart tbh

#

annnddddddd

#

!t entity.item_in_hand

silver oceanBOT
low herald
#

!t entity.item_in_offhand

silver oceanBOT
meager ridge
#

This is perfect! Thank you so much!
I'm gonna try to figure out a way to save the equipment map in the yaml file as well

#

or ill probably just loop over the map and save each equipment as its own entry

#

nvm im just gonna do map.get and save each one as its own entry then on switch ill do equip

low herald
#

no need to do a yaml file honestly unless you have an external plugin that needs to read that info

#

both notables and flags are already in their own yaml file

meager ridge
#

I need to store a lot more data than just the inventory, and I'd rather have it organized as well as some players can have 5+ characters

There are also places where i need to return a list of characters for a player and i figured having it saved as a list would make my life easier as i could just loop over them

#

Instead of saving data as flags so something like:
Char.1.name
Char.1.inventory

Char.2.name
Char.2.inventory

I'm going to save these in the yml and then set the name for example on the player as a flag on switch

So on switch to char1 ill get this char's data, then set the flag char_name on the player to use it in other places

meager ridge
#

Does that make sense? Are there better ways?

hexed citrus
#

You can mix between flags and notes

#

the pro for inventory notes is that they do the saving for you

#

you could save the inventory name in char.2.inventory and then simply open that

hexed citrus
#

ex flag <player> char.2.equipment:<player.equipment_map>

#

ex narrate <player.flag[char.2.equipment.boots]>

meager ridge
meager ridge
# hexed citrus You can mix between flags and notes

Okay so the thing is im planning to do a gui where a player can see their characters

So i thought a loop would work better here?

I'll use this list in a lot of places too. I also plan to display characters per town (another custom system later) so im saving the town reference in the character too. Then ill do list.filter to get that