#Adding an array to the player's persistentData

9 messages · Page 1 of 1 (latest)

dawn dirge
#

When adding more than a string, in this case an array, it has issues granting the player the data

//ABILITIES
    event.register(
        Commands.literal("pa_rejuvenating_strike")
        .requires(src => src.hasPermission(2))
        .executes((ctx) => {
            var player = ctx.source.getEntity()
            player.persistentData.puff_abilities[0].abilty = 'rejuvenating_strike';
            player.persistentData.puff_abilities[0].on_cooldown = 0;
            return;
        })
    )
    event.register(
        Commands.literal("pa_arrow_volley")
        .requires(src => src.hasPermission(2))
        .executes((ctx) => {
            var player = ctx.source.getEntity()
            player.persistentData.puff_abilities[0].abilty = 'volley_of_arrows';
            player.persistentData.puff_abilities[0].on_cooldown = 0;
            return;
        })
    )
willow lakeBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

dawn dirge
#

Also, the reason I cannot simply do:
player.persistentData.puff_abilities = [{ability: "rejuvenating_strike", on_cooldown: 0}];
and
player.persistentData.puff_abilities = [{ability: "volley_of_arrows", on_cooldown: 0}];
is because each would overwrite itself

woeful spire
#

i assume these commands giving the executor only one ability tracker at a time is intentional?

#

because currently that's how it's working, setting and indexing 0

#

if you want it to grant multiple, you should use .push() on the array

#

issues granting the player the data is a ridiculously vague statement though

#

your commands should also be set to return 1 if they're succeeding, or 0 if they fail, the command builder generally wants that

dawn dirge
#

I figured out the empty object requirement