add_score.mcfunction 2.1 KB

12345678910111213141516171819202122232425
  1. #as player
  2. execute store result score #bonus_add_score mem run data get storage item:bonus item.tag.bonus_add_score
  3. # 正常的加分
  4. execute if score #bonus_add_score mem matches 1..10 run scoreboard players operation @s total_score += #bonus_add_score mem
  5. execute if score #bonus_add_score mem matches 1..10 run scoreboard players operation @s total_score_disp += #bonus_add_score mem
  6. execute if score #bonus_add_score mem matches 1..10 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 获得了 ",{"score": {"name":"#bonus_add_score","objective": "mem"},"color":"aqua"},{"text": " 积分","color":"aqua"},", 当前共有 ",{"score": {"name": "@s","objective": "total_score"}}, " 积分"]
  7. # 没有加分
  8. execute if score #bonus_add_score mem matches 0 run tellraw @a ["",{"text": ">> ","color":"red","bold": true},{"selector": "@s","color":"red"}," 没能获得积分……"]
  9. # 清零
  10. execute if score #bonus_add_score mem matches ..-1 if score @s total_score matches 0 run tellraw @a [{"text":"","color":"red"},{"text": ">> ","color":"red","bold": true},{"selector": "@s","color":"white"}," 没能获得积分……"]
  11. execute if score #bonus_add_score mem matches ..-1 if score @s total_score matches 1.. run tellraw @a [{"text":"","color":"red"},{"text": ">> ","color":"red","bold": true},{"selector": "@s","color":"white"}," 的 ",{"score": {"name": "@s","objective": "total_score"}}," 积分惨遭清零……"]
  12. execute if score #bonus_add_score mem matches ..-1 run scoreboard players set @s total_score 0
  13. execute if score #bonus_add_score mem matches ..-1 run scoreboard players set @s total_score_disp 0
  14. # 刷新显示
  15. function item:refresh_level
  16. # 给予进度
  17. execute if entity @s[scores={total_score=10..}] run advancement grant @s only ltw:story/score1
  18. execute if entity @s[scores={total_score=18..}] run advancement grant @s only ltw:story/score2
  19. execute if entity @s[scores={total_score=26..}] run advancement grant @s only ltw:story/score3
  20. execute if entity @s[scores={total_score=34..}] run advancement grant @s only ltw:story/score4