Solved loop entities in radius around command sender not working in command block

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

mtrD359360

Member
May 2, 2017
17
1
0
22
Skript Version (do not put latest): Skript 2.4.1
Skript Author: Bensku
Minecraft Version: 1.12.2

Code:
Code:
command /test:
    trigger:
        broadcast "1"
        loop all entities in radius 5 around command sender:
            broadcast "%loop-entity%"
            if "%loop-entity%" is "minecart":
                set {_nbt} to nbt of loop-entity
                broadcast "Minecart's NBT is %{_nbt}%."
So I'm testing to detect the name of a minecart when a command block is activated by a moving minecart using detector rail.

After I tried to use this code, I found that the command executed by cmd block cannot enter the loop expression, but it can enter if I execute this command as a player
How could I modify the code to allow command blocks also enter the loop?

Addons using (including versions):
Sk-NBeeT 2.11.0

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? There are no other methods I can think of right now.
 
may be that work ¯\_(ツ)_/¯

Code:
command /test:
    trigger:
        broadcast "1"
        loop all entities in radius 5 around command sender:
            broadcast "%loop-entity%"
            if loop-entity is minecart:
                set {_nbt} to nbt of loop-entity
                broadcast "Minecart's NBT is %{_nbt}%."
 
Skript Version (do not put latest): Skript 2.4.1
Skript Author: Bensku
Minecraft Version: 1.12.2

Code:
Code:
command /test:
    trigger:
        broadcast "1"
        loop all entities in radius 5 around command sender:
            broadcast "%loop-entity%"
            if "%loop-entity%" is "minecart":
                set {_nbt} to nbt of loop-entity
                broadcast "Minecart's NBT is %{_nbt}%."
So I'm testing to detect the name of a minecart when a command block is activated by a moving minecart using detector rail.

After I tried to use this code, I found that the command executed by cmd block cannot enter the loop expression, but it can enter if I execute this command as a player
How could I modify the code to allow command blocks also enter the loop?

Addons using (including versions):
Sk-NBeeT 2.11.0

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it? There are no other methods I can think of right now.


The feature to retrieve a location of a command block sender has been added since 2.5-alpha1.
Added location for block command senders (closes #2160)

quote from docs:
If the command sender is a command block, its location can be retrieved by using %block's location%

If u can't update and are using skript-mirror 2.0.0 this should work (not tested):

Code:
command sender.getBlock().getLocation()
 
Status
Not open for further replies.