On throwed block connect

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

Bilbo

Member
Jan 26, 2017
27
0
0
29
Hello.

What i cant find out is this : when right clicked holding TNT, it fires it in a direction of player, when the primed tnt hits a block - it sticks to it.

I need to to this where a C4 in my case, that looks like Tnt is thrown, that far i got, when the tnt is thrown - it shoots it and primes it straight up. But i cant manage to get it to stick on block hit.

On projectile hit: - doesnt read it. Because it doesnt take it as projectile, is there a way to do this somehow?

Thank you.
@Snow-Pyon Maybe you know how to do this? :emoji_slight_smile:
 
I'm not sure what do you mean. But if you spawned primed tnt than use event-entity as event-block. If you want push primed tnt then use code:
code_language.skript:
push the target-entity %direction%
How do you spawn the primed tnt?
 
code_language.skript:
on right click holding tnt:
    shoot a tnt from the player at speed 0.5

This is the code, yet i need to somehow get the block to stick to the first hit block. Like if i throw it at a wall - on block connect it gets stuck there
 
I prefer:
code_language.skript:
on rightclick holding tnt:
    set target-block to air
    spawn a primed tnt at target-block
    set {_lastspawned} to last spawned entity
    push {_lastspawned} %direction%
Do some in this way, else I need check self.
EDIT:
OHHH wait I read your text again, you want check if the tnt is hitting the wall? oke then there should a event.
 
I prefer:
code_language.skript:
on rightclick holding tnt:
    set target-block to air
    spawn a primed tnt at target-block
    set {_lastspawned} to last spawned entity
    push {_lastspawned} %direction%
Do some in this way, else I need check self.
EDIT:
OHHH wait I read your text again, you want check if the tnt is hitting the wall? oke then there should a event.

What event could there be? Thats the thing i need to get :emoji_grinning: How to detect if the Tnt hits a wall or ground...
 
What event could there be? Thats the thing i need to get :emoji_grinning: How to detect if the Tnt hits a wall or ground...
try something like this:
code_language.skript:
on right click holding tnt:
    shoot a tnt from the player at speed 0.5
    set {_tnt} to last spawned entity
    while {_tnt} is alive:
        if block at location of {_tnt} isn't air:
            teleport {_tnt} to location of {_tnt}
 
try something like this:
code_language.skript:
on right click holding tnt:
    shoot a tnt from the player at speed 0.5
    set {_tnt} to last spawned entity
    while {_tnt} is alive:
        if block at location of {_tnt} isn't air:
            teleport {_tnt} to location of {_tnt}
It doesnt give any errors but the while function doesnt work i guess, because i added fake explosion code to it and it does nothing.
 
It doesnt give any errors but the while function doesnt work i guess, because i added fake explosion code to it and it does nothing.
try replacing while {_tnt} is alive with while true BUT MAKE SURE to add a delay or it will crash your server
 
UPDATE:
code_language.skript:
on right click holding tnt:
    cancel event
    shoot a tnt from the player at speed 0.5
    wait 20 ticks
    loop all entities:
        loop-entity is tnt:
            broadcast "works"
This code reads out the entity
 
UPDATE:
code_language.skript:
on right click holding tnt:
    cancel event
    shoot a tnt from the player at speed 0.5
    wait 20 ticks
    loop all entities:
        loop-entity is tnt:
            broadcast "works"
This code reads out the entity
This may work but it will be buggy if there are multiple tnt's. Try shooting the tnt and then loop through all tnt's and set {_tnt} to the closest one to the player (without the 20 tick delay).
 
code_language.skript:
on right click holding tnt:
    cancel event
    shoot a tnt from the player at speed 0.5
    loop all entities:
        loop-entity is tnt:
            if distance between player and loop-entity is less than 5:
                broadcast "yes"
                set {_tnt} to loop-entity
                while {_tnt} is alive:
                    broadcast "yes again"
                    if block at location of {_tnt} isn't air:
                        teleport {_tnt} to location of {_tnt}
The {_tnt} part doesnt work
 
code_language.skript:
on right click holding tnt:
    cancel event
    shoot a tnt from the player at speed 0.5
    loop all entities:
        loop-entity is tnt:
            if distance between player and loop-entity is less than 5:
                broadcast "yes"
                set {_tnt} to loop-entity
                while {_tnt} is alive:
                    broadcast "yes again"
                    if block at location of {_tnt} isn't air:
                        teleport {_tnt} to location of {_tnt}
The {_tnt} part doesnt work
So the output is only "Yes"?
Then it's probably the while loop
 
Status
Not open for further replies.