Solved Random Block in Loop Radius

  • 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.

FL3PHi

Member
Jul 7, 2017
3
0
0
22
Hey!

I've been trying to make a skript, but I ran into a problem that I can't solve.
(Been using skript for about 2 weeks)

How could I loop blocks in radius 5 of player and then select a random block from the looped blocks
and I used "on any movement:" from SkQuery, but I'd like to change that just to movement, not mouse movement aswell, but I have no idea how.

I tried (Didn't work):

code_language.skript:
on any movement:
    loop all blocks in radius 3 around player:
        set {block} to random loop-block
        if {variable.%player%} is set:
            make {variable.%player%} pathfind to {block} with speed 1.25

I would appreciate any sort of help <3
 
code_language.skript:
loop blocks in radius 5 around player:
    add loop-block to {_blocks::*}
set {_block} to random element of {_blocks::*}
 
code_language.skript:
loop blocks in radius 5 around player:
    add loop-block to {_blocks::*}
set {_block} to random element of {_blocks::*}
Wouldn't that mean, that it would constantly add blocks to the variable and then they would stay in there? I need them to be cleared every move to the new blocks around player
 
code_language.skript:
loop blocks in radius 5 around player:
    add loop-block to {_blocks::*}
set {_block} to random element of {_blocks::*}
That's not very efficient because skript loops aren't great. Not to mention it's over complex. A much better solution is
code_language.skript:
a random element out of blocks in radius 5 of player
 
Status
Not open for further replies.