#(hmoe) Persistent Data in Denizen

1 messages · Page 1 of 1 (latest)

primal tusk
#

I'm wondering how I could make an item script with persistent data, meaning that the item will be saved when the player unloads and updated when the player reloads. This way, if the item script is changed, any instance of that item in a player's inventory will be changed. How can this be done?

sage egretBOT
#

(hmoe) Persistent Data in Denizen

sage egretBOT
#

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.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>

blissful saffron
primal tusk
#

sure. let's say I make a sword with the name "My Sword":

    type: item
    material: diamond_sword
    display name: My Sword```

and then i start giving it out to a bunch of players. There are hundreds. Thousands. Hundreds of thousands of people with this sword. `My Sword` becomes so cool and popular that I decide to change its name to `The Sword`, because of how much fame it has. So, I go back into the script file, and change the name. The script looks like
```server_sword:
    type: item
    material: diamond_sword
    display name: The Sword```
But now, everyone who previously received the sword sees the name as `My Sword`, and any new instances of the sword say `The Sword`! Oh no! No one is sure what to call it now. Is it really a sword at all???

So to avoid all this, after I change the display name to `The Sword`, anyone who has the server_sword should see the name change to `The Sword`
blissful saffron
# primal tusk sure. let's say I make a sword with the name "My Sword": ```server_sword: ty...

Ah I see, asked because the solution would likely be different for non-display data - for your use-case I'd recommend 2 things:

  1. Probably the best option - use a resource pack with a translatable string, that way your actual display name would be <&translate[the.sword.name]>, and in your resource pack you could map that to whatever you'd like.
    And since resource packs can be automatically updated for a player every time they join the server, all you'd need to do is change the.sword.name's translation in your resource pack whenever you'd like for it to automatically update (can even do cool things like having translations for multiple languages, which would mean the player would see the item's name in the language they have set on their client).
  2. Potentially harder/more annoying option - just update them manually via a script, e.g. whenever a player joins, scan their inventory for the relevant items that need updating and modify them.
    Can check more frequently ofc, technically can go as far as checking every single inventory change
noble granite
#

I'll include that you seem to be under the pretense of loading data from the script again, but that uhh

#

wouldn't really work. Items work with a lot of metadata that can't afford to just be reset constantly

#

i.e in the sword example, durability wouldn't work because you're reloading a sword with maxed durability

ocean torrent
proper pythonBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@primal tusk

primal tusk
#

/resolved

blissful saffron
proper pythonBOT
#
Thread Closing Reminder

Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.

If not yet resolved, please reply below to tell us what you still need.

(Note that if there is no reply for a few days, this thread will eventually close itself.)

#

@primal tusk