Updating values within a sequence
Hello!
I'm trying to present participants with a screen that updates according to their responses. Basically, they are to "negotiate" and I want to show them how much resources they have left on the top left part of the screen as they make an offer. I've managed to do most of that, but the values won't update within a sequence.
This is what I did:
1) There is a loop with value1, value2, value3 assigned. (let's say how much wood, plastic, and screws they have)
2) Then a sequence with a screen showing their current budget (how much wood, plastic, and screws they have) and asking how many of each they want to give and ask for in return and an "offer" button.
Script in a form base:
set timeout infinite
set spacing 10
set rows "1;1;1;1;1;1"
set only_render no
set margins "50;50;50;50"
set cols "1;1;1"
set _theme gray
widget 0 0 1 1 label text="[value1] Wood [value2] Plastic [value3] Screws"
widget 1 0 1 1 image path="Goal1.png"
widget 2 0 1 1 image path="Goal2.png"
widget 1 1 1 1 label text=Give
widget 2 1 1 1 label text=Get
widget 0 2 1 1 image path="wood.png"
widget 1 2 1 1 rating_scale nodes="0;1;2;3;4;5;6;7;8;9" var=question1
widget 0 3 1 1 image path="plastic.png"
widget 1 3 1 1 rating_scale nodes="0;1;2;3;4;5;6;7;8;9;10" var=question2
widget 0 4 1 1 image path="screws.png"
widget 1 4 1 1 rating_scale nodes="0;1;2;3;4;5;6;7;8;9;10" var=question3
widget 2 2 1 1 rating_scale nodes="0;1;2;3;4;5;6;7;8;9;10" var=question4
widget 2 3 1 1 rating_scale nodes="0;1;2;3;4;5;6;7;8;9;10" var=question5
widget 2 4 1 1 rating_scale nodes="0;1;2;3;4;5;6;7;8;9;10" var=question6
widget 0 5 3 1 button text=Offer
3) Logger
4) Inline script updating value1, value2, and value3.
Inline Script:
var.value1 = var.value1 + var.question4
var.value2 = var.value2 + var.question5
var.value3 = var.value3 + var.question6
5) Logger
6) Same script in form base as before, where value1, value2, and value3 should be updated.
7) Logger
...
The issue is that when the second form shows up (step 6) the values are still the original ones, i.e. they have not updated. I checked the variable inspector and it has the correct values. It just seems like the values for the form were obtained at the beginning of the sequence rather than immediately before the form. Is there any way to fix this?
thank you!!
Candice
PS: I'm using the legacy back-end. I don't know if that's relevant. It was the only one that ran the script without crashing.
PS2: I also tried to subtract the values from the "Give" column, but it won't let me use a minus sign, it just gives an error. Any ideas as to why?
Comments
Hi Candice,
Did you place the code of your
inline_script
item in the Run phase tab?Cheers,
Lotje
Did you like my answer? Feel free to
Have you already tried an independent form base at point 6) ?
Maybe the image is prepared at the beginning (of the loop) and just used as it is later on. But what you want is that the image is set up again at point 6).
Lotje, Yes I did.
DahmSF, I´m not sure I understand. They are separate base forms, unlinked.
I ended up just writing the code in python and inserting it as an inline script, but I would still like to know if there is any way of fixing it within the base form.
Thanks!
In this case, would you mind uploading your experiment? Then we'll probably find out what is going on faster.
Eduard
Sorry, eduard, I missed your last message. What happens is that Opensesame seems to evaluate all variables in a sequence right when it starts running it, unless you use inline script. So, if you tell it n=5 in the beginning of the sequence, then change it to n=6, and at the end ask it to report n using a form base (or a sketchpad or basically any other way other than using feedback screen or inline script) , it will continue showing n=5, as it was in the beginning of the sequence. I simply fixed it by doing it all using inline script.