PennController for IBEX › Forums › Support › Can we randomize time with newTimer() ? › Reply To: Can we randomize time with newTimer() ?
March 21, 2022 at 10:57 am
#7910
Keymaster
Hi Larissa,
If you want the totality of your trial to be 3800ms (because timer-RT = 1700ms, max timer-D1 = 1600ms, timer_cue_D2 = 100ms and timer_D3 = 400ms) start the timer at the beginning of the trial, and wait for it at the end:
Template("tabela-target.csv" , row =>
newTrial("trial_2_center_cue_UP",
defaultText
.center()
.cssContainer({"position": "absolute",
"top": "50%",
"left": "50%",
"transform": "translate(-50%, +50%)"})
.print()
,
newTimer("wait-separacao",3800).start()
,
newText("D1", "<br><b>+</b>")
.cssContainer({"font-size":"100px",
"color":"blue"})
.center()
.print()
,
newTimer("timer-D1",400+Math.round(1200*Math.random())) // if you want between 400ms and 1600ms, you need 400+[0--1200]
.start()
.wait()
,
getText("D1").remove()
,
newText("cue", "<br> <b>*</b>")
.cssContainer({"font-size":"100px",
"color":"green"})
.center()
.print()
,
newTimer("timer_cue_D2",100)
.start()
.wait()
,
getText("cue","D2").remove()
,
newText("D3", "<br> <b>+</b>")
.cssContainer({"font-size":"100px",
"color":"pink"})
.center()
.print()
,
newTimer("timer_D3",400)
.start()
.wait()
,
getText("D3").remove()
,
newTimer("timer-RT",1700).start()
,
newImage("imagens", row.imagem).size(500, 200)
,
newText("cruz_central", "<br> <b>+</b>")
.cssContainer({"font-size":"100px",
"color":"black"})
.center()
.print()
,
//para cima//
newCanvas("center", 150,150)
.add( "center at 50%" , "center at 50%" , getImage("imagens"))
.cssContainer({"position": "absolute",
"margin-top": "85px"})
.center()
.log()
.print()
,
newKey("keypress1","SK")
.log()
.callback( getTimer("timer-RT").stop() )
,
getTimer("timer-RT").wait()
,
getKey("keypress1").disable(),
getText("cruz_central"),
getCanvas("center").remove()
,
newText("separacao", "<br> <b>+</b>")
.cssContainer({"font-size":"100px",
"color":"yellow"})
.center()
.print()
,
getTimer("wait-separacao").wait()
)
.log("imagens", row.imagem)
.log("item", row.versao)
);
Also, re. the feedback on each trial, just use the Var named localRT to set a Text element in the success/failure commands. For example, in success:
newVar("positiveFeedbackText").set( getVar("localRT") ).set( v => "Correct! Your speed was: "+v+"ms!" )
,
newText("positiveFeedback").text( getVar("positiveFeedbackText") ).print()
Jeremy