#Emerald block gun

1 messages · Page 1 of 1 (latest)

unkempt nacelle
#

Hi, so im making a little gun that shoots particles and the block that those particles hit will turn into an emerald block for 4 seconds but its not working

function ems(p: player, length: number, dmg: number):
    set {_x} to 0
    set {_l} to 0
    loop {_length} times:   #loops as many times as long as the length from the function input
        add 1 to {_x}
        add 0.25 to {_l}
        set {_rg%{_x}%} to location {_l} meters infront of {_p}
        set {_rg%{_x}%} to location 1.25 meters above {_rg%{_x}%} #aligns with where player is looking better
    # all of the locations are saved as soon as the function is called, effects such as particles can be applied afterwards.
    set {_x} to 0
    loop {_length} times:
        add 1 to {_x}
        show 3 light green dust at {_rg%{_x}%} #change color or particle type
        show 1 green dust at {_rg%{_x}%} #change color or particle type
        loop entities in radius 1 around {_rg%{_x}%}:
            loop-entity is not {_p}
            damage loop-entity by {_dmg}
            stop #if you want your projectile to pierce entities, delete this line
        loop blocks in radius 0.5 around {_rg%{_x}%}:
            if loop-block is not glass or air or water:
                set {block} to block at {_rg%{_x}%}
                set {blockloc} to location of {block}
                wait 1 tick
                set block at {blockloc} to emerald block
                wait 4 seconds
                set block at {blockloc} to {block}
                broadcast "%{blockloc}% %{block}%"
                stop
                
on click:
    if player's held item is emerald:
        ems(player, 30, 0)
smoky echo
#

can you elaborate past "but its not working"? Which parts of the code are we looking at for an error? What kind of an error are we looking for?

#

-# also im really tired of seeing this recycled garbage code from the minehut forums

unkempt nacelle
#

oh yes the part where its supposed to place the block back as the block it was before turning into emerald doesnt work and I know here its using global variables but I have tried it with local variables and the same thing happened

#

theres no skript error it simply just isnt placing the block back

maiden locust
#

hmm

#

what isn't working

#

@cedar portal do /sk info

#
    set {_x} to 0
    set {_l} to 0
    loop {_length} times:   #loops as many times as long as the length from the function input
        add 1 to {_x}
        add 0.25 to {_l}
        set {_rg%{_x}%} to location {_l} meters infront of {_p}
        set {_rg%{_x}%} to location 1.25 meters above {_rg%{_x}%} #aligns with where player is looking better
    # all of the locations are saved as soon as the function is called, effects such as particles can be applied afterwards.
    set {_x} to 0
    loop {_length} times:
        add 1 to {_x}
        show 3 light green dust at {_rg%{_x}%} #change color or particle type
        show 1 green dust at {_rg%{_x}%} #change color or particle type
        loop entities in radius 1 around {_rg%{_x}%}:
            loop-entity is not {_p}
            damage loop-entity by {_dmg}
            stop #if you want your projectile to pierce entities, delete this line
        loop blocks in radius 0.5 around {_rg%{_x}%}:
            if loop-block is not glass or air or water:
                set {_block} to block at loop-block
                set {_loc} to location of loop-block
                wait 1 tick
                set block at {_loc} to emerald block
                wait 4 seconds
                set block at {_loc} to {_block}
                broadcast "%{blockloc}% %{block}%"
                stop
                
on click:
    if player's held item is emerald:
        ems(player, 30, 0)```
there should be fixed
maiden locust
#

@unkempt nacelle try this

#

it should fix your code

cedar portal
#

Np. Us waffles get confused a lot.

maiden locust
#

im glad theres only 1 crebs here

cedar portal
#

Like people thought I was the richest person on the Donut SMP

maiden locust
#

are you?

cedar portal
#

no. My username: WaffleMan4268, their username: WaffleMan1234

unkempt nacelle
#

it just makes the block emerald and doesnt change it back

#

its the same problems I was having

#

theres no error though

maiden locust
#

it makes the emerald block

#

but didn't change it

#

ok i see

unkempt nacelle
#

it doesnt change it back to what the bock was before the emerald hit

maiden locust
#
    set {_x} to 0
    set {_l} to 0
    loop {_length} times:   #loops as many times as long as the length from the function input
        add 1 to {_x}
        add 0.25 to {_l}
        set {_rg%{_x}%} to location {_l} meters infront of {_p}
        set {_rg%{_x}%} to location 1.25 meters above {_rg%{_x}%} #aligns with where player is looking better
    # all of the locations are saved as soon as the function is called, effects such as particles can be applied afterwards.
    set {_x} to 0
    loop {_length} times:
        add 1 to {_x}
        show 3 light green dust at {_rg%{_x}%} #change color or particle type
        show 1 green dust at {_rg%{_x}%} #change color or particle type
        loop entities in radius 1 around {_rg%{_x}%}:
            loop-entity is not {_p}
            damage loop-entity by {_dmg}
            stop #if you want your projectile to pierce entities, delete this line
        set {_n} to 0
        loop blocks in radius 0.5 around {_rg%{_x}%}:
            if loop-block is not glass or air or water:
                set {_block::%{_n}%} to block at loop-block
                set {_loc} to location of loop-block
                wait 1 tick
                set block at {_loc} to emerald block
                wait 4 seconds
                set block at {_loc} to {_block::%{_n}%}
                broadcast "%{_loc}% %{_block::%{_n}%}%"
                add 1 to {_n}
                stop
                
on click:
    if player's held item is emerald:
        ems(player, 30, 0)```
#

try that

unkempt nacelle
#

doesnt work and when it broadcasts the block it says emerald block so idk why thats happeneding ;-;

maiden locust
#

idk because it doesn't check if the loop-block is already an emerald block

#

oh i see it now

#

its the stop

#
    set {_x} to 0
    set {_l} to 0
    loop {_length} times:   #loops as many times as long as the length from the function input
        add 1 to {_x}
        add 0.25 to {_l}
        set {_rg%{_x}%} to location {_l} meters infront of {_p}
        set {_rg%{_x}%} to location 1.25 meters above {_rg%{_x}%} #aligns with where player is looking better
    # all of the locations are saved as soon as the function is called, effects such as particles can be applied afterwards.
    set {_x} to 0
    loop {_length} times:
        add 1 to {_x}
        show 3 light green dust at {_rg%{_x}%} #change color or particle type
        show 1 green dust at {_rg%{_x}%} #change color or particle type
        loop entities in radius 1 around {_rg%{_x}%}:
            loop-entity is not {_p}
            damage loop-entity by {_dmg}
            exit this loop
        set {_n} to 0
        loop blocks in radius 0.5 around {_rg%{_x}%}:
            if loop-block is not glass or air or water:
                set {_block::%{_n}%} to block at loop-block
                set {_loc} to location of loop-block
                wait 1 tick
                set block at {_loc} to emerald block
                wait 4 seconds
                set block at {_loc} to {_block::%{_n}%}
                broadcast "%{_loc}% %{_block::%{_n}%}%"
                add 1 to {_n}
                
on click:
    if player's held item is emerald:
        ems(player, 30, 0)```
#

try this

unkempt nacelle
#

still the exact same

maiden locust
#

Odd

#

Idk skill issue

#

Never had this problem

unkempt nacelle
#

It's happened to me a lot and i find a work around but i forgot the work around

smoky echo
#

probably could shorten it by 20 lines re-writing with vectors

maiden locust
#

True