#How Can Players Distribute Stats Without OP Commands?

1 messages · Page 1 of 1 (latest)

naive pivot
#

I'm working on a Minecraft datapack and could really use some advice.

I’m trying to create a system where players can distribute points into different stats (think things like stamina, strength, ect , kind of like an rpg). I want players to be able to open a menu or some kind of interface to do this easily.

The problem is I don’t want to use tellraw or chat based commands because they require players to have permissions to run commands. Same thing goes for using books or signs, they also run commands as the player, and I don’t want to give out permissions.

I’m basically looking for a way for players to allocate their stat points without any commands involved and without forcing them to hold a specific item or open a chest. I want something that can open a UI like experience in a clean, player friendly way that doesn’t rely on giving them extra permissions.

If anyone has any clever ideas or has tackled something like this before, I’d love to hear your suggestions. Thanks a bunch!

quartz oyster
#

/trigger

#

would even work exactly for this too

#

for changing the number on a scoreboard

naive pivot
#

yea but i didn't want the player to use commands in chat i wanted something more user friendly, i thought of spawning armor stands infront of the player that display a stat and the player can punch it to distribute the point but other players can also see them and it kinda kills the point

quartz oyster
#

dialogs

#

so its an actually menu

naive pivot
#

omg how have i never heard of dialogs

#

can this be run on the player whenever and it will just pop up

quartz oyster
#

i think the ways to open it are:
from esc screen next to the options and all
keybind
with commands

naive pivot
#

you can set up a custom keybind for it?

quartz oyster
#

no theres one keybind that you can bind dialogs to

#

if multiple datapacks use it it opens a list where you select what dialog to open

naive pivot
#

oh okay makes sense, ill look into it and reach back if i have any other questions thank you sm!

#

one question actually, wouldn't pressing the option run the command as the player, just like a book would do

#

oh uh it sends a warning to the player thats gonna run a command, thats a bit odd

quartz oyster
#

Shouldn't do it if you use /trigger

#

They added that for signs and all a while back

naive pivot
#

beside trigger and dialogs do you have any other ideas? @quartz oyster

quartz oyster
#

Not off the top of my head

naive pivot
#

dialogs im not sure if they can work cause i don't think they can show scores

#

even brainstorming ideas can work atp, ive been stuck for days idk how to approach this

quartz oyster
#

They can show scores

naive pivot
#

@quartz oyster sorry for the ping, the scores don't seem to be displaying even tho the player has them. i tried @s, * and @p on the dialog to show the score and nothing displays it.

{type:"minecraft:multi_action",title:{text:"Player Stats",type:"text",extra:[""]},body:{type:"minecraft:plain_message",contents:{text:"Level: ",type:"text",extra:[{score:{objective:"level",name:"@p"},type:"score",extra:[""],color:"#efff0a",bold:1}]}},can_close_with_escape:1,pause:0,after_action:"none",actions:[{label:{text:"Strength: ",type:"text",extra:[{score:{objective:"stats.strength",name:"@p"},type:"score",extra:[""],color:"#00bfff",bold:1}]},action:{type:"minecraft:run_command",command:"trigger trigger.stats.strength add 1"}}]}

The first screenshot is how it supposed to be displayed and on the second screenshot it's how it's displayed. what am i doing wrong?

quartz oyster
#

Is this misode?

naive pivot
#

yea

#

im using his dialog generator for 1.21.9

naive pivot
quartz oyster
#

Well I haven't really used dialogs so I can't necessarily help much

#

I recommend you wait an extra 30 min then press summon helpers

#

Or press it now but I recommend waiting first

naive pivot
#

okay ill wait a bit then press it

#

thank you anyway

crude hemlockBOT
#

-# (helpers summoned) <@&1166082198152159386> <@&1202694677766348840>

naive pivot
#

anyone?

short yarrow
#

No nbts (storage/entity etc.), no scores, no selectors, basically nothing that has any form of "context"

#

Dialogs as of yet are in my humble opinion really nice looking garbage... barely any use cases.

quartz oyster
#

oh? I saw that misode had a field for it

night pine
#

they can't resolve text components normally, but you can use macros to generate them dynamically
(misode only has the relevant fields because it just uses text components, the fields can still go there. they just dont resolve)

naive pivot
short yarrow
#

as LadyEternal stated, you can dynamically generate dialogs and even have those dialogs use a macro template if need be.

short yarrow
#

To avoid abuse my method would be to use the /trigger on a separate scoreboard that you use to "select" which skill to actually update.

in short:

trigger upgrade_skill set <number_corresponding_with_skill_X>

Each tick run as all players a function that does:

  • execute if score @s upgrade_skill matches 0 run return (no skill selected for upgrade)
  • list of execute if score @s upgrade_skill matches <skill_id_value> run scoreboard players add @s <skill_scoreboard_objective_name> 1
  • scoreboard players reset @s upgrade_skill

something like this...

The dialog can be created in various ways, you can build things with misode and then copy them in the inline mode if you want to display anything dynamic (current score, player names etc.). You still cannot resolve any context but you can use a macro function to fill the inline dialog.

if you need your inline dialog to the call a dynamic/run_command with a macro template you must "escape" the $ character using the unicode equivalent: \u0024

Alternatively use a multi_action, in your case each skill would simply have a hardcoded command running that triggers upgrade_skill to be set to the id of the skill.

#

Note that using a trigger to select a single id is safer because any player can call trigger with any value.

#

I can provide some in detail examples but the short story is to use trigger to set a scoreboard value.

naive pivot
#

wow that is smart ngl

naive pivot
short yarrow
# naive pivot thank you ill try something out!

no problem, if you have any questions on dialogs feel free to ask. I mostly play around with them for fun and giggles as I don't feel like they are ready to do most stuff that I would want to use them for. I have learned some tricks however.

naive pivot
#

yea i will fs! my real concern is macros, i just found out they exist lol, maybe im not so intermediate as i thought lol

#

they dont seem too hard but it's gonna be a bit of a challenge to integrate with dialogs

short yarrow
#

staying away from macros is a good idea, if you can do without them, please do.

naive pivot
#

honestly i most likely can by just creating a lot of dialogs

short yarrow
#

it depends on how deep you want to go, if you dont mind each skill point spent being a single click in the same dialog over and over, you only need 1 dialog

#

without macros

naive pivot
#

i wanted each point to be distributed individually, i think i have an approach in mind

#

ill be using your idea of using the score being reset on the trigger