Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Variables to Text UI #1328

Merged
merged 5 commits into from Apr 13, 2019

Conversation

Projects
None yet
3 participants
@woosle1234
Copy link

commented Apr 10, 2019

This is for : #1119
I added the player index to text ui
Facing problems with other variable types and player types
Cannot seem to iterate through self.machine.game.player.vars as an array
Every time I try to use a for loop doing so often gives me errors of "task destroyed but it was pending" or
image
Without the ability to access the variables as an array I can't display any more player variables
Also can't seem to access the machine variables might be the wrong name I tried using self.machine.vars, self.machine.game.machine.vars and self.machine.machine_var.
All of the was being tested inside the text_ui.py

Woosle Park
@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Apr 10, 2019

Looks great! I will test it tonight.

Player variables only exist during a game. A game only exists after the user pressed the start button. It is probably best to check for self.machine.game. It will be None if there isn't any game. Usually we use _update_player_no_game outside of a game but you can also just is an if block.

Woosle Park
@woosle1234

This comment has been minimized.

Copy link
Author

commented Apr 11, 2019

I managed to add the for loop and have all player variables show up
working on machine variables next

Woosle Park
@woosle1234

This comment has been minimized.

Copy link
Author

commented Apr 11, 2019

Added machine variables also changed it so that the same player variables do not get displayed multiple times Is there anything else I need to do

@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Apr 11, 2019

Looks good! Maybe we could also show the machine variables outside of games.

The test previously have been unhappy because there was a trailing whitespace. Besides that it I guess we can merge it soon.

If you want you can add a acreenshot to the docs (e.g. here http://docs.missionpinball.org/en/dev/running/commands/game.html) or also to http://missionpinball.org. You could write a blog post on http://missionpinball.org/blog.html also since this is an often requested feature. All if you want.

@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Apr 11, 2019

Messages
========
mpf/core/text_ui.py
  Line: 288
    pylint: unused-variable / Unused variable 'x' (col 16)
  Line: 306
    pylint: unused-variable / Unused variable 'k' (col 20)

Just replace those with a underscore and you should be good. If you are at it could give the other vars a longer name too.

@woosle1234

This comment has been minimized.

Copy link
Author

commented Apr 11, 2019

Messages

mpf/core/text_ui.py
Line: 288
pylint: unused-variable / Unused variable 'x' (col 16)
Line: 306
pylint: unused-variable / Unused variable 'k' (col 20)

Just replace those with a underscore and you should be good. If you are at it could give the other vars a longer name too.

I shall

@jabdoa2
Copy link
Collaborator

left a comment

Looks awesome. Thanks!

@avanwinkle

This comment has been minimized.

Copy link
Collaborator

commented Apr 11, 2019

Excellent! I wonder if there should be a config setting in the player_vars: configuration to enable/disable variables from this display? I have 46 player variables at the moment and most of them are immaterial, but there are a handful that I would love to see. Unfortunately a straight dump of them hides the ones I'm after below the ones I don't care about.

Something like...

player_vars:
  research_points:
    initial_value: 0
    show_in_ui: true
@woosle1234

This comment has been minimized.

Copy link
Author

commented Apr 11, 2019

Excellent! I wonder if there should be a config setting in the player_vars: configuration to enable/disable variables from this display? I have 46 player variables at the moment and most of them are immaterial, but there are a handful that I would love to see. Unfortunately a straight dump of them hides the ones I'm after below the ones I don't care about.

Something like...

player_vars:
  research_points:
    initial_value: 0
    show_in_ui: true

I'm not sure how I would go about this because the variables are created at game time and I wouldn't know the names to pop so I can't hard code any filtering.

@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Apr 12, 2019

One thing I noticed: You did not yet add your name to the Authors file.

Woosle Park
@woosle1234

This comment has been minimized.

Copy link
Author

commented Apr 12, 2019

One thing I noticed: You did not yet add your name to the Authors file.

My mistake I will add it now

@jabdoa2 jabdoa2 merged commit 45c7558 into missionpinball:dev Apr 13, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jabdoa2

This comment has been minimized.

Copy link
Collaborator

commented Apr 13, 2019

Thanks for adding this great feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.