#Score compared to score help

1 messages · Page 1 of 1 (latest)

digital mulchBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1733683729:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

opaque ocean
#

Store the score you're checking against to two fake players, increase one of them by 5 and reduce the other by 5, then do two separate if score checks against those fake players in one command, to see if the target player's score is less than the first, and also greater than the second

gray veldt
#

I dont think that will work for my situation as I need it to work on a per player basis

vale sapphire
#

this method works on a per player basis too.

gray veldt
#

how so?

#

Here is some more info if it helps. I'm trying to have it so a score set per player via nbt data is within a +5 and -5 range of another score set per player via another nbt data value

#

what im trying to do is have it so when a player gets within 5 blocks of their lastdeathlocation it will remove a recovery compass from their inventory

gray veldt
vale sapphire
#

this makes it even easier and in this case I think using predicates makes it even more easier.

gray veldt
#

what is a predicate and how do I use it?

#

I havent looked into them at all yet

#

Here is how I have it working for the coord saving atm

#
execute as @a store result score @s liveY run data get entity @s Pos[1]
execute as @a store result score @s liveZ run data get entity @s Pos[2]

execute as @a[nbt={Dimension:"minecraft:overworld"}] run scoreboard players set @s dimlive 0
execute as @a[nbt={Dimension:"minecraft:the_nether"}] run scoreboard players set @s dimlive 1
execute as @a[nbt={Dimension:"minecraft:the_end"}] run scoreboard players set @s dimlive 2


execute as @a[nbt={DeathTime:1s}] store result score @s deathX run data get entity @s Pos[0]
execute as @a[nbt={DeathTime:1s}] store result score @s deathY run data get entity @s Pos[1]
execute as @a[nbt={DeathTime:1s}] store result score @s deathZ run data get entity @s Pos[2]

execute as @a[nbt={DeathTime:1s,Dimension:"minecraft:overworld"}] run scoreboard players set @s dim 0
execute as @a[nbt={DeathTime:1s,Dimension:"minecraft:the_nether"}] run scoreboard players set @s dim 1
execute as @a[nbt={DeathTime:1s,Dimension:"minecraft:the_end"}] run scoreboard players set @s dim 2```
#

The top is storing the players active location to scoreboards while the bottom is storing their location on death to scoreboards

gray veldt
opaque ocean
#

A predicate is a JSON file that you can check in commands to return either true or false. They have a variety of conditions. You can make one here:
https://misode.github.io/predicate/

I'm not certain the exact predicate type @vale sapphire has in mind, but there are a number of ways to detect a player's position as well as a score

gray veldt
#

Alright, thankyou.

vale sapphire
#

My bad. I had in mind that you could use number provider for the position fields in the location_check predicate but you can only use constant values.

gray veldt
#

ah ok

vale sapphire
#

You could still use a value check predicate to check both scores (the -5 and +5) against the position score of the player in one go. It has the benefit of looking a bit cleaner imo

gray veldt
vale sapphire
#

This is how the predicate for the X coordinate could look like:

{
  "condition": "minecraft:value_check",
  "value": {
    "type": "minecraft:score",
    "target": "this",
    "score": "liveX"
  },
  "range": {
    "min": {
      "type": "minecraft:score",
      "target": "this",
      "score": "deathX.plus.five"
    },
    "max": {
      "type": "minecraft:score",
      "target": "this",
      "score": "deathX.minus.five"
    }
  }
}
gray veldt
#

ok, so I essentially just do a predicate for each coord

vale sapphire
#

This part specifies the value that should be checked.

the type tells it that we want to check a score value,
the target is the entity that we want the score from,
and score is the name of the objective

gray veldt
#

and the dimension one is simply just a compare scores

vale sapphire
#

yes

#

if you want you can even put all 4 score checks in the same file

#

it might decrease readability though

gray veldt
#

would that be doing a list instead of an object?

vale sapphire
#

a list or everything in an all_of condition

gray veldt
#

ok

#

hmm

#

so i am testing it with a repeat command block and its just constantly going off even if im out of range

#

@vale sapphire any ideas?

#

I fixed it from constantly going off. Not sure why but the world just needed to be reloaded

#

but now it just doesnt trigger when im within 5 blocks of the x coord

gray veldt
#

@opaque ocean Do you have any ideas?

opaque ocean
#

Show your work

gray veldt
#

well I have the predicate file like he stated earlier in the predicates folder of the datapack and I tried to run the following command in a command block repeating.
execute as @a if predicate coords:coord_x run say hi

#

I feel like its the deathX.plus.5 & deathX.minus.five that are causing no return

opaque ocean
#

Possibly, have you tried checking those scores manually in-game?

gray veldt
#

I say that might be the issue as I couldnt find anything on score based math

opaque ocean
#

/scoreboard players get <fake player name> <score>

gray veldt
#

or do I need dedicated scoreboards for those values?

opaque ocean
#

You do not

gray veldt
#

I guess a way I could do it for sure but it would be ridiculous would be to have deathX, deathX+ and deathX- scoreboards that each save the corresponding values then have it where I have a sphere of detection locations. But thats super messy

gray veldt
opaque ocean
#

Yes

gray veldt
#

ok thats probabaly why then

#

so how would I go about setting that up as im not familiar with using fake players

opaque ocean
#

You don't need to set anything up, if you try to set a score of or to a name that doesn't exist, it'll just create that fake player

gray veldt
#

ah ok

#

ngl im kind of lost on what I need to do now

opaque ocean
#

Honestly same, you're kinda confusing me

gray veldt
#

Sorry

#

Probabaly need to start from the beginning ngl

#

Should I yeet this post and just make a new one for the entire project instead?

opaque ocean
#

No, but you may need to provide a refresh here if what the problem is and what you're working with

gray veldt
#

Im trying to find a way to use the players location of death to remove a recovery compass out of the players inventory when they walk within a 5 block radius of their death

gray veldt
#

What is instead of doing coords I summon an armorstand at the players death location with the dead player's UUID then compared the two and if they match remove the recovery compass when within 5 blocks of while also killing the armor stand?

digital mulchBOT
#
Question Closed

Your question, #1315382089851605002 (Score compared to score help), was resolved!

Original Message

#1315382089851605002 message

Duration open

6h27m

#

Re-opened the channel. Make sure to close it again once you're done.