Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

updating variables in opesesame

appapp
edited June 2016 in OpenSesame

Hi!I am new to opensesame and I am putting together a simple experiment. Participants see two objects on the screen and are asked to press either the M or the Z button on the keyboard. If they click on the M button, they lose one point of out, let's say, 10 points. If they click in the Z button they lose nothing.

I declared after the loop a variable called 'points' as follows - exp.set('points',10)
what I want to do is adding an inline after I collect the responses that updates the var points and display its current value in a sketchpad after each trial.

I tried the following code in the prepare phase of the inline after collecting responses:

if self.get("response")=="z":
    points=points
elif self.get("response")=="m":
    points=points - 1

In the sketchpad I use the [ ] to retrieve the value of points:

  • you are earning [points] points -

But no matter what I click, the sketchpad always shows the value of 10..

I am pretty sure this is an easy question. but for some reasons I cannot figure it out!
thanks all!

Cheers,
A

Comments

  • edited 5:25AM

    Hi A,

    The reason is simply that you don't use exp.set() to update points. You only update the Python variable that lives in your inline_script, but which isn't accessible using the square-brackets notation. Also, as of 3.0, you can use the var.varname notation instead of exp.set(). That's a bit more elegant, but it does the same thing.

    So what you want to do is:

    if var.response == "z":
        var.points = var.points
    elif var.response == "m":
        var.points = var.points - 1
    

    Or, less redundant:

    if var.response == "m":
        var.points -= 1
    

    See also:

    Cheers!
    Sebastiaan

  • appapp
    edited 5:25AM

    Hi Sebastiaan!
    Thanks a lot! I was also running an older version and I could not wrap my head around the error that I was getting while trying to use the var.varname..
    Your solution is very elegant and works smoothly..
    Now I am trying to implement in the same experiment a block in which participants have to click accurately on one pic on the screen (with the mouse). if they click on it, then the accuracy is =1, otherwise is =0. I have been trying to re create the mouse.hit test (I am coming from an extensive eprime background!) but I could not figure out how to give feedback based on the accuracy of the mouse responses..
    do you have any recommendation, or can you direct me towards some relevant info?
    many thanks!

    Cheers,
    Andrea

  • edited July 2016

    Hi Andrea,

    One way would be to use the touch_response plugin, with which you can code mouse click responses based on a grid on the screen (e.g. left side is 0, right side is 1).

    Or you could use a custom form with image_button widgets on it:

    Cheers!
    Sebastiaan

  • appapp
    edited 5:25AM

    Thanks Sebastiaan!
    But the link you kindly provided does not work:-(
    andrea

  • edited 5:25AM

    Ah, right! It should work now. (I removed the .html part.)

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games