Solved Loop block help

  • 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 community!

    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.

TheBlazeTuber

New Member
Jul 6, 2018
8
0
0
Skript Version:Skript 2.2 bensku-dev36
Skript Author:TheBlazeTuber
Minecraft Version:1.12.2

---
Full Code:
https://hastebin.com/ogoyuqejez.vbs

Errors on Reload:

None

Console Errors: (if applicable)

None

Other Useful Info:
I want to "shoot" ice from the player and after 10 seconds the ice disappears.


Addons using (including versions):
skDragon-0.14.0
Skellett 1.9.6b
sklib 1.1.0
SkQuery 3.6.0-Lime
SkRayFall 1.9.12
SkStuff 1.6.4.1


Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it?
I have tried to make the skript wait 10 seconds before changing the ice into air but then the ice takes forever to be created
 
Skript Version:Skript 2.2 bensku-dev36
Skript Author:TheBlazeTuber
Minecraft Version:1.12.2

---
Full Code:
https://hastebin.com/ogoyuqejez.vbs

Errors on Reload:

None

Console Errors: (if applicable)

None

Other Useful Info:
I want to "shoot" ice from the player and after 10 seconds the ice disappears.


Addons using (including versions):
skDragon-0.14.0
Skellett 1.9.6b
sklib 1.1.0
SkQuery 3.6.0-Lime
SkRayFall 1.9.12
SkStuff 1.6.4.1


Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
What other methods have you tried to fix it?
I have tried to make the skript wait 10 seconds before changing the ice into air but then the ice takes forever to be created
What do you mean by "shooting ice"? Shoot a snowball? Shoot a falling_sand ice block?
 
I mean as in the player shoots an particle and ice spawns in that direction
Ah I see. For this you would need to use a "projectile hit" event and detect the block the projectile hit. The thing is this task is really buggy using only Skript, so I would recommend using an addon called skript-mirror.

Using the addon, the code would look something like this (untested):

code_language.skript:
on projectile hit:
    projectile is a snowball
    set {_block} to event.getHitBlock()
    set {_location} to location of event.getHitBlock()
    set block at {_location} to ice
    wait 3 seconds
    set block at {_location} to {_block}

Using only Skript, you do something like this (also untested):

code_language.skript:
on projectile hit:
    projectile is a snowball
    set {_block} to block at location 0.1 in front of the projectile
    set {_location} to block at location 0.1 in front of the projectile
    set block at {_location} to ice
    wait 3 seconds
    set block at {_location} to {_block}
 
Ah I see. For this you would need to use a "projectile hit" event and detect the block the projectile hit. The thing is this task is really buggy using only Skript, so I would recommend using an addon called skript-mirror.

Using the addon, the code would look something like this (untested):

code_language.skript:
on projectile hit:
    projectile is a snowball
    set {_block} to event.getHitBlock()
    set {_location} to location of event.getHitBlock()
    set block at {_location} to ice
    wait 3 seconds
    set block at {_location} to {_block}

Using only Skript, you do something like this (also untested):

code_language.skript:
on projectile hit:
    projectile is a snowball
    set {_block} to block at location 0.1 in front of the projectile
    set {_location} to block at location 0.1 in front of the projectile
    set block at {_location} to ice
    wait 3 seconds
    set block at {_location} to {_block}

Not quite what I meant, I mean as in that the player shoots ice from himself to create a path of some sort.
dPHlZJk
https://imgur.com/a/dPHlZJk Like that but after around 10 seconds it woud be deleted
The ice spawned through this code
code_language.skript:
loop blocks from the block in front of the player to the block 50 in front of the player:
            if loop-block is air:
                set loop-block to packed ice
 
Not quite what I meant, I mean as in that the player shoots ice from himself to create a path of some sort.
dPHlZJk
https://imgur.com/a/dPHlZJk Like that but after around 10 seconds it woud be deleted
The ice spawned through this code
code_language.skript:
loop blocks from the block in front of the player to the block 50 in front of the player:
            if loop-block is air:
                set loop-block to packed ice
Oh whoopsie, I read 'projectile' instead of 'particle'. Sorry about that. Still, it follows the same kind of mechanism: saving the locations of the looped blocks to later place air.
code_language.skript:
    loop blocks from the block in front of the player to the block 50 in front of the player:
        if loop-block is air:
            set loop-block to packed ice
            add location of loop-block to {_blocks::*}
    wait 2 seconds
    loop {_blocks::*}:
        set block at location at {_blocks::%loop-index%} to air
I tested it and it worked.
 
Last edited:
Oh whoopsie, I read 'projectile' instead of 'particle'. Sorry about that. Still, it follows the same kind of mechanism: saving the locations of the looped blocks to later place air.
code_language.skript:
    loop blocks from the block in front of the player to the block 10 in front of the player:
        if loop-block is air:
            set loop-block to packed ice
            add location of loop-block to {_blocks::*}
    wait 2 seconds
    loop {_blocks::*}:
        set block at location at {_blocks::%loop-index%} to air
I tested it and it worked.
Thank you! That worked! Now just one more thing, Would it be possible to make the ice disappear per block while also making a particle when that block disappears?
 
Thank you! That worked! Now just one more thing, Would it be possible to make the ice disappear per block while also making a particle when that block disappears?
Actually, one of the bugs I had when coding this thing was exactly what you said, "making the ice disappear per block", so this should do the job:
code_language.skript:
    loop blocks from the block in front of the player to the block 50 in front of the player:
        if loop-block is air:
            set loop-block to packed ice
            add location of loop-block to {_blocks::*}
    wait 2 seconds
    loop {_blocks::*}:
        set block at location at {_blocks::%loop-index%} to air
        play snowball break at location at {_blocks::%loop-index%}
        wait 0.1 second
You change the "snowball break" part to the visual effect you wanna play (psst, the list of all effects can be found here) and the "wait 0.1 second" to the time interval you wish the blocks to disappear.
 
Status
Not open for further replies.