Increasing a persistent variable value (x = x + 1)

42 views
Skip to first unread message

Iain Simons

unread,
Jun 15, 2024, 8:04:43 AMJun 15
to QLab
Hello there!

Pretty new to Qlab scripting here..
I'm working on a project where i need to keep two 'score' variable for an onstage game, that are displayed and updated dynamically. 

I understand that I can store and set variables inside a text cue, but I was wondering what the best strategy might be for an operator to then increase the variable as someone 'scores a point'. 
I need this to be as easy as possible for the operator to do :) 

Essentially I'm looking to get the current value from the text cue and x, then x = x + 1, and then write it back. Am I right in thinking that applescript is the best / only way of approaching this? 

Any pointers much appreciated!

Thanks in advance :) 

Iain Simons

unread,
Jun 15, 2024, 8:10:41 AMJun 15
to QLab
having done some more reading -this appears to work...

tell application id "com.figure53.QLab.5" to tell front workspace

set currentRedScore to {get anchor x of cue "1.1"}
set currentRedScore to {currentRedScore + 1}
set anchor x of cue "1.1" to currentRedScore
set q name of cue "0.5" to "test group"
end tell

I guess i'll need to reinitialise currentRedScore to 0 every time i start the show, but that appears to do the job.. Unless I'm doing something really daft with that approach? 

Kinetic Screen

unread,
Jun 15, 2024, 8:15:04 AMJun 15
to QLab
Funny, I've just been posting a series of videos about different QLab tricks from a recent festival show, and one includes what I think is exactly what you're describing?


As in the video description, exactly as you describe the text layers that are displaying the scores are themselves used as the variable to be changed. You just need to get the text from the cue, make sure it is being treated as an integer, and then you can do your maths on the value.

This is what the 'correct' cue script looked like:

tell application id "com.figure53.QLab.5" to tell front workspace
if cue "saleBuzzer1" is running then
set CueTarget to "SaleCont1"
else if cue "saleBuzzer2" is running then
set CueTarget to "SaleCont2"
else if cue "saleBuzzer3" is running then
set CueTarget to "SaleCont3"
else
stop cue "Plus5"
end if
set theScore to the text of cue CueTarget
set theScore to theScore + 5
set text of cue CueTarget to theScore
end tell

You'll notice that the first thing it does is works out which contestant's buzzer is currently illuminated - the easiest way of determining who the score should be applied to.
Reply all
Reply to author
Forward
0 new messages