Page 4 of 4
Re: Incremental Color Change Over Long Periods
Posted: Wed Mar 12, 2014 4:01 am
by jacque
theotherbassist wrote:
But the color specified in the menu label on Card 1 at the time the start button is clicked should determine which of the backgroundcolor variables will be linked to the tValue changes over time. (white: "tValue,tValue,tValue"; red: "tValue,0,0"; green: "0,tValue,0"; blue: "0,0,tValue") I know this must be really simple, I just can't seem to get the methodology.
You can refer to any object remotely without being on that card. That avoids the use of a global or any other variable. Just read the label of the button no matter where it is:
Code: Select all
put the label of btn "menuButton" of card 1 into tColor
You can even refer to objects in other open stacks:
Code: Select all
put the label of btn "menuButton" of card 1 of stack "theOtherStack" into tColor
and even if the stack isn't open, as long as you know the file name:
Code: Select all
put the label of btn "menuButton" of card 1 of stack (specialFolderPath("documents") & "/mystack.livecode") into tColor
Note that the last one will actually open the stack invisibly (and not in the message path) and it will stick around in RAM if you don't close it.
If you're going to use the color over and over again, then that's a good reason to retrieve it once and store it in a variable, especially if you're opening another file to get it, which is an expensive operation. But for a single retrieval you may as well just grab what you need and go.
Re: Incremental Color Change Over Long Periods
Posted: Wed Mar 12, 2014 4:03 am
by jacque
Wait a sec -- maybe you're asking how to link the word "red" with the rgb "255,0,0" ? Maybe I misread the question.
Re: Incremental Color Change Over Long Periods
Posted: Wed Mar 12, 2014 8:46 am
by theotherbassist
Jacque, thanks for the reply. I understand now that I could reference an object from different locations... I was unaware it was that easy, so I just stored my relevant variables as globals and referenced them that way. Cheers. No, I've never properly programmed in any other languages before... I've dabbled a bit with HTML and messed around with Wordpress, but that's all. So a lot of contingent learning going on here--but I'm slowly deriving the rules.
Here's (roughly) the way I have it set up now, in case anyone is interested:
Card 1: A menu is available with a "go" button, in essence, and an options menu to select the color (White, Red, Green, Blue, Yellow, Cyan, or Magenta).
When "go" is clicked, it reads the label of the options menu (i.e. the desired color) and places a corresponding number (e.g. "Red" = 2) into the global variable "Kolor". The click of "go" also opens the next card.
Card 2: Opens fullscreen, begins playing the white noise loop at 0%, and references the global "Kolor" value, which determines which one, two, or three of the three RGB values will be incrementally increased with the sound over time. Then a command runs (as long as the "pause" state isn't in effect) which checks the background color and adds to the correct color and volume-level variables until each reaches its maximum--then the program hangs until escape is pressed, sending the user back to Card 1.
Re: Incremental Color Change Over Long Periods
Posted: Wed Mar 12, 2014 6:01 pm
by jacque
Sounds perfect. I don't think you need to change anything unless you decide to get rid of the global (which you don't necessarily need to do.) If you want to, then the color-change card could grab the label from card 1, pop it into the local script variable on startSequence, and it would run from there. I think you only need the initial value (i.e., red) for the first pass through the changing sequence, so a global is a little superfluous. But it won't hurt.
Impressed with your progress, for a newbie. Nice going.
Re: Incremental Color Change Over Long Periods
Posted: Fri Dec 12, 2014 1:22 am
by theotherbassist
Brief follow up:
I finished everything and programmed in the parameters for several experimental conditions as part of my masters thesis. I actually used the program on four laptops that ran it continuously for over a month--no problems. Everything was solid. Basically, I conditioned and tested several pigeons in isolation chambers, bringing their eating behavior under experimental control with repeated exposures to only the program's light and sound. Thanks for the crash course everybody.