#defense

1 messages · Page 1 of 1 (latest)

prime cairn
#

what im trying to do is defense blocks so i set if a cobblestone was placed it should like set metadata health of event block and then like remove 1 by 1 from meta till it finishes like the health of it and set it to air and cancel drop and delete the metadata but not working any reasons?

#

i debugged the {_meta} it shows as -1 why?

#

@foggy pagoda

wheat coral
#

you cannot call local variables outside the function they were declared in
in the on place event, you set {_meta} to the metadata but then you remove 1 from {_meta} in your on mine event

wheat coral
#

by default if a variable is undefined (which it is because its a local variable) it'll be 0, and you're removing 1 from it so its always going to be -1

prime cairn
#

how can i call it tho or something

wheat coral
#

by my understanding of your code, you simply need to change {_meta} into metadata "DHealth" of event-block in your on mine event

#

and setting the {_meta} variable inside your on place event is redundant since it will never be used

prime cairn
#

okay let me try

wheat coral
prime cairn
#

weird its not setting the block to air and debugging the meta {none}

#

on break:
    if event-block is a cobblestone:
        if metadata "DHealth" of event-block is not set:
            set metadata "DHealth" of event-block to 15
        else:
            set {_meta} to metadata "DHealth" of event-block
            remove 1 from {_meta}
            set event-block to air
            cancel drops
        if {_meta} is 0:
            delete metadata "DHealth" of event-block
        else:
            cancel event
            set metadata "DHealth" of event-block to {_meta}
wheat coral
#

when you set {_meta} to the metadata on line 6 and modify it, it will not actually update the metadata since you are just changing the var
so you must use remove 1 from metadata "DHealth" of event-block instead of removing it from the variable
also try using set block at event-block to air instead