Solved Explosions with Debris

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

CKR367

Member
Feb 1, 2017
64
2
0
I need help creating a script that when an explosion occurs, it throws the blocks that were in the radius of the explosion, away from it, somewhat like a realistic explosion. I created a bit of code to help people visualize what I need help with, I know it doesn't work. Any help is appreciated.

code_language.skript:
on explosion:
    cancel event
    create a fake explosion at event-location
    loop blocks in radius 4:
        set loop-block to air
        spawn falling block of loop-block at event-location
        push last spawned entity away from event-explosion with force 1
    stop trigger

Info:
Game Version: 1.11.2
Skript: Latest Bensku Version
SkQuery: 1.11 Lime
SkRayFall: Latest
Skellett: Latest
Umbaska: Latest
 
  1. You don't need to put "stop trigger" at the end of a trigger, because it's going to stop there anyways; it's just a waste of code.
  2. Since you have SkQuery, use "loop exploded blocks" instead of looping all blocks in a radius of four. That way you'll actually be looping the blocks that were affected, not every block that happens to be nearby (which would let people blow up obsidian, bedrock, end portals...)
  3. You'll need to set the loop-block to air after you attempt to spawn the falling block, because otherwise it will see that the loop-block is now air, so it'll try to spawn falling air.
  4. The entity should be pushed from the event-location, not the event-explosion.
Hope that helps!
 
  1. You don't need to put "stop trigger" at the end of a trigger, because it's going to stop there anyways; it's just a waste of code.
  2. Since you have SkQuery, use "loop exploded blocks" instead of looping all blocks in a radius of four. That way you'll actually be looping the blocks that were affected, not every block that happens to be nearby (which would let people blow up obsidian, bedrock, end portals...)
  3. You'll need to set the loop-block to air after you attempt to spawn the falling block, because otherwise it will see that the loop-block is now air, so it'll try to spawn falling air.
  4. The entity should be pushed from the event-location, not the event-explosion.
Hope that helps!

Thank you!

But what direction should I use? I currently have:
code_language.skript:
push last spawned entity away from event-location with force 1
but that seems to not work, it just says "event-location is not a direction"
 
You'd do "push last spawned entity direction from event-location to last spawned entity"
 
You'd do "push last spawned entity direction from event-location to last spawned entity"
Here is the outcome of that....xD
https://gyazo.com/84a5e8dd726c215f412f71dd8a452ee1


code_language.skript:
on explosion:
    cancel event
    create a fake explosion at event-location
    loop exploded blocks:
        spawn falling block of loop-block at event-location
        set loop-block to air
        push last spawned entity direction from event-location to last spawned entity
 
Spawn the falling block at the loop-block instead of the event-location, you're spawning all of the falling blocks where the explosion is taking place instead of where they're meant to be.
 
Spawn the falling block at the loop-block instead of the event-location, you're spawning all of the falling blocks where the explosion is taking place instead of where they're meant to be.

Thank you! I had to add a force amount to the end or else the blocks would fly off into no where. Thanks again, problem solved.
 
Spawn the falling block at the loop-block instead of the event-location, you're spawning all of the falling blocks where the explosion is taking place instead of where they're meant to be.
Actually, If I were to go about setting specific blocks in the loop to another block, how would I do that? For example, I don't want grass blocks to be launched in the explosion, so I tried doing this...
code_language.skript:
    loop exploded blocks:
        if loop-block contains grass:
            set loop-block to dirt
The issue with that is that it sets every looped block to dirt, not just the grass blocks....
 
Are you saying you want it to not explode grass, or to spawn falling dirt instead of grass when a grass block explodes? Try using "if loop-block is grass" instead of contains.
 
Are you saying you want it to not explode grass, or to spawn falling dirt instead of grass when a grass block explodes? Try using "if loop-block is grass" instead of contains.
That worked, Thanks!
 
@CKR367 Could you post the full working code here so i could also use it :emoji_slight_smile: ?
Sure, here it is.


code_language.skript:
on explosion:
    cancel event
    create a fake explosion at event-location
    loop exploded blocks:
        spawn falling block of loop-block at loop-block
        set loop-block to air
        push last spawned entity direction from event-location to last spawned entity with force 0.5
 
Status
Not open for further replies.