forum Forumsplay_arrow Minecraft fiber_manual_record Redstone

1

teellraw whenever a players score goes up or down

1 emerald2 replies231 views
created 02/11/2016 12:46 pm by NateIsTurtle
last reply 02/11/2016 5:24 pm
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 avatar
NateIsTurtle
Level 15 : Journeyman Dragon
3

comment Login or register to post a reply.

2 replies

02/11/2016 5:24 pm
Level 28 : Expert Engineer
Jmal116
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!
02/11/2016 5:14 pm
Level 28 : Expert Engineer
Jmal116
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

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome