Variables Reference Docs

66 views
Skip to first unread message

Greg Sealby

unread,
May 11, 2019, 3:50:04 AM5/11/19
to MPF Users

Does anyone know where the MPF doco holds a list of all available variables that can be used.  For example, I am trying to find out if end of game match values are available in any existing game variables.  The only game variables I've seen in the doco are here: http://docs.missionpinball.org/en/latest/config/instructions/dynamic_values.html#game-variables

jabdoa

unread,
May 11, 2019, 5:05:39 AM5/11/19
to MPF Users
Does not look like we set this to a variable: https://github.com/missionpinball/mpf/blob/dev/mpf/modes/match/code/match.py. Should we add a variable? You could also use the match events (http://docs.missionpinball.org/en/dev/game_logic/match_mode/index.html) to set it using variable_player as a workaround.


Jan

Greg Sealby

unread,
May 11, 2019, 8:30:05 AM5/11/19
to MPF Users
Thanks Jan.  I tried using a variable (machine) and using variable_player to set it, but it seems that this is not valid during match mode.  I got the following error:

2019-05-11 22:24:37,526 : ERROR : root : Config File Error in variable_player: Section not valid outside of game modes. ConfigPlayer.variable_player/variables match_has_match:{'match_success_flag': {'int': <mpf.core.placeholder_manager.NativeTypeTemplate object at 0x0000026D3CEE1358>, 'action': 'set', 'priority': 0, 'float': None, 'string': None, 'block': False, 'player': None, 'condition': None}} Mode: <Mode.match> Error Code: CFE-variable_player-1

Is it possible to reference the winners match mode variable?  If I did a conditional event checking if it is zero (or not) I will be able to tell if a match has been found.

Greg Sealby

unread,
May 11, 2019, 8:34:06 AM5/11/19
to MPF Users
FYI, I did try and reference game.winners and got the following error:

2019-05-11 22:32:47,652 : ERROR : root : 'Game' object has no attribute 'winners'

jabdoa

unread,
May 11, 2019, 9:38:59 AM5/11/19
to MPF Users
Hi Greg,

match mode is not the game mode. You have to use machine variables (set_machine) instead of player variables. The latter can only be used in game modes (which match is not).


Jan

Greg Sealby

unread,
May 11, 2019, 10:04:38 AM5/11/19
to MPF Users
Sorry Jan, I might have thrown you off a bit there.  My main issue was that match mode does not allow you to use variable_player, so setting a machine variable was not possible.  I was just trying to see if there was another variable somewhere I could reference.

I got around this using show_player instead of slide_player as per the example in the docs.  I am using the has_match and no_match events to trigger a shows to play my first slide to show that "matching is in progress", and then showing the result.  What I am finding is that the (winner_number) variable does not show now.  It works however when I replace my match mode slide config with the example from the docs, not sure what I am doing wrong....

jabdoa

unread,
May 11, 2019, 10:47:27 AM5/11/19
to MPF Users


Am Samstag, 11. Mai 2019 16:04:38 UTC+2 schrieb Greg Sealby:
Sorry Jan, I might have thrown you off a bit there.  My main issue was that match mode does not allow you to use variable_player, so setting a machine variable was not possible.  I was just trying to see if there was another variable somewhere I could reference.

Sure you can use variable_player! Just don't use player variables. Machine variables will work fine.
 

I got around this using show_player instead of slide_player as per the example in the docs.  I am using the has_match and no_match events to trigger a shows to play my first slide to show that "matching is in progress", and then showing the result.  What I am finding is that the (winner_number) variable does not show now.  It works however when I replace my match mode slide config with the example from the docs, not sure what I am doing wrong....

Please post your config.

Greg Sealby

unread,
May 11, 2019, 11:06:09 AM5/11/19
to MPF Users
My match.yaml config has this show config in it:

show_player:
    no_match: 
        show_no_match:
            loops: 0
    has_match: 
        show_has_match:
            loops: 0

My show file is pretty simple and has this config:
#show_version=5
- time: 0
  slides: sld_match_generic_slide
- time: +4s
  slides: sld_match_slide
- time: +3s

My slide config is in a separate YAML file to my match.yaml and the area in question looks like this:

    sld_match_slide:
        widgets:
          - type: text
            style: match_result_success
            text: MATCH
            anchor_y: middle
            anchor_x: middle
            y: middle+40
            x: middle            
            animations:
              show_slide: pulse_bounce_half_sec
          - type: text
            text: (winner_number)
            style: match_result_success
            anchor_y: middle
            anchor_x: middle
            y: middle-40
            x: middle            


jabdoa

unread,
May 11, 2019, 11:38:06 AM5/11/19
to MPF Users
Looks like it should work. Can you try a slide_player? Not sure if we pass event args from show_player to sub slides. I guess we need a test there.

Jan

Greg Sealby

unread,
May 11, 2019, 7:00:23 PM5/11/19
to MPF Users
Yep, slide_player works perfectly.   Can I use a swap slide transition in slide_player to play one after the other?

I tried this code and it just showed the last slide, so I have something incorrect.

    no_match: 
        sld_match_generic_slide:
            expire: 3s
            transition:
                type: swap
        sld_no_match_slide:
            expire: 3s



FYI, I did try to use a timer to show the different slides and got this error:

SyntaxError: unexpected EOF while parsing

As soon as I removed the timer it parsed OK.  I'd used that same timer code elsewhere without issue, so pretty confident it was OK.  

Greg Sealby

unread,
May 11, 2019, 8:44:39 PM5/11/19
to MPF Users
I think I have this working now ... I used a priority property:

slide_player:
    no_match: 
        sld_match_generic_slide:
            expire: 3s
            priority: 10
        sld_no_match_slide:
            expire: 6s

Looks good to me, will keep testing it.

jabdoa

unread,
May 12, 2019, 3:48:44 AM5/12/19
to MPF Users
Thanks for testing. Will have a look why this fails in show. We probably need another test.


Jan

jabdoa

unread,
May 12, 2019, 3:51:47 AM5/12/19
to MPF Users

Greg Sealby

unread,
May 12, 2019, 4:00:45 AM5/12/19
to MPF Users
Thanks Jan.

I noticed an inconsistency potentially with the doco.  My Match Mode is not adding credits when a match is found.  I added this code into my main config.yaml:

credits:
    events:
        - event: match
          type: match
          credits: 1

The Match Mode doco refers to match_has_match as they key event, so I don't think an event named "match" is ever posted (I couldn't see it posted in the log).  I will try with the match_has_match event in my credits config.  Takes a while to test as I have to wait for a match!

jabdoa

unread,
Jul 8, 2019, 2:33:59 PM7/8/19
to MPF Users
Reply all
Reply to author
Forward
0 new messages