Author Topic: user_setttings Return Value Issue  (Read 2543 times)

ScottD

  • Wizard
  • *****
  • Posts: 388
  • Scott Danesi
    • View Profile
    • ScottDanesi.com
user_setttings Return Value Issue
« on: February 16, 2014, 11:22:52 AM »
Hey Guys,
I seem to be having a strange problem with my understanding of how to use the user_settings function.

First, let me show you some code snippets of how I am setting up and calling the user_settings function.

In my settings.yaml and settings_template.yaml file, I have the following:
Code: [Select]
Feature:
  'Jackpot Hold':
    options: [true,false]
    default: true
  'Drop Target Time':
    options: [5,50]
    increments: 1
    default: 5

I am then setting a variable to the Drop Target Time in this file:
Code: [Select]
self.dropTargetHurryUpTime = self.game.user_settings['Feature']['Drop Target Time']

I was expecting that I can use this variable as a float or int value, but when I "print" the value of this variable, I get the following:
Code: [Select]
print 'Drop Target Hurry Time: ' + str(self.dropTargetHurryUpTime)

Result:
Drop Target Hurry Time: {'default': 5, 'increments': 1, 'options': [5, 50]}

This value seems to be of the datatype 'dict' and not what I was expecting, that is why I had to convert it to str in order to concatenate it with the line I am printing.  I have successfully used the 'Jackpot Hold' boolean value in my code without issue.  Am I missing something obvious here?

Thanks guys!

Gerry Stellenberg

  • Administrator
  • *****
  • Posts: 2399
    • View Profile
    • PinballControllers.com
Re: user_setttings Return Value Issue
« Reply #1 on: February 16, 2014, 11:35:42 AM »
Scott,

What you've put into both of your files *is* a dictionary.  You need only create the settings_template.yaml file.  That's where the dictionary goes to define the possibly values for each setting.  pyprocgame will automatically create settings.yaml with only the item name and selected value (or default).

So... just delete your settings.yaml file and rerun.

- Gerry

ScottD

  • Wizard
  • *****
  • Posts: 388
  • Scott Danesi
    • View Profile
    • ScottDanesi.com
Re: user_setttings Return Value Issue
« Reply #2 on: February 16, 2014, 11:40:31 AM »
HAHA!  That absolutely did the trick.  Thanks for getting back to me so quickly on this.  I am back up and running!

I wish every programming issue I had in my life could be solved this easily.

:)

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: user_setttings Return Value Issue
« Reply #3 on: February 16, 2014, 11:42:26 AM »
I don't think the two files should not be the same.  The user settings should just contain the current value.  The template has the data so the service mode can offer you options to select.  The user_settings should look more like .. .

Feature: {Jackpot Hold: True, Drop Target Time: 5}

If the load settings does not find the item in the user data, it then grabs the default value.

Since you are telling it those are the values needed for that item, it is grabbing the whole thing.  Try going into the service mode, and selecting your items there and see what file it generates.

ScottD

  • Wizard
  • *****
  • Posts: 388
  • Scott Danesi
    • View Profile
    • ScottDanesi.com
Re: user_setttings Return Value Issue
« Reply #4 on: February 16, 2014, 12:33:54 PM »
Since you are telling it those are the values needed for that item, it is grabbing the whole thing.  Try going into the service mode, and selecting your items there and see what file it generates.

Yeah, the problem was that I copied the file from the template and assumed that would work to store values.

HAHA, service mode...  ...I am definitely not that far into it yet.  :)

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Re: user_setttings Return Value Issue
« Reply #5 on: May 05, 2015, 03:22:09 PM »
I know, this is an old topic, but I am at the point of trying to implement high score tracking in my Flash machine, and I want to make sure I know how this works.

I am going to use game_data to store my high scores.  The load command takes two arguments: A template file and a user file.  The template file is the only one that is required initially.  So I will put my default high score values there.

If I understand the code correctly, pyprocgames goes looking for the user file first, and if it finds the value there, it load it.  If it is not in the user file, it then uses the value from the template file.

So what about storing the new values?  Do I use the save_game_data function, and point it to the user game data file?
Thanks,
Uncivil Engineer

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: user_setttings Return Value Issue
« Reply #6 on: May 05, 2015, 06:06:03 PM »
your code needs to save that back at the end of the game (save_game_data), I do it when a new high score is achieved.

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Re: user_setttings Return Value Issue
« Reply #7 on: May 06, 2015, 01:21:26 AM »
Ok, cool.   I got it to work.

lachied

  • P3 Developers
  • *
  • Posts: 296
    • View Profile
    • Pin build/blog
Re: user_setttings Return Value Issue
« Reply #8 on: May 06, 2015, 06:30:50 PM »
Where does that data get saved to? Is it a text file, registry? Is there some kind of mechanism in place to prohibit someone from manually putting in a highscore or changing their stats?

Steve S

  • FPGA_testers
  • *
  • Posts: 434
  • Steve Shoyer
    • View Profile
    • Steve's website
Re: user_setttings Return Value Issue
« Reply #9 on: May 06, 2015, 09:10:29 PM »
It gets saved as a yaml file, so it's a text file.  It's probably in the same directory as your other config files, set by config_path.  I don't see anything that would prevent someone from getting modifying the file manually with a text editor, although they would need access to the system to be able to do that (such as using a local screen/keyboard or a remote connection).  I don't believe there's anything in the framework that would allow someone to edit the file through the service menu.

uncivil engineer

  • Wizard
  • *****
  • Posts: 118
  • Alan
    • View Profile
Re: user_setttings Return Value Issue
« Reply #10 on: May 07, 2015, 12:34:00 PM »
You can specify the path the setting file gets saved when you save the settings.  I have mine pointed back to the config directory the template file is in.  I don't have a service menu setup in my machine, so the only way you can revise the settings is via a text editor.  I am just starting to use the setting template file, so the only things I have in it are my starting high scores, my last game scores (so they get carried over even if the machine is turned off) and the balls per game.  One of the things on my 'to do' list is to go through the Flash game manual, and add some more adjustable features based on the original game rules.