Solved Trying to find the location of a command sender that is a 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.

02skaplan

Member
Nov 2, 2020
1
0
1
21
Script Version (do not put latest): 2.5.1
Script Author: SkriptLang
Minecraft Version: 1.12.2
Full Code:

Code:
command /test:
    trigger:
        loop all entities in radius 5 around block's location:
            loop-entity is a player:
                message "%block's location%" to loop-entity



Errors on Reload:
There's no block in a command event (line 3).

Console Errors: (if applicable)
N/A

Other Useful Info:
I'm new to Skript.
Executing /test in command block. The documentation says that
"If the command sender is a command block, its location can be retrieved by using %block's location%."

Addons using (including versions):
N/A

Troubleshooting:
Changing syntax from "command sender" to "command executor", adding 5th line to check block's location, which comes back <none>.

Changing code to:
Code:
command /test:
    trigger:
        loop all entities:
            loop-entity is a player:
                message "%command executor's location%" to loop-entity
Yields "<none>" being sent to the player. I'm looking for the command block's location.

Have you tried searching the docs? Yes, see Other Useful Info.
Have you tried searching the Forums? Yes, I found this old post which seemed to have the same issue, but a fix was never mentioned.
What other methods have you tried to fix it?
See Troubleshooting

Thank you in advance to anyone who tries to help!
[doublepost=1604374831,1604359745][/doublepost]Thanks to the help of some kind samaritans on the Discord, I have found a working solution. The correct code for this situation is:
Code:
command sender.getBlock().getLocation()
Thank you to Killerz1243, DelayedGaming, and TheRealUnderscore for their help on this one. The full code in working condition is:
Code:
command /test:
    trigger:
        set {_location} to command sender.getBlock().getLocation()
        loop all entities in radius 5 of {_location}:
            loop-entity is a player:
                message "%command sender.getBlock().getLocation()%" to loop-entity

I also had to install Skript-Reflect in order for this to work.
 
Last edited:
Status
Not open for further replies.