add shots:delay_event_list to allow more delay options#1911
add shots:delay_event_list to allow more delay options#1911bosh wants to merge 1 commit intomissionpinball:devfrom
Conversation
|
Docs PR missionpinball/mpf-docs#626 |
8036dde to
a764cc4
Compare
|
I think this is just a generally useful feature to support, but I was wondering about one potential use case: could delay events on shots be a useful way to allow drop bank knockdowns (e.g. for ball search or in service mode) to bypass shot crediting? It seems like you might be able to get away with the custom dropdown knockdown event being reused as a delay event here. |
avanwinkle
left a comment
There was a problem hiding this comment.
It surprises me that the sequence shots uses delay_event_list and delay_switch_list, that's a pattern not used anywhere else in the configs. Most just use the plural, e.g. delay_events or delay_switches.
Should we align on the standard pattern?
|
Can do :) |
a764cc4 to
b9884c5
Compare
|
|
@avanwinkle I believe there is an actual reason to not name with _events as a suffix (which is why this build failed upon changing it). In device manager it checks for config keys that This can be confirmed in mode where the device manager yield values are being used to register handlers with delay -- self.add_mode_event_handler(
event=event, handler=self._control_event_handler, callback=method,
ms_delay=delay, blocking_facility=device.class_label)But we want the event to process immediately, and the delay to last until the time expires. IMO delay is the wrong term for this whole feature on shots and shot sequences (not that I can think of better) but maybe delay was just used since most other control events do indeed use that field as a delay amount. I feel like shot_sequence probably had the feature named awkwardly as it did specifically to avoid getting caught in the handler. Are you okay with reverting to the original PR with I guess another option could be to add |
b9884c5 to
2755d82
Compare
|
Bummer, I feel like we're so close to leveraging the existing _events syntax but just need a special case where the delay is a param passed to the handler rather than a delay in calling the handler. Would it be worth adding a special case to the mode code to handle the delay specially? As for verbage, I introduced the word "mute" when I was working on drop targets and wanting to suppress switch hits while the drop was resetting. So perhaps mute_events would be appropriate? |
|
Oops I meant to get back to this -- re: another special case in At least control_events has a pretty standard structure that is very distinct from the rest of the *_events bindings; I think that our new case here has an identical structure to the standard case, so adding the different behavior could make it harder to track down game developer's bugs in the future. I'm not usually an annotations guy, but I would be more in favor of something like extending the current annotation params. The annotation |
|
Re: mute verbiage - I'm down with it, but would you want to rename the existing usages? We have: I suppose a full renaming would allow us to fix the delay_switch name-is-single-but-actually-supports-multiple issue as well. sequence_shots - mute_event/switch_list or just mute_events/switches |
|
Mm, now you've got me thinking and I feel like this new use case is actually closer to the control events than standard events. Most events just use a string or list of strings for event names to trigger a proscribed verb, while control events use a dictionary to specify the action and parameters. What if the delay/mute behavior was controlled via control events with action: mute and duration: XXms? This avoids the special formatting case and the default *_events behavior, and muting a switch/shot feels like a "control" kind of thing. |
2755d82 to
e4fcf3f
Compare
|
|
So switch the implementation target to a new control event type on shots? The existing control_events for shots implicitly has an action we could call "set_state", which takes an event list and a state to set. So instead we would take a Or use TBH after thinking through all this, I still think just avoiding the _events suffix is best (so, mute_event_list and mute_switch_list) because it reduces special cases and is the clearest naming to tell a developer what kind of structure theyre going to build. I think the suffix |
|
I like the direction of inferring |
|
So: shots:
my_shot:
...
control_events:
- events: set_my_shot_to_my_state
action: set_state
state: 1
force: True
force_show: False
- action: mute
duration: 100ms
events: mute_my_shotand Shot::_register_control_event_handlers will split into two different handler binding sets based on action (or falling back to set_state). Looks like shot control events also do not yet support priority setting -- it looks like shot actually supports priority (and is undocumented on the config reference, but represents an offset), so I would expect shot control event bindings to have priority of:
This would be a breaking change, but makes more sense to me than defaulting shot control events to priority 1 - the default per Line 132 in a19c3a3 |
|
Yeah, I think that looks really good. I'd check out the logic_blocks to see how the Thanks for bearing through on this one! |
e4fcf3f to
358b938
Compare
b78149b to
b736b20
Compare
…shot handling previously only delay_switch was allowed. Note that the format of these delay events is event_handler:ms, but unlike the usual where ms means the delay before acting, this ms represents the duration of the delay (which is applied immediately)
b736b20 to
08cf8d7
Compare
|



not just switches! Based on the sequence_shot implementation of the same property name