The Meaning of Life, the Universe, and Everything.
Join Date:
2/24/2015
Posts:
226
Minecraft:
Lightwavers
Member Details
How do you detect an item by its age? c= isn't working for this. I'm trying to create a system where when you die, you drop 10% of your coins as an item that transfers to anyone who gets close enough, and everything is working, except when a player dies again, the coin gets the value of the most recent player death. If I can detect the youngest coins, I'll just use that, but it isn't working. Commands for spawning the coin and reducing player coins below.
This will allow us to detect that it hasn't received any info yet.
Next change the fake player's Coins score to -10 instead of 10, you'll see why next.
Now change the entity selector for the first two operation commands to this:
@e[type=Item,tag=Coins,score_Coins=0]
Finally change the first operation from = to -=.
With it only acting on coins with a max of 0, the first command will subtract the number of coins setting it to a negative value of the same amount. Since it is less than 1, the next command will also act on this same item, dividing it by -10 which will then make it positive and greater than 0. Now that item will never be selected again.
Also, you should be using /execute on all your operation commands, then add c=1 to every entity selector so that incase more than one player dies at the same time, creating two Coins items, each one will contain the correct value. Right now if multiple people died at the same time it would only pick the last processed player/entity and use their value for every item.
How do you detect an item by its age? c= isn't working for this. I'm trying to create a system where when you die, you drop 10% of your coins as an item that transfers to anyone who gets close enough, and everything is working, except when a player dies again, the coin gets the value of the most recent player death. If I can detect the youngest coins, I'll just use that, but it isn't working. Commands for spawning the coin and reducing player coins below.
⠀
s̮̹̃rͭ͆̄͊̓̍ͪ͝e̮̹̜͈ͫ̓̀̋̂v̥̭̻̖̗͕̓ͫ̎ͦa̵͇ͥ͆ͣ͐w̞͎̩̻̮̏̆̈́̅͂t͕̝̼͒̂͗͂h̋̿
Instead of acting on the youngest item act on one without any Coins yet:
First add this command after you summon the item:
/scoreboard players add @e[type=Item,tag=Coins] Coins 0
This will allow us to detect that it hasn't received any info yet.
Next change the fake player's Coins score to -10 instead of 10, you'll see why next.
Now change the entity selector for the first two operation commands to this:
@e[type=Item,tag=Coins,score_Coins=0]
Finally change the first operation from = to -=.
With it only acting on coins with a max of 0, the first command will subtract the number of coins setting it to a negative value of the same amount. Since it is less than 1, the next command will also act on this same item, dividing it by -10 which will then make it positive and greater than 0. Now that item will never be selected again.
Also, you should be using /execute on all your operation commands, then add c=1 to every entity selector so that incase more than one player dies at the same time, creating two Coins items, each one will contain the correct value. Right now if multiple people died at the same time it would only pick the last processed player/entity and use their value for every item.
It works, thank you!
⠀
s̮̹̃rͭ͆̄͊̓̍ͪ͝e̮̹̜͈ͫ̓̀̋̂v̥̭̻̖̗͕̓ͫ̎ͦa̵͇ͥ͆ͣ͐w̞͎̩̻̮̏̆̈́̅͂t͕̝̼͒̂͗͂h̋̿