#(sumocat19) How to define a variable from an operation of two other variables

46 messages · Page 1 of 1 (latest)

sullen trellis
#
update_mining_bossBar:
    type: task
    script:
    #- bossbar update " mining:<player> " progress:<element[player.flag[miningxp]].div[player.flag[level1]]>
    - narrate <player.flag[miningxp]>
    - define xp <player.flag[miningxp]>
    - define nextLevel <player.flag[level1]>
    - define levelProgress <[xp]>:/:<[nextLevel]>
    - narrate <[levelProgress]>
    - bossbar update " mining:<player> " color:blue progress:<[levelProgress]>

The problem in this code is that - define levelProgress <[xp]>:/:<[nextLevel]> doesn't set levelProgress to xp / nextLevel.

tough ironBOT
#

(sumocat19) How to define a variable from an operation of two other variables

tough ironBOT
#

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.

lilac mason
#

!debug

feral gustBOT
# lilac mason !debug
Info: debug

If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!

lilac mason
#

Could you debug this please?

sullen trellis
lilac mason
#

Please don't post the snippet from your console

#

Record it properly

lilac mason
sullen trellis
lilac mason
#

Thank you, that's more readable

#

You don't have a flag called miningxp.

#

That's why it can not work

sullen trellis
#

I have a player flag on myself called miningxp that is set to 10. - narrate <player.flag[miningxp]> in the code I posted works correctly and says "10" in the chat.

#

I also have a player flag named level1 that is set to 50 on myself. - narrate <[levelProgress]> shows " 10:/:50 " in chat.

#

It seems to me like the problem is not the flags but instead that - define levelProgress <[xp]>:/:<[nextLevel]> is not the correct way to define a variable from two other variables being divided.

lilac mason
#

The debug doesn't indicate this

#

It's saying that you don't have this flag.

#

It's also showing that you don't have the flag level1.

#

Could you provide the full script that also how you set these flags?

#

!paste

feral gustBOT
sullen trellis
#

I run flag_test in game before I run update_mining_bossbar.

lilac mason
#

Could you run another debug where you run

  1. /ex run flag_test
  2. /ex run update_mining_bossBar

please?

sullen trellis
lilac mason
#

Now the flags did work.

#

Though there is an issue with the bossbar command on line 93.

#

- define levelProgress <[xp]>:/:<[nextLevel]>
Do you want to divide?

sullen trellis
#

yes I want xp(10) to be divided by nextlevel(50) so when I update the boss bar I can use levelProgress(0.2) as the progress amount (range from 0 - 1).

lilac mason
#

If you want to use a data actions you have to add this on the definition you want to divide on.

#
- define xp:/:<[nextLevel]>

This will override the xp definition.

#

You can also use tags if you like to create a new one:

#
- define levelProgress <[xp].div[<[nextLevel]>]>
#

You can read more about definitions here:

#

!guide short term memory

lilac mason
#

!t element.div

feral gustBOT
sullen trellis
#

This works. Thanks! I tried to use tags before but I wrote wrong it like - define levelProgress <[xp]>.div[<[nextLevel]>]> The extra <> on xp was causing an error so I then tried doing a data action where I wrote it wrong again. Thanks again for the help.

tight pewterBOT
#
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.)

#

@sullen trellis