Hi Forum,
I have a problem of how to jump back into the part of a time loop, for example:
...
if time > time2 then
if b2 = 0 then
put 1 into b2
...
send "testInter"
...
end if
end if
This is once only test (only for b2=0), where the command "testInter" is executed, and I would like to come back just after the statement 'send "testInter"'. Is this possible? Note that in a big time loop there are lots of similar tests, and it would be easy to go back to the beginning, but then my b2 is 1! In one of the old languages I could use "go to location/ line" etc, and that would be fine. There must ba a way in REV to do something similar.
Regards,
Vladimir
Jumping out & back within a time loop
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Jumping out & back within a time loop
I have no idea what you are trying to do, your description is rather confused 
to get out of a loop or handler prematurely, you can use the "exit" or "exit repeat" commands:
there is no goto in rev, like in most "higher class" languages (stupid term). for cases where you want to go to certain parts of your code, then you have to remodel your code so that the part you want to get on top of is in a sub handler. alternatively you can use a flagging variable, like in this example:

to get out of a loop or handler prematurely, you can use the "exit" or "exit repeat" commands:
Code: Select all
on mouseUp
repeat forever
if the mouse is down then
exit repeat
end if
if counter > 10000 then
exit mouseUp
end if
end repeat
beep
end mouseUp
Code: Select all
on mouseUp
put false into myTest
repeat for each line myLine in field "text
if myTest is true then
--do stuff only after stuff below has happened
end if
--do other stuff
put true into myTest
end repeat
end mouseUp
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- Posts: 14
- Joined: Mon Dec 21, 2009 10:37 pm
Re: Jumping out & back within a time loop
Hello BvG,
I have abandoned hope for a reply, hence late post-response. First, many thanks! You were right about my confusion and you ewill see why. I would like to have several objects doing various things at different times but running at the same time. To do that I have seen in one of the excamples the following "loop":
--get the start time in ticks
command showTime
-- get the current time in ticks
--subtract current-start to get the ellapsed time
--do things
showTime
end showTime
and if I go out of the loop, then I come back by using 'send "showTime", etc. My question is: is there a better way of diung this? My main loop is attached!
Kind regards,
Vladimir Trbojevic
PS. Did not like Word doc, so it is here below:
==============================================================Time loop
global timeT, begT, endT, curT, curTsec, curTmin
#
global a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20
global b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20
global c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19, d20
global e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20
#
global m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11
global gmove
global tblurb, tin
global newcoords
global curDate, limDate, tMonth, tDay, tm
global tExpired, tExDate, cExpirationDate
global gStop
global wdir
#
global tChosenColor1, tChosenColor2, tChosenColor3
global tChangedColor1, tChangedColor2, tChangedColor3
# Event related
global gHEPlac, gHExpl, gHEp1, gHEp2, gHEp3, gHEinter
global gVCplac, gVCexpl, gVCp1, gVCp2, gVCp3, gVCp4, gVcentx, gVcenty
global gPFtime, gPFdura, gPFdia
global gTCrel, gTCdev, gTCdura, gTCdist, gTCentx, gTCenty
global gDataType, gHazType, gPropType, gEmerType, gScale
# Propagation related
global gPropRad1, gPropRad2, gPropRad3, gPropTim1, gPropTim2, gPropTim3
global gHaz1, gHaz2, gHaz3, gHaz4, gEsc1, gEsc2, gEsc3, gEme1, gEme2, gEme3, gEme4
# Emergency related
global gAmbTime1, gAmbTime2, gFireTIme1, gFireTime2, gPoliTime1, gPoliTime2, gArmyTime1, gArmyTime2
global gTime1, gTime2, gTime3, gTime4, gTime5, gTime6, gTime7, gTime8, gTime9, gTime10
global gTime11, gTime12, gTime13, gTime14, gTime15, gTime16, gTime17, gTime18, gTime19, gTime20
global gTime21, gTime22, gTime23, gTime24, gTime25, gTime26, gTime27, gTime28, gTime29, gTime30
# Copy object related
global nTank, nOffice, nIndustry, nHouse
# Initiator related
global gInitiator, gEscalator1, gEScalator2, gEscalator3, gVCesc, gTCesc, gVCloc, gTCloc
global gLoc1, gLoc2, gLoc3, gLoc4
global tGrc, xTank, xLoca, zVCtank, zTCtank, tDamTank
#
local tWang1, tWang2, tWang3, tIncre, tLoca, tBottom
local tLoops, k, xTime, yTime
#
#
# Initialise time
#
command setTime
put 0 into gStop
put the ticks into begT
put 0 into field "timer"
#
put "Chemical plant & tank farm (brown objects)" into line 1 of field "Board"
put "Housing Estate (dark green objects)" into line 2 of field "Board"
put "Industrial Estate (orange objects)" into line 3 of field "Board"
put "Time: midday" into line 5 of field "Board"
#
put gHEplac into line 1 of field "bb"
put gHExpl into line 2 of field "bb"
put gVCplac into line 3 of field "bb"
put gVCexpl into line 4 of field "bb"
put gPropTim2 into line 6 of field "bb"
put gTCdev into line 8 of field "bb"
#######
put 0 into tLoops
end setTime
#
# Show time
#
command showTime
put tLoops+1 into tLoops
put tLoops into field "test"
put the ticks into curT
put (curT - begT) into timeT
put (timeT/60/60) into curTmin
set the numberFormat to "0.00"
put curTmin into field "timer"
#############################
# Check for HE explosion as INITIATOR #
#############################
if gInitiator = 1 then
if curTmin > gHEplac then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc1 into tLoca
set the loc of button "terrorist" to tLoca
show button "terrorist"
end if
end if
# HE explosion (bang)
if curTmin > gHExpl then
if a2 = 0 then
put 1 into a2
put curTmin into field "timer"
set loc of grc "bang" to loc of button "terrorist"
hide button "terrorist"
show grc "bang"
----------
send "mouseUp" to button "Ininter"
----------
end if
end if
# Hide "bang"
if curTmin > gHExpl+0.005 then
if a3 = 0 then
put 1 into a3
hide grc "bang"
put gHExpl+0.005 into gTime5
end if
end if
end if -- End of Initiator=1
###########################################
# Check for Vapour Cloud release & explosion as INITIATOR #
###########################################
if gInitiator = 2 then
#
if curTmin > gVCplac then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc2 into tLoca
set the loc of button "VC release" to tloca
show button "VC release"
put line 1 of field "winDir" into tWang1
put (gVCexpl / 4) into gTime1
put gVCplac + gTime1 into gTime2
put gVCplac+gVCexpl into gTime3
----------
send "setMe tLoca" to button "VC release"
send "mouseUp" to button "Ininter"
----------
end if
end if
if curTmin > gVCplac+0.005 then
if a2 = 0 then
put 1 into a2
----------
send "displayMe gTime1, tWang1" to button "VC release"
----------
end if
end if
# VC explosion (bang)
if curTmin > gTime3 then
if a3 = 0 then
put 1 into a3
put curTmin into field "timer"
put gVCplac+gVCexpl+0.05 into gTime4
----------
send "displayPres" to button "VC release"
----------
end if
end if
# Remove bang
if curTmin > gTime4 then
if a4 = 0 then
put 1 into a4
put gTime4+0.005 into gTime5
----------
send "mouseUp" to button "Presinter"
send "hideMe" to button "VC release"
----------
end if
end if
end if --End of Initiator=2
##########################
# Check for Pool Fire as INITIATOR #
##########################
if gInitiator = 3 then
#
if curTmin > gPFtime then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc3 into tLoca
set the loc of button "Pool fire" to tLoca
show button "Pool fire"
----------
send "mouseUp" to button "Ininter"
----------
end if
end if
# Remove pool fire
if curTmin > gPFtime+gPFdura then
if a3 = 0 then
put 1 into a3
hide button "Pool fire"
put gPFtime+gPFdura+0.005 into gTime5
end if
end if
end if --End of Initiator=3
############################
# Check for Toxic Cloud as INITIATOR #
############################
if gInitiator = 4 then
#
if curTmin > gTCrel then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc4 into tLoca
set the loc of button "TC release" to tLoca
show button "TC release"
put line 2 of field "WinDir" into tWang2
put (gTCdev / 4) into gTime1
put gTCrel+gTCdev+gTCdura into gTime3
----------
send "setMe tLoca" to button "TC release"
----------
end if
end if
if curTmin > gTCrel+0.005 then
if a2 = 0 then
put 1 into a2
----------
send "displayMe gTime1, tWang2" to button "TC release"
----------
end if
end if
# Hide toxic clouds
if curTmin > gTime3+0.1 then
if a3 = 0 then
put 1 into a3
----------
send "hideMe" to button "TC release"
----------
put gTime3+0.005 into gTime5
end if
end if
end if --End of Initiator=4
#######################################
# Check for SUBSEQUENT (SECONDARY) EVENTS #####
#######################################
#
############################
# VC tank is SECONDARY ESCALATOR #
############################
if gEscalator1 = 1 then
if curTmin > gTime5 then
if b1 = 0 then
put 1 into b1
put curTmin into field "timer"
# Secondary VC release
put xLoca into tLoca
set the loc of button "VC release" to tLoca
set the loc of grc "inter2" to tLoca
show button "VC release"
put line 1 of field "WinDir" into tWang1
put (gVCexpl / 4) into xTime
put gTime5 + xTime into gTime6
----------
send "setMe tLoca" to button "VC release"
--send "displayMe xTime, tWang1" to button "VC release"
----------
end if
end if
if curTmin > gTime6 then
if b2 = 0 then
put 1 into b2
put curTmin into field "timer"
show grc "VCloud2"
put gTime6 + xTime into gTime7
end if
end if
if curTmin > gTime7 then
if b3 = 0 then
put 1 into b3
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud3"
show grc "VCloud3"
put gTime7 + xTime into gTime8
end if
end if
if curTmin > gTime8 then
if b4 = 0 then
put 1 into b4
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud4"
show grc "VCloud4"
put gTime8 + 0.001 into gTime9
end if
end if
----------
if curTmin > gTime9 then
if b5 = 0 then
put 1 into b5
put curTmin into field "timer"
put gTime9 + 0.001 into gTime10
----------
send "displayPres" to button "VC release"
----------
end if
end if
if curTmin > gTime10 then
if b6 = 0 then
put 1 into b6
put curTmin into field "timer"
put gTime10+(nTank-1)*gPropTim3 into gTime11
put gTime11 into gTime20
----------
send "mouseUp" to button "Presinter"
send "hideMe" to button "VC release"
put 1 into gVCesc
send "startEscalation" to button "Escinter"
----------
end if
end if
# Further escalation with TC clouds
if gTCesc = 1 then
if curTmin > gTime11 then
if b7 = 0 then
put 1 into b7
put curTmin into field "timer"
put line 3 of field "tankescal" into k
put "tank"&k into tGrc
put the loc of grc tGrc into tLoca
set the loc of button "TC release" to tLoca
show button "TC release"
put line 2 of field "WinDir" into tWang2
put (gTCdev / 4) into yTime
put gTime11 + yTime into gTime12
----------
send "setMe tLoca" to button "TC release"
----------
end if
end if
if curTmin > gTime12 then
if b8 = 0 then
put 1 into b8
put curTmin into field "timer"
----------
--send "displayMe yTime, tWang2" to button "TC release"
----------
put gTime12 + yTime into gTime13
end if
end if
if curTmin > gTime13 then
if b9 = 0 then
put 1 into b9
put curTmin into field "timer"
show grc "TCloud1"
put gTime13 + yTime into gTime14
end if
end if
----------
if curTmin > gTime14 then
if b10 = 0 then
put 1 into b10
put curTmin into field "timer"
send "rotateMe tWang2" to grc "TCloud2"
show grc "TCloud2"
put gTime14 + yTime into gTime15
end if
end if
if curTmin > gTime15 then
if b11 = 0 then
put 1 into b11
put curTmin into field "timer"
send "rotateMe tWang2" to grc "TCloud3"
show grc "TCloud3"
put gTime15 + 0.001 into gTime16
end if
end if
---------
if curTmin > gTime16 then
if b12 = 0 then
put 1 into b12
put curTmin into field "timer"
put curTmin into field "timer"
----------
send "hideMe" to button "TC release"
----------
put gTime16+0.001 into gTime20
end if
end if
end if
# End of further escalation by TC
end if
# End of VC as escalation
############################
# PF tank is SECONDARY ESCALATOR #
############################
if gEscalator1 = 2 then
if curTmin > gTime5 then
if c1 = 0 then
put 1 into c1
put curTmin into field "timer"
put xLoca into tLoca
set the loc of grc "inter3" to tLoca
show grc "inter3"
put gTime5+nTank*gPropTim3 into gTime6
---------
send "startEscalation" to button "Escinter"
---------
end if
end if
# Further escalation with VC clouds
if gVCesc = 1 then
if curTmin > gTime6 then
if c2 = 0 then
put 1 into c2
put curTmin into field "timer"
# Secondary VC release
put gVCloc into tLoca
set the loc of button "VC release" to tLoca
set the loc of grc "inter2" to tLoca
show button "VC release"
put line 1 of field "WinDir" into tWang1
put (gVCexpl / 4) into xTime
put gTime6 + xTime into gTime7
----------
send "setMe tLoca" to button "VC release"
--send "displayMe xTime, tWang1" to button "VC release"
----------
end if
end if
----------
if curTmin > gTime7 then
if c3 = 0 then
put 1 into c3
put curTmin into field "timer"
show grc "VCloud2"
put gTime7 + xTime into gTime8
end if
end if
if curTmin > gTime8 then
if c4 = 0 then
put 1 into c4
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud3"
show grc "VCloud3"
put gTime8 + xTime into gTime9
end if
end if
if curTmin > gTime9 then
if c5 = 0 then
put 1 into c5
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud4"
show grc "VCloud4"
put gTime9+0.001 into gTime10
end if
end if
----------
if curTmin > gTime10 then
if c6 = 0 then
put 1 into c6
put curTmin into field "timer"
put gTime10 + 0.03 into gTime11
----------
send "displayPres" to button "VC release"
----------
end if
end if
if curTmin > gTime11 then
if c7 = 0 then
put 1 into c7
put curTmin into field "timer"
put gTime11 + 0.001 into gTime20
----------
send "mouseUp" to button "Presinter"
send "hideMe" to button "VC release"
put 1 into gVCesc
--send "startEscalation" to button "Escinter" -- alrady done at the start!
----------
end if
end if
# End of further escalation by VC
end if
# Further escalation with TC clouds
if gTCesc = 1 then
if curTmin > gTime6+0.01 then
if c8 = 0 then
put 1 into c8
put curTmin into field "timer"
put line 3 of field "tankescal" into k
put "tank"&k into tGrc
put the loc of grc tGrc into tLoca
set the loc of button "TC release" to tLoca
show button "TC release"
put line 2 of field "WinDir" into tWang2
put (gTCdev / 4) into yTime
put gTime6 + yTime into gTime12
----------
send "setMe tLoca" to button "TC release"
----------
end if
end if
if curTmin > gTime12 then
if c9 = 0 then
put 1 into c9
put curTmin into field "timer"
----------
--send "displayMe yTime, tWang2" to button "TC release"
----------
put gTime12 + yTime into gTime13
end if
end if
----------
if curTmin > gTime13 then
if c10 = 0 then
put 1 into c10
show grc "TCloud1"
put gTime13 + yTime into gTime14
end if
end if
if curTmin > gTime14 then
if c11 = 0 then
put 1 into c11
send "rotateMe tWang2" to grc "TCloud2"
show grc "TCloud2"
put gTime14 + yTime into gTime15
end if
end if
if curTmin > gTime15 then
if c12 = 0 then
put 1 into c12
send "rotateMe tWang2" to grc "TCloud3"
show grc "TCloud3"
put gTime15 + gTCdura into gTime16
end if
end if
----------
if curTmin > gTime16 then
if c13 = 0 then
put 1 into c13
put curTmin into field "timer"
----------
send "hideMe" to button "TC release"
----------
put gTime16 + 0.01 into gTime20
end if
end if
end if
# End of further escalation by TC
end if
# End of PF as escalator
############################
# TC tank as SECONDARY ESCALATOR #
############################
if gEScalator1 = 3 then
if curTmin > gTime5 then
if b12 = 0 then
put 1 into b12
put curTmin into field "timer"
---------
--TC clouding
---------
end if
end if
end if
#######################
# Check Emergency Response #
#######################
if gEme1 = 1 then
if gAmbTime1 <> 0 then
if curTmin > gAmbTime1 then
if d1 = 0 then
put 1 into d1
put "Amb1 on its way" into line 15 of field "Board"
send "mouseUp" to img "amb1"
end if
end if
end if
if gAmbTime2 <> 0 then
if curTmin > gAmbTime2 then
if d2 = 0 then
put 1 into d2
send "mouseUp" to img "amb2"
end if
end if
end if
end if
#
#
--if curTmin > gTime23 then
if curTmin > 2 then
if d10 = 0 then
put 1 into d10
stopTime
end if
end if
#
# Main time driver
#
wait 200 millisec with messages
showTime
#
end showTime
###############################################################
command stopTime
send "mouseUp" to button "stop"
end stopTime
###############################################################
I have abandoned hope for a reply, hence late post-response. First, many thanks! You were right about my confusion and you ewill see why. I would like to have several objects doing various things at different times but running at the same time. To do that I have seen in one of the excamples the following "loop":
--get the start time in ticks
command showTime
-- get the current time in ticks
--subtract current-start to get the ellapsed time
--do things
showTime
end showTime
and if I go out of the loop, then I come back by using 'send "showTime", etc. My question is: is there a better way of diung this? My main loop is attached!
Kind regards,
Vladimir Trbojevic
PS. Did not like Word doc, so it is here below:
==============================================================Time loop
global timeT, begT, endT, curT, curTsec, curTmin
#
global a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20
global b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20
global c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20
global d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19, d20
global e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20
#
global m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11
global gmove
global tblurb, tin
global newcoords
global curDate, limDate, tMonth, tDay, tm
global tExpired, tExDate, cExpirationDate
global gStop
global wdir
#
global tChosenColor1, tChosenColor2, tChosenColor3
global tChangedColor1, tChangedColor2, tChangedColor3
# Event related
global gHEPlac, gHExpl, gHEp1, gHEp2, gHEp3, gHEinter
global gVCplac, gVCexpl, gVCp1, gVCp2, gVCp3, gVCp4, gVcentx, gVcenty
global gPFtime, gPFdura, gPFdia
global gTCrel, gTCdev, gTCdura, gTCdist, gTCentx, gTCenty
global gDataType, gHazType, gPropType, gEmerType, gScale
# Propagation related
global gPropRad1, gPropRad2, gPropRad3, gPropTim1, gPropTim2, gPropTim3
global gHaz1, gHaz2, gHaz3, gHaz4, gEsc1, gEsc2, gEsc3, gEme1, gEme2, gEme3, gEme4
# Emergency related
global gAmbTime1, gAmbTime2, gFireTIme1, gFireTime2, gPoliTime1, gPoliTime2, gArmyTime1, gArmyTime2
global gTime1, gTime2, gTime3, gTime4, gTime5, gTime6, gTime7, gTime8, gTime9, gTime10
global gTime11, gTime12, gTime13, gTime14, gTime15, gTime16, gTime17, gTime18, gTime19, gTime20
global gTime21, gTime22, gTime23, gTime24, gTime25, gTime26, gTime27, gTime28, gTime29, gTime30
# Copy object related
global nTank, nOffice, nIndustry, nHouse
# Initiator related
global gInitiator, gEscalator1, gEScalator2, gEscalator3, gVCesc, gTCesc, gVCloc, gTCloc
global gLoc1, gLoc2, gLoc3, gLoc4
global tGrc, xTank, xLoca, zVCtank, zTCtank, tDamTank
#
local tWang1, tWang2, tWang3, tIncre, tLoca, tBottom
local tLoops, k, xTime, yTime
#
#
# Initialise time
#
command setTime
put 0 into gStop
put the ticks into begT
put 0 into field "timer"
#
put "Chemical plant & tank farm (brown objects)" into line 1 of field "Board"
put "Housing Estate (dark green objects)" into line 2 of field "Board"
put "Industrial Estate (orange objects)" into line 3 of field "Board"
put "Time: midday" into line 5 of field "Board"
#
put gHEplac into line 1 of field "bb"
put gHExpl into line 2 of field "bb"
put gVCplac into line 3 of field "bb"
put gVCexpl into line 4 of field "bb"
put gPropTim2 into line 6 of field "bb"
put gTCdev into line 8 of field "bb"
#######
put 0 into tLoops
end setTime
#
# Show time
#
command showTime
put tLoops+1 into tLoops
put tLoops into field "test"
put the ticks into curT
put (curT - begT) into timeT
put (timeT/60/60) into curTmin
set the numberFormat to "0.00"
put curTmin into field "timer"
#############################
# Check for HE explosion as INITIATOR #
#############################
if gInitiator = 1 then
if curTmin > gHEplac then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc1 into tLoca
set the loc of button "terrorist" to tLoca
show button "terrorist"
end if
end if
# HE explosion (bang)
if curTmin > gHExpl then
if a2 = 0 then
put 1 into a2
put curTmin into field "timer"
set loc of grc "bang" to loc of button "terrorist"
hide button "terrorist"
show grc "bang"
----------
send "mouseUp" to button "Ininter"
----------
end if
end if
# Hide "bang"
if curTmin > gHExpl+0.005 then
if a3 = 0 then
put 1 into a3
hide grc "bang"
put gHExpl+0.005 into gTime5
end if
end if
end if -- End of Initiator=1
###########################################
# Check for Vapour Cloud release & explosion as INITIATOR #
###########################################
if gInitiator = 2 then
#
if curTmin > gVCplac then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc2 into tLoca
set the loc of button "VC release" to tloca
show button "VC release"
put line 1 of field "winDir" into tWang1
put (gVCexpl / 4) into gTime1
put gVCplac + gTime1 into gTime2
put gVCplac+gVCexpl into gTime3
----------
send "setMe tLoca" to button "VC release"
send "mouseUp" to button "Ininter"
----------
end if
end if
if curTmin > gVCplac+0.005 then
if a2 = 0 then
put 1 into a2
----------
send "displayMe gTime1, tWang1" to button "VC release"
----------
end if
end if
# VC explosion (bang)
if curTmin > gTime3 then
if a3 = 0 then
put 1 into a3
put curTmin into field "timer"
put gVCplac+gVCexpl+0.05 into gTime4
----------
send "displayPres" to button "VC release"
----------
end if
end if
# Remove bang
if curTmin > gTime4 then
if a4 = 0 then
put 1 into a4
put gTime4+0.005 into gTime5
----------
send "mouseUp" to button "Presinter"
send "hideMe" to button "VC release"
----------
end if
end if
end if --End of Initiator=2
##########################
# Check for Pool Fire as INITIATOR #
##########################
if gInitiator = 3 then
#
if curTmin > gPFtime then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc3 into tLoca
set the loc of button "Pool fire" to tLoca
show button "Pool fire"
----------
send "mouseUp" to button "Ininter"
----------
end if
end if
# Remove pool fire
if curTmin > gPFtime+gPFdura then
if a3 = 0 then
put 1 into a3
hide button "Pool fire"
put gPFtime+gPFdura+0.005 into gTime5
end if
end if
end if --End of Initiator=3
############################
# Check for Toxic Cloud as INITIATOR #
############################
if gInitiator = 4 then
#
if curTmin > gTCrel then
if a1 = 0 then
put 1 into a1
put curTmin into field "timer"
put gLoc4 into tLoca
set the loc of button "TC release" to tLoca
show button "TC release"
put line 2 of field "WinDir" into tWang2
put (gTCdev / 4) into gTime1
put gTCrel+gTCdev+gTCdura into gTime3
----------
send "setMe tLoca" to button "TC release"
----------
end if
end if
if curTmin > gTCrel+0.005 then
if a2 = 0 then
put 1 into a2
----------
send "displayMe gTime1, tWang2" to button "TC release"
----------
end if
end if
# Hide toxic clouds
if curTmin > gTime3+0.1 then
if a3 = 0 then
put 1 into a3
----------
send "hideMe" to button "TC release"
----------
put gTime3+0.005 into gTime5
end if
end if
end if --End of Initiator=4
#######################################
# Check for SUBSEQUENT (SECONDARY) EVENTS #####
#######################################
#
############################
# VC tank is SECONDARY ESCALATOR #
############################
if gEscalator1 = 1 then
if curTmin > gTime5 then
if b1 = 0 then
put 1 into b1
put curTmin into field "timer"
# Secondary VC release
put xLoca into tLoca
set the loc of button "VC release" to tLoca
set the loc of grc "inter2" to tLoca
show button "VC release"
put line 1 of field "WinDir" into tWang1
put (gVCexpl / 4) into xTime
put gTime5 + xTime into gTime6
----------
send "setMe tLoca" to button "VC release"
--send "displayMe xTime, tWang1" to button "VC release"
----------
end if
end if
if curTmin > gTime6 then
if b2 = 0 then
put 1 into b2
put curTmin into field "timer"
show grc "VCloud2"
put gTime6 + xTime into gTime7
end if
end if
if curTmin > gTime7 then
if b3 = 0 then
put 1 into b3
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud3"
show grc "VCloud3"
put gTime7 + xTime into gTime8
end if
end if
if curTmin > gTime8 then
if b4 = 0 then
put 1 into b4
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud4"
show grc "VCloud4"
put gTime8 + 0.001 into gTime9
end if
end if
----------
if curTmin > gTime9 then
if b5 = 0 then
put 1 into b5
put curTmin into field "timer"
put gTime9 + 0.001 into gTime10
----------
send "displayPres" to button "VC release"
----------
end if
end if
if curTmin > gTime10 then
if b6 = 0 then
put 1 into b6
put curTmin into field "timer"
put gTime10+(nTank-1)*gPropTim3 into gTime11
put gTime11 into gTime20
----------
send "mouseUp" to button "Presinter"
send "hideMe" to button "VC release"
put 1 into gVCesc
send "startEscalation" to button "Escinter"
----------
end if
end if
# Further escalation with TC clouds
if gTCesc = 1 then
if curTmin > gTime11 then
if b7 = 0 then
put 1 into b7
put curTmin into field "timer"
put line 3 of field "tankescal" into k
put "tank"&k into tGrc
put the loc of grc tGrc into tLoca
set the loc of button "TC release" to tLoca
show button "TC release"
put line 2 of field "WinDir" into tWang2
put (gTCdev / 4) into yTime
put gTime11 + yTime into gTime12
----------
send "setMe tLoca" to button "TC release"
----------
end if
end if
if curTmin > gTime12 then
if b8 = 0 then
put 1 into b8
put curTmin into field "timer"
----------
--send "displayMe yTime, tWang2" to button "TC release"
----------
put gTime12 + yTime into gTime13
end if
end if
if curTmin > gTime13 then
if b9 = 0 then
put 1 into b9
put curTmin into field "timer"
show grc "TCloud1"
put gTime13 + yTime into gTime14
end if
end if
----------
if curTmin > gTime14 then
if b10 = 0 then
put 1 into b10
put curTmin into field "timer"
send "rotateMe tWang2" to grc "TCloud2"
show grc "TCloud2"
put gTime14 + yTime into gTime15
end if
end if
if curTmin > gTime15 then
if b11 = 0 then
put 1 into b11
put curTmin into field "timer"
send "rotateMe tWang2" to grc "TCloud3"
show grc "TCloud3"
put gTime15 + 0.001 into gTime16
end if
end if
---------
if curTmin > gTime16 then
if b12 = 0 then
put 1 into b12
put curTmin into field "timer"
put curTmin into field "timer"
----------
send "hideMe" to button "TC release"
----------
put gTime16+0.001 into gTime20
end if
end if
end if
# End of further escalation by TC
end if
# End of VC as escalation
############################
# PF tank is SECONDARY ESCALATOR #
############################
if gEscalator1 = 2 then
if curTmin > gTime5 then
if c1 = 0 then
put 1 into c1
put curTmin into field "timer"
put xLoca into tLoca
set the loc of grc "inter3" to tLoca
show grc "inter3"
put gTime5+nTank*gPropTim3 into gTime6
---------
send "startEscalation" to button "Escinter"
---------
end if
end if
# Further escalation with VC clouds
if gVCesc = 1 then
if curTmin > gTime6 then
if c2 = 0 then
put 1 into c2
put curTmin into field "timer"
# Secondary VC release
put gVCloc into tLoca
set the loc of button "VC release" to tLoca
set the loc of grc "inter2" to tLoca
show button "VC release"
put line 1 of field "WinDir" into tWang1
put (gVCexpl / 4) into xTime
put gTime6 + xTime into gTime7
----------
send "setMe tLoca" to button "VC release"
--send "displayMe xTime, tWang1" to button "VC release"
----------
end if
end if
----------
if curTmin > gTime7 then
if c3 = 0 then
put 1 into c3
put curTmin into field "timer"
show grc "VCloud2"
put gTime7 + xTime into gTime8
end if
end if
if curTmin > gTime8 then
if c4 = 0 then
put 1 into c4
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud3"
show grc "VCloud3"
put gTime8 + xTime into gTime9
end if
end if
if curTmin > gTime9 then
if c5 = 0 then
put 1 into c5
put curTmin into field "timer"
send "rotateMe tWang1" to grc "VCloud4"
show grc "VCloud4"
put gTime9+0.001 into gTime10
end if
end if
----------
if curTmin > gTime10 then
if c6 = 0 then
put 1 into c6
put curTmin into field "timer"
put gTime10 + 0.03 into gTime11
----------
send "displayPres" to button "VC release"
----------
end if
end if
if curTmin > gTime11 then
if c7 = 0 then
put 1 into c7
put curTmin into field "timer"
put gTime11 + 0.001 into gTime20
----------
send "mouseUp" to button "Presinter"
send "hideMe" to button "VC release"
put 1 into gVCesc
--send "startEscalation" to button "Escinter" -- alrady done at the start!
----------
end if
end if
# End of further escalation by VC
end if
# Further escalation with TC clouds
if gTCesc = 1 then
if curTmin > gTime6+0.01 then
if c8 = 0 then
put 1 into c8
put curTmin into field "timer"
put line 3 of field "tankescal" into k
put "tank"&k into tGrc
put the loc of grc tGrc into tLoca
set the loc of button "TC release" to tLoca
show button "TC release"
put line 2 of field "WinDir" into tWang2
put (gTCdev / 4) into yTime
put gTime6 + yTime into gTime12
----------
send "setMe tLoca" to button "TC release"
----------
end if
end if
if curTmin > gTime12 then
if c9 = 0 then
put 1 into c9
put curTmin into field "timer"
----------
--send "displayMe yTime, tWang2" to button "TC release"
----------
put gTime12 + yTime into gTime13
end if
end if
----------
if curTmin > gTime13 then
if c10 = 0 then
put 1 into c10
show grc "TCloud1"
put gTime13 + yTime into gTime14
end if
end if
if curTmin > gTime14 then
if c11 = 0 then
put 1 into c11
send "rotateMe tWang2" to grc "TCloud2"
show grc "TCloud2"
put gTime14 + yTime into gTime15
end if
end if
if curTmin > gTime15 then
if c12 = 0 then
put 1 into c12
send "rotateMe tWang2" to grc "TCloud3"
show grc "TCloud3"
put gTime15 + gTCdura into gTime16
end if
end if
----------
if curTmin > gTime16 then
if c13 = 0 then
put 1 into c13
put curTmin into field "timer"
----------
send "hideMe" to button "TC release"
----------
put gTime16 + 0.01 into gTime20
end if
end if
end if
# End of further escalation by TC
end if
# End of PF as escalator
############################
# TC tank as SECONDARY ESCALATOR #
############################
if gEScalator1 = 3 then
if curTmin > gTime5 then
if b12 = 0 then
put 1 into b12
put curTmin into field "timer"
---------
--TC clouding
---------
end if
end if
end if
#######################
# Check Emergency Response #
#######################
if gEme1 = 1 then
if gAmbTime1 <> 0 then
if curTmin > gAmbTime1 then
if d1 = 0 then
put 1 into d1
put "Amb1 on its way" into line 15 of field "Board"
send "mouseUp" to img "amb1"
end if
end if
end if
if gAmbTime2 <> 0 then
if curTmin > gAmbTime2 then
if d2 = 0 then
put 1 into d2
send "mouseUp" to img "amb2"
end if
end if
end if
end if
#
#
--if curTmin > gTime23 then
if curTmin > 2 then
if d10 = 0 then
put 1 into d10
stopTime
end if
end if
#
# Main time driver
#
wait 200 millisec with messages
showTime
#
end showTime
###############################################################
command stopTime
send "mouseUp" to button "stop"
end stopTime
###############################################################
Re: Jumping out & back within a time loop
I am not going to look trough your script, as i'm not that patient.
At a first glance it seems that you are trying to make a time based game. Rev is not exactly good at creating precise timing loops, so you need to do some tricks to get a main loop behave properly. Most important is to know the backdraw of rev loops. Although they are fast, they are also blocking. That means the user cannot enter anything while a loop runs, no mouse events happen, screen redraws are limited. If you want to retain interactivity, you should look at the "send <message> in time" command. However, this approach will not be time precise. so you need to work around that by increasing the frequency to above 5 times your actual timevalue. this means that time precision below 2 or 3 seconds is not attainable.
see also:
number 4 of the online scripting conferences,which where done in 2008
the lesson on sending messages to objects
the animation engine tutorial stack (send in time example) standalone download: windows mac
the documentation pdf, topics "5.3 message path" and "5.8 ExtendingtheMessagePath"
the dictionary entry for the "send" command
At a first glance it seems that you are trying to make a time based game. Rev is not exactly good at creating precise timing loops, so you need to do some tricks to get a main loop behave properly. Most important is to know the backdraw of rev loops. Although they are fast, they are also blocking. That means the user cannot enter anything while a loop runs, no mouse events happen, screen redraws are limited. If you want to retain interactivity, you should look at the "send <message> in time" command. However, this approach will not be time precise. so you need to work around that by increasing the frequency to above 5 times your actual timevalue. this means that time precision below 2 or 3 seconds is not attainable.
see also:
number 4 of the online scripting conferences,which where done in 2008
the lesson on sending messages to objects
the animation engine tutorial stack (send in time example) standalone download: windows mac
the documentation pdf, topics "5.3 message path" and "5.8 ExtendingtheMessagePath"
the dictionary entry for the "send" command
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- Posts: 14
- Joined: Mon Dec 21, 2009 10:37 pm
Re: Jumping out & back within a time loop
Hi BvG,
Very many thanks. I have realised that having a long loop is not a good idea and that it would be much better to have it in chunks/objects that could run independently and communicate between themselves by sewnding messages. This requires the change of mindset!
Kind regards,
Vladimir
Very many thanks. I have realised that having a long loop is not a good idea and that it would be much better to have it in chunks/objects that could run independently and communicate between themselves by sewnding messages. This requires the change of mindset!
Kind regards,
Vladimir