Skip to content

MPFSlide

MPFSlide is a Godot Node class provided by the MPF-GMC extension. All scenes that will be used as slides must derive from the MPFSlide class.

Node Configuration

animation_player:

An instance of an AnimationPlayer node that one or more animations named "created", "active", and/or "removed". If an AnimationPlayer node is attached and contains any of those animation names, the respective animation will play on the slide when the slide changes to that state.

Parameters

Slide instances created by slide_player have initial values that can be overridden with parameters in the slide player configuration.

context:

Single value, type: String. Default: the calling mode's name

When a mode is stopped in MPF, a clear event is broadcast to signal the end of the mode and to remove all slides, widgets, sounds, lights, and shows started by that mode. The value to track this is called "context", and by default each slide has a context of the name of the mode that created it.

If you do not wish for your slide to be removed when the calling mode ends, you can specify a different context value.

key:

Single value, type: String. Default: the slide's file name

Once a slide is instantiated, it can be referenced by its key for actions like update and remove. By default, the slide's file name is used as its key.

In situations you may want multiple instances of a slide, you can specify a key manually. This key will then be used to reference the slide for any future actions.

priority:

Single value, type: 'integer'. Default: 0

This value will be added to the calling mode's priority to determine the overall stack priority of the slide. When a slide is added or removed from the stack, the stack is sorted with the highest priority slide on top.

Methods

MPFSlide does not have any public methods exposed, but custom methods can be added to scene scripts that extend MPFSlide. These methods can be triggered from MPF slide_player with the action: method option. See the slide_player: reference for more details.

When a custom function is called, two parameters are passed in: settings, the configuration settings from the slide player config, and kwargs, the arguments from the event that triggered the slide player. If you declared any tokens: in your config for the slide player, those will be available as settings.tokens.

    func my_custom_method(settings, kwargs):
        # Function does stuff here

Godot requires parameters for this function

You don't have to use the settings and kwargs parameters, but you do need to include them in your method.

Godot has a pattern for parameters that are required by a function but not used by it: prefix the parameter name with a single underscore. This tells Godot that you know there is a required parameter but you're not going to use it; otherwise, Godot will give you a warning that the parameter is not used.

func my_custom_method(_settings, _kwargs):

settings

Single value, type Dictionary.

The settings parameter passed to the custom method is the configuration used in the slide_player: config file. It includes settings like priority, action, and the tokens: dictionary if you made one.

kwargs

Single value, type Dictionary.

The kwargs parameter passed to the custom method is the list of event arguments from the event that triggered the slide_player to be called in the first place.

For example, the player_score event includes arguments for value, prev_value, change, and player_num. If your slide player is triggered by the player_score event, like so:

    slide_player:
        player_score:
            main_slide:
                action: method
                method: my_method

Then in the func my_method(settings, kwargs): method of main_slide.gd you would have access to kwargs.value, kwargs.prev_value, kwargs.change, and kwargs.player_num.

If you're curious what event arguments are available for a given event, look at the MPF log files. Each event is logged with all its arguments, so you can quickly see what's available.


Something missing or wrong? You can fix it!

This website is edited by people like you! Is something wrong or missing? Is something out of date, or can you explain it better?

Please help us! You can fix it yourself and be an official "open source" contributor!

It's easy! See our Beginner's guide to editing the docs.

Page navigation via the keyboard: < >

You can navigate this site via the keyboard. There are two modes:

General navigation, when search is not focused:

  • F , S , / : open search dialog
  • P , , : go to previous page
  • N , . : go to next page

While using the search function:

  • Down , Up : select next / previous result
  • Esc , Tab : close search
  • Enter : go to highlighted page in the results