MPFTextInput Text String Argument

47 views
Skip to first unread message

Nixco

unread,
Aug 6, 2025, 11:48:02 AMAug 6
to MPF Users
Hi MPF Users !

I'm coding a mode that launch before the first ball of each player.
The player enters his name like in the highscore mode.

Everything is going fine except i can't find how to use the text value stored as an argument in the event sent by Godot.

#config_version=6

mode:
  start_events: ball_will_start{player==1 and ball==1}
  priority: 200

queue_relay_player:
  ball_starting:
    post: name_player_one
    wait_for: text_input_player_one_name_complete

slide_player:
  name_player_one: player_one_naming
  text_input_player_one_name_complete:
    player_one_naming:
      action: remove

event_player:
  s_left_flipper_active:
    text_input:
      action: left
  s_right_flipper_active:
    text_input:
      action: right
  s_start_active:
    text_input:
      action: select

variable_player:
  text_input_player_one_name_complete:
    player_one_name:
      action: set
      string: ??

The value is well stored :

2025-08-06 17:16:17,478 : INFO : EventManager : Event: ======'text_input_player_one_name_complete'====== Args={'text': 'NICO', '_from_bcp': True}

I tried a few things but i can't make it work.
Any idea ?

Thanks :D

Alex L

unread,
Aug 7, 2025, 4:19:49 PMAug 7
to MPF Users
I was trying to solve this a month or two ago, and your message pushed me to dig that up and try again.
This time I found success! Here's an example with just a button press submitting the update event with a "text" param.

```
# in a machine config:
player_vars:
    test_string:
        initial_value: "default"
        value_type: str

# in a mode config:
event_player:
    s_test_input_active:
        update_test_string: #custom event emission
            text: success          #custom param set for event

variable_player:
    update_test_string:
        test_string:
            action: set
            string: "{text}"
```

It seems that this is just a python format string, so you can also do things like "static-content{variable_content}" to get static interpolation, or possibly "{var1}-{var2}" to get multiple variable interpolation (if you have those variables, of course!)
Message has been deleted
Message has been deleted

Nixco

unread,
Aug 8, 2025, 10:20:44 AMAug 8
to MPF Users
Thank you so much ! 
It's working well :D
Reply all
Reply to author
Forward
0 new messages