Author Topic: Global settings  (Read 2976 times)

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Global settings
« on: February 10, 2018, 10:54:29 AM »
Is there a way to set a global variable on launch that can be referenced (and changed) from any layout or plug-in?

So whatever you set it to (say true or false) would stay the same no matter where it was referenced from (layout, plug-in, screensaver, etc.). And likewise the value could conceivably be changed from any of these places.

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Re: Global settings
« Reply #1 on: February 10, 2018, 11:04:54 AM »
Might this be what the fe.nv table is for?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Global settings
« Reply #2 on: February 10, 2018, 01:25:01 PM »
Might this be what the fe.nv table is for?

Yes. However, be careful that you don’t mess with other params and loose them. There’s no real guideline. I opted for fe.nv.layout_plugin_module <- {} to keep things working nicely between devs.

Check out how I am using it:
https://github.com/keilmillerjr/mvscomplete/blob/master/layout.nut
Line 244

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Re: Global settings
« Reply #3 on: February 10, 2018, 11:21:51 PM »
Thanks!

I copied yours. The only difference is I only need to store one boolean in there.

if (!fe.nv.rawin("jukebox")) fe.nv.rawset("jukebox", false);

In jukebox mode you get music from whatever era of games are displayed (80s, 90s, etc) and the audio for all videos is turned off (Vid.NoAudio).

In non-jukebox mode you get the opposite (no music, but audio for videos is re-enabled).

The Custom1 input toggles between the two modes.

With the NV variable I can have these settings persist even when the screensaver is active.