1

Teellraw whenever a players score goes up or down

NateIsTurtle's Avatar NateIsTurtle2/11/16 12:46 pm
1 emeralds 281 2
2/11/2016 5:24 pm
Jmal116's Avatar Jmal116
I have a scoreboard objective, EMERALDS, that automatically changes based on the number of emeralds in a player's inventory.

When a person gains/loses a point I want to display a `/tellraw` to the player saying "Gained/Lost An Emerald". How can I do this?
Posted by NateIsTurtle's Avatar
NateIsTurtle
Level 1 : New Dragon
4

Create an account or sign in to comment.

2

1
02/11/2016 5:24 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
Jmal116If you have an actual circuit set up to manually add or remove points with commands I'd suggest just sticking some tellraw's on the ends of that stuff.

Since you probably don't (or else you wouldn't be asking the question), we'll have to be a bit more creative. Let's start by making another scoreboard objective, oldScore:scoreboard objectives add oldScore dummyWith this we're going to track the score for how many emeralds the player has, and then compare their actual score to the last one we had. To finish setting up, set your 'oldScore' value equal to your 'EMERALDS' score: execute @a ~ ~ ~ scoreboard players operation @p oldScore = @p EMERALDS
To actually detect a change in the emeralds score, we're going to be repeatedly subtracting one score from the other. On a clock put the following commands (in order!):execute @a ~ ~ ~ scoreboard players operation @p oldScore -= @p EMERALDSexecute @a[score_oldScore_min=1] ~ ~ ~ tellraw @p {"text":"You gained some emeralds! :D","color":"green"}execute @a[score_oldScore=-1] ~ ~ ~ tellraw @p {"text":"You lost some emeralds! D:","color":"red"}execute @a ~ ~ ~ scoreboard players operation @p oldScore = @p EMERALDS
Now assuming I've thought this all out correctly in my head you should be able to detect pretty easily when their score changes. Obviously you can change the tellraws to whatever you want, or even use something other than tellraws if you want. You could run pretty much whatever you wanted to off this, just add some more of the executes with the score to your clock. Good luck!
1
02/11/2016 5:14 pm
Level 33 : Artisan Engineer
Jmal116
Jmal116's Avatar
If you have an actual circuit set up to manually add or remove points with commands, I'd suggest just sticking some tellraw's on the ends of that stuff.

Since you probably don't (or else you wouldn't be asking the question), we'll have to be a bit more creative. Let's start by making another scoreboard objective, oldScore:scoreboard objectives add oldScore dummyWith this we're going to track the score for how many emeralds the player has, and then compare their actual score to the last one we had. To finish setting up, set your 'oldScore' value equal to your 'EMERALDS' score: execute @a ~ ~ ~ scoreboard players operation @p oldScore = @p EMERALDS
To actually detect a change in the emeralds score, we're going to be repeatedly subtracting one score from the other. On a clock put the following commands (in order!):execute @a ~ ~ ~ scoreboard players operation @p oldScore -= @p EMERALDSexecute @a[score_oldScore_min=1] ~ ~ ~ tellraw @p {"text":"You gained some emeralds! :D","color":"green"}execute @a[score_oldScore=-1] ~ ~ ~ tellraw @p {"text":"You lost some emeralds! D:","color":"red"}execute @a ~ ~ ~ scoreboard players operation @p oldScore = @p EMERALDS
Now assuming I've thought this all out correctly in my head you should be able to detect pretty easily when their score changes. Obviously you can change the tellraws to whatever you want, or even use something other than tellraws if you want. You could run pretty much whatever you wanted to off this, just add some more of the executes with the score to your clock. Good luck!
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome