Unable to detect correct NBT, 1.15.2
I made a sonic map in 1.12 commands, and I'm now trying to transfer it to 1.13 commands instead.
I'm trying to detect how many blocks were affected by the command that was run (previously "/stats") by using the new /execute store result. As you can see, it didn't work cause the "test" scoreboard shows 84 instead of 18.
What I'm thinking is that it's adding the time to the scoreboard as well. I've tried looking up solutions on the wiki, youtube, etc.
But can't wrap my head around how it works!
I would appreciate it if someone talented at commands could help me.
there is a system that collects gold with execute as @a [x=666704,dx=138,y=44,dy=23,z=981,dz=12] at @s run fill ~1 ~1 ~1 ~-1 ~-1 ~-1 air replace gold_block
problem is, it can remove 2 gold blocks though getting only 1 gold ingot. That's why I want to get the input from the command and store the result on a scoreboard. Referring to what MegaCrafter10 said, I tested his command(execute store result score <player> <objective> run fill <x> <y> <z> <x2> <y2> <z2> <block>
) and I found another problem, It sets back to 0 every time there is no output(it's in a repeating command block). Would it be able to store how many blocks of gold it has filled away without it being reset? Instead, rising higher by 1 for each gold?
LastOutput represents the last line of output generated by the command block. Since that line is a string, the /execute store command returns the length of that line (which is 84 in your case).
Instead of reading the number from the output, you can access that number directly:
execute store result score <player> <objective> run fill <x> <y> <z> <x2> <y2> <z2> <block>
this will store the amount of blocks affected by the /fill command into the specified objective.
Edit:
if you want to keep track of how many blocks we're affected in total, here is how you can do that.
You need two scoreboard objectives of type dummy. I will call mine "count" and "total". Once you have two objectives, place down a command block (it can be an impulse or repeating command block) and paste this command in:
execute store result score @p count run fill ...
attach a chain command block to the one you just placed down and set it to always active. Paste this in:
execute as @p run scoreboard players operation @s total += @s count
this will store the number of affected blocks into "count" and add its value to "total".