PGM icon indicating copy to clipboard operation
PGM copied to clipboard

Instantaneous Dynamic Filters

Open OhPointFive opened this issue 3 years ago • 2 comments

Currently, filters only apply to things that are true or false for a period of time. This makes sense, since filters originally weren't dynamic.

However, with dynamic filters, it could be useful to have filters that represent events, not states. For example, something like

<filters>
  <ate id="ate-apple">apple</ate>
</filters>
<portals>
  <portal forward="ate-apple" />
</portals>

could teleport a player when they ate an apple.

With the upcoming Actions & Triggers (#1016) this could be even more useful. For example, a player could have a selection of items which, when one is clicked, applies a kit to them, allowing class selection more easily than the /class command or the usual portal/kit setup.

The most immediately useful instantaneous dynamic filter I think would be when the player right clicks with an item, but this could be expanded to many other events (taking damage, placing/breaking blocks, etc.)

Implementation-wise I'm not too familiar with the inner workings of dynamic filters. It might be easiest to make the filter stay true just while executing relevant action, or for a whole tick. Or, it might be better to use some other mechanism other than dynamic filters.

OhPointFive avatar Jul 07 '22 05:07 OhPointFive

I've discussed this with @KingOfSquares in the past and i believe it to be a good idea, the filter themselves should be active for a tick because rising and falling on the same tick isn't supported and would make little sense.

Pablete1234 avatar Jul 07 '22 08:07 Pablete1234

Yes, filters that test something that happened instead of something that is happening should probably just rise for a single tick. Easier than making a separate system

KingOfSquares avatar Jul 08 '22 19:07 KingOfSquares

The only example use I could think of for this idea is finished by #1131 so I'm not sure this is still needed. Maybe there's some other instantaneous filter?

OhPointFive avatar Feb 05 '23 08:02 OhPointFive

Given that we've gotten triggers, actions and more importantly, variables, i think this is no longer needed. If we want to support a one-tick-thing instead of a filter, we can add a feature that activates an action, and if the XML author needs it as a filter, it can be turned into a variable filter that re-sets itself after a tick. (ie: an action that sets some variable to 1, the filter matches on 1, and a filter for 1 tick after it becomes 1 triggers an action to set it back to 0). While it's not the cleanest solution, it would do in the case that you really need to filter during that one tick.

Pablete1234 avatar Mar 19 '23 01:03 Pablete1234