PMMO:Perks information request
KatoNamus opened this issue ยท 4 comments
Describe what documentation needs updated or added:
Perks Wiki, specifically "pmmo:command"
Why is this documentation needed:
Please add one or more examples of how to implement functions, specifically with variables and some guidance on what kind of functions can be used, maybe an example of existing functions' list.
What medium is best for this documentation:
Preferably in the Wiki itself, please?
Additional context:
I.e. I'm trying to award the player with (Minecraft) XP points equal to the level of whatever skill has just leveled up. So if the player levels e.g. Agility up from 3 to 4 then award them with 4 points Minecraft XP (points, not levels).
I'm pretty sure it is explained in the wiki I'll link to the exact line in a second but your perks file should have something like this in it for runnings commands based off of a level up
[[Perks.For_Event.SKILL_UP.agility]]
perk = "pmmo:command"
command = "(insert XP command here"
Actually the page you linked has exactly the info you were looking for
pmmo:command
runs the specified command or function when triggered
"command" a string containing the command to be run
"function" the ID of the function to be run. mutually exclusive to command and always takes precedence
Functions are a vanilla feature for datapacks. There are no preexisting functions because they exists as virtual command blocks for users to create. You will have to create one for your use case. your function will look something like
#store your skill
pmmo store @s agility
#use a binary tree to iterate over the score and give XP.
#you can do this level by level, but this leverages some math to make your life easier
execute at @s[scores={agility=16..}] run experience add @s 16 points
execute at @s[scores={agility=16..}] run scoreboard players operation @s agiilty -= 16 agility
execute at @s[scores={agility=8..}] run experience add @s 8 points
execute at @s[scores={agility=8..}] run scoreboard players operation @s agiilty -= 8 agility
execute at @s[scores={agility=4..}] run experience add @s 4 points
execute at @s[scores={agility=4..}] run scoreboard players operation @s agiilty -= 4 agility
execute at @s[scores={agility=2..}] run experience add @s 2 points
execute at @s[scores={agility=2..}] run scoreboard players operation @s agiilty -= 2 agility
execute at @s[scores={agility=1..}] run experience add @s 1 points
execute at @s[scores={agility=1..}] run scoreboard players operation @s agiilty -= 1 agility
let's store this in our datapack at data/mypack/functions/agility_to_xp.mcfunction
. then in our command we do
[[Perks.For_Event.SKILL_UP]]
perk = "pmmo:command"
skill = "agility"
function = "mypack:agility_to_xp"