Title. What I’m trying to make is a new redstone component/device which is a speaker. Basically, I have a redstone lamp which is flagged that I want to play a sound when it’s powered (switched). Then, to stop it from making light, I flip it off without physics, returning it to its original state. The problem I’m having is if the block is updated (for example, when you place something adjacent) the sound will trigger, which is not the desired effect. How can I prevent this from happening, and only have the event activate from it being powered?
#(Funkyhehim) Preventing A Lamp From Ever Being Powered From A Block Update
42 messages · Page 1 of 1 (latest)
(Funkyhehim) Preventing A Lamp From Ever Being Poweed
Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>
What I have ^
The custom event I’m using ^
(Funkyhehim) Preventing A Lamp From Ever Being Powered From A Block Update
!e block physics
Group
Block
**WARNING**
This event may fire very rapidly.
Event Lines
<block> physics
Switches
adjacent:<block> to only process the event if the block or an immediately adjacent block (up/down/n/e/s/w) matches the LocationTag matcher specified. This can be useful to prevent blocks from breaking.
Triggers
when a block's physics update.
Context
<context.location> returns a LocationTag of the block the physics is affecting.
<context.new_material> returns a MaterialTag of what the block is becoming.
Has Known Location
True - this adds switches in:<area> + location_flagged:<flag name>.
Cancellable
True - this adds <context.cancelled> and determines cancelled + cancelled:false.
uh huh yeah i know
I'm trying not to update it when a player puts a block next to it or any reason other than being powered
is the block physics event insufficient for this?
if so, in what way?
Basically, I only want the block to trigger when it receives power from a source for the first time, like a dispenser
My current method works, however, whenever the block updates due to other reasons, the lamp lights up again, misfiring the trap
My end end goal is to make a custom traps system
My main problem with the physics event is that I can’t determine what caused the event
Looking at the spigot docs for the BlockPhysicsEvent I see that the getSourceBlock() method is not used in Denizen’s BlockPhysicsScriptEvent and I was thinking that may possibly be relevant or be a solution to getting what location caused the block update?
Any updates on this? I’d also be content if I could somehow fake the lantern into not emitting light.
Maybe I could use pistons for this instead?? I’ll tias later
You could flag the block with it's powered state, then when block physics triggers, see if the powered state has changed. If it didn't, then it was probably just a block being placed nearby, and you can ignore it
If I cancel the push even then it will still update #sad
I’ll see about this
Resolving this because SOMEBODY decided to implement this WITHOUT TELLING ME @junior dirge
actually should I keep this open as a feature rqst
wat
I've assumed you would check the repo after I merged your PR
No </3
Thread Closing Reminder
Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.
If not yet resolved, please reply below to tell us what you still need.
(Note that if there is no reply for a few days, this thread will eventually close itself.)
@karmic wolf