Ruby - How can I flush variables when FL start?

For general discussion related FlowStone
Post Reply
Nowhk
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Ruby - How can I flush variables when FL start?

Post by Nowhk »

I'm coding a Ruby script that store some variables (an Hash) during FL playing.
If I stop and restart FL, I see that those variables are not cleaned.

How can I clean variables/data ever time I start (or stop?) FL?

Thank you!
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby - How can I flush variables when FL start?

Post by tulamide »

Use "Is Playing" prim to keep track of the host's state. Every time it stops, (re-)set your variables.
"There lies the dog buried" (German saying translated literally)
Nowhk
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Ruby - How can I flush variables when FL start?

Post by Nowhk »

tulamide wrote:Use "Is Playing" prim

Uhm, what's "Is Playing" prim? Global variable? I don't understand what you mean (sorry, I'm new in Flowstone). :oops:
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby - How can I flush variables when FL start?

Post by tulamide »

Nowhk wrote:
tulamide wrote:Use "Is Playing" prim

Uhm, what's "Is Playing" prim? Global variable? I don't understand what you mean (sorry, I'm new in Flowstone). :oops:

If new, you should definately spend some time reading the user guide, and always keep the reference at hand. A prim is a primitive, a functional object Flowstone offers. You will find it in your toolbox. The "Is Playing" prim tells you the current state of the host (playing/stopped). Output is a false or a Ruby value. Connect that with your Ruby editor (look at the user guide, section Ruby, about how to setup variables from inputs). It will trigger the event method each time the value changes. So put your comparing code into the event method.
"There lies the dog buried" (German saying translated literally)
Nowhk
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Ruby - How can I flush variables when FL start?

Post by Nowhk »

tulamide wrote:
Nowhk wrote:
tulamide wrote:Use "Is Playing" prim

Uhm, what's "Is Playing" prim? Global variable? I don't understand what you mean (sorry, I'm new in Flowstone). :oops:

If new, you should definately spend some time reading the user guide, and always keep the reference at hand. A prim is a primitive, a functional object Flowstone offers. You will find it in your toolbox. The "Is Playing" prim tells you the current state of the host (playing/stopped). Output is a false or a Ruby value. Connect that with your Ruby editor (look at the user guide, section Ruby, about how to setup variables from inputs). It will trigger the event method each time the value changes. So put your comparing code into the event method.

Oh... didn't know that toolbox object were called "prim". I always called them "module" :)
Now I see what you mean. Linked to Ruby input, and managed events. Works like a charm!

Thank you!
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby - How can I flush variables when FL start?

Post by tulamide »

Well done! You're welcome :)
"There lies the dog buried" (German saying translated literally)
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Ruby - How can I flush variables when FL start?

Post by Perfect Human Interface »

Nowhk wrote:didn't know that toolbox object were called "prim". I always called them "module" :)


A "module" is a block that contains other elements, the things you can double-click on to go inside. "Primitives" you cannot go inside, because they're base-level components. Your toolbox will contain both modules and primitives.
Nowhk
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Ruby - How can I flush variables when FL start?

Post by Nowhk »

Wee Perfect Human, you are also here :) How are you?
Thanks for the precisation, makes things pretty clear! 8-)
Post Reply