Re: Incremental Color Change Over Long Periods
Posted: Fri Mar 07, 2014 6:03 am
Yeah, I already got the fullscreen working well. I'm exploring the rest now. Thanks a whole lot.
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
That's the only bit I'm foggy about. I don't know what you mean by seeing what it holds or how that translates into an ability to move implement an if/then. Thanks!See that tKey in there?
Put a breakpoint in and see what tKey holds. You can build an if/then from there.
Code: Select all
command do_nexsetting
if tContinue = true then
put the backgroundcolor of this stack into tValue
if tValue < 255 then
set the backgroundcolor of this stack to tValue+1,tValue+1,tValue+1
send "do_nexsetting tValue" to me in 1 second -- adjust timing here
end if
end if
end do_nexsetting
Code: Select all
global tContinue
on mouseup
set the fullscreen of this stack to true
If tContinue <> true then
put true into tContinue
send "do_nexsetting 1" to me in .1 secs
end if
end mouseup
command do_nexsetting tValue
if tContinue = true then
set the backgroundcolor of this stack to tValue,tValue,tValue
## We did not reach the last possible value yet, so:
if tValue < 255 then
if tValue > 254 then breakpoint
add 1 to tValue
put .1 into tNextDelivery
send "do_nexsetting tValue" to me in tNextDelivery secs
end if
end if
end do_nexsetting
on functionKey F2
if tValue < 255 then
if tValue > 254 then breakpoint
add 1 to tValue
put .1 into tNextDelivery
send "do_nexsetting tValue" to me in tNextDelivery secs
end if
end functionKey
Code: Select all
on optionKeyDown tkey
global tContinue
put false into tContinue
end optionKeyDown
on escapeKey
set the fullscreen of this stack to false
end escapeKey
Code: Select all
on optionKeyDown tkey
global tContinue
put numToChar(charToNum(tkey)) into tKey
if tKey = "p" then
put false into tContinue
end if
if tKey = "k" then
--up to you :)
end if
end optionKeyDown
Heck, not going to help you walk in tomorrow and say "Solved it!"Well, I just installed Livecode 24 hours ago
Code: Select all
command do_nexsetting tValue
## We did not reach the last possible value yet, so:
if tValue < 255 then
add 1 to tValue
### !!!!
set the backgroundcolor of this stack to tValue,tValue,tValue
### !!!!
put 15*60 into tNextDelivery
send "do_nexsetting tValue" to me in tNextDelivery secs
end if
end do_nexsetting
Code: Select all
local sOnState -- our on/off flag; this variable is available to all handlers in this script
on startSequence
set the fullscreen of this stack to true
set the backgroundcolor of this stack to "0,0,0" -- black
put true into sOnState -- set flag to "on"
send "do_nextsetting" to me in 1 second -- start the timer
end startSequence
-- this handler does the work. If the state flag is "on" it updates the color.
-- if the flag is "off" it does nothing. Since the next timer message
-- is only sent when "on" is true, the timer automatically stops if the on-state is false
command do_nextsetting -- we'll read the color directly here
if sOnState = true then -- state is "on"
-- since all 3 items are the same, we only need to look at one of them:
put item 1 of the backgroundcolor of this stack into tValue
if tValue < 255 then -- it isn't white yet
add 1 to tValue -- increment
set the backgroundcolor of this stack to tValue,tValue,tValue
send "do_nextsetting" to me in .1 second -- keep the timer going
end if
end if
end do_nextsetting
on functionKey pKey -- "pKey" will be the number of the function key that was pressed, this is the state toggle
if pKey = 6 then -- check for the correct key
put not sOnState into sOnState -- toggles the state flag true/false
if sOnState = true then -- state is "on", resume:
send "do_nextsetting" to me in 1 second -- restart the timer
end if
-- we don't need to do anything if it is off;
-- the do_nextsetting handler won't run because the flag is false
end if
end functionKey
on escapeKey -- abort everything
put false into sOnState
set the fullscreen of this stack to false
-- optional:
set the backgroundcolor of this stack to "255,255,255" -- white
end escapeKey