Author Topic: Persist variable between plugin instances? SOLVED  (Read 2421 times)

arzoo

  • Newbie
  • *
  • Posts: 9
    • View Profile
Persist variable between plugin instances? SOLVED
« on: May 13, 2020, 07:24:26 AM »
I've noticed that the LEDBlinky plugin is reloaded each time the Displays list is active. Has anyone had success creating a global variable that persists between different plugins or the same plugin for each instance?

I've tried this code but it doesn't persist.
Code: [Select]
::ledblinky_started <- true;
« Last Edit: May 13, 2020, 07:01:57 PM by arzoo »

arzoo

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Persist variable between plugin instances?
« Reply #1 on: May 13, 2020, 05:50:05 PM »
As a follow-up to my question above, I created a simple plugin that does nothing except print to the console, and this confirms that the plugin is started twice when attract-mode first starts up, and then again each time the displays list is active? Why does am restart the plugin multiple times? It also appears that any global variables are also cleared each time the plugin restarts. This makes it impossible to maintain "state" within a plugin. Has anyone else noticed this issue?

arzoo

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Persist variable between plugin instances?
« Reply #2 on: May 13, 2020, 07:00:57 PM »
Ok, looks like I can use the fe.nv table to persist data. Problem solved.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Persist variable between plugin instances? SOLVED
« Reply #3 on: May 14, 2020, 02:16:57 AM »
Just remember that there is no rules with fe.nv. It might be wise to store your date inside a table with plugin/layout/module name to avoid being written over.

arzoo

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Persist variable between plugin instances? SOLVED
« Reply #4 on: May 14, 2020, 05:20:56 AM »
Just remember that there is no rules with fe.nv. It might be wise to store your date inside a table with plugin/layout/module name to avoid being written over.

Will do, thanks. Btw, who do I contact about having the current LEDBlinky plugin in the repo replaced with my updated version?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Persist variable between plugin instances? SOLVED
« Reply #5 on: May 14, 2020, 05:35:21 AM »
Just remember that there is no rules with fe.nv. It might be wise to store your date inside a table with plugin/layout/module name to avoid being written over.

Will do, thanks. Btw, who do I contact about having the current LEDBlinky plugin in the repo replaced with my updated version?

I believe the other process is as such, correct me if I am wrong;
  • fork repo
  • create branch
  • make commit
  • request pull

Try it. Hopefully it works. I started a public fork due to lack of communication. It's fustrating that the one open source software I can contribute to, I can't. Hopefully it changes in the future.