Howdy, Stranger!

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

Supported by

srbox inline script

edited September 2021 in OpenSesame

Hi! I'd like to use an srbox in an inline script.

However, if I use the code from here https://osdoc.cogsci.nl/3.3/manual/response/srbox/#function-srbox__init__experiment-devnone in this way:

import srbox
srbox.__init__(experiment, dev = COM1)
t0 = clock.time()
srbox.start()
button, t1 = srbox.get_button_press(allowed_buttons=[1,2],
        require_state_change=True)
if button == 1:
        response_time = t1 - t0
        print('Button 1 was pressed in %d ms!' % response_time)
srbox.stop()

I get the following error:

name 'experiment' is not defined.

If I delete the line:

srbox.__init__(experiment, dev = COM1)

then I get the following error:

'module' object has no attribute 'start'.


I would appreciate any help to solve this issue. Note that this is a very "plain" experiment aimed to do nothing more than get the srbox to work.

Comments

  • Hi @Paula ,

    These two lines:

    import srbox
    srbox.__init__(experiment, dev = COM1)
    

    Are not necessary, because the srbox is initialized by the srbox plugin. This means that, as soon as you have this plugin in your experiment, an srbox object will exist and can be used as in the example scripts in the documentation. In other words: simply removing these two lines should do the trick!

    -- Sebastiaan

    PS. Even if you would need to initialize the object, this would not be the way to do it. If you want to understand how the __init__() function etc. work, then I have a few videos about the basics of object-oriented programming. 😊

  • Hi @sebastiaan

    Thanks for the reply! I'd much rather use the plugin (I've used it before and it works perfectly), but I want to integrate this inline script in a coroutine. The plugin doesn't seem to work in the coroutine (I've tried without success).

    I've also tried removing the lines you mention are not necessary, and I get the error message:

    'module' object has no attribute 'start'.

    I upload the experiment I am working on here, and now I get the following error:

    name 'srbox' is not defined

    Thank you for the link to the videos on programming! I will investigate further!

  • Hi @Paula ,

    Even if you're going to use the srbox programmatically, you still have to add the plugin to the experiment. If necessary, you can simply put it at the top of the experiment and then set the timeout to 0 so that it effectively does nothing. But the plugin needs to be there, otherwise the srbox object will not be available in the Python workspace!

    — Sebastiaan

  • edited September 2021

    Sorry @sebastiaan , I didn't explain myself clearly:

    even when the plugin is added I still get the error message

    name 'srbox' is not defined

    The experiment is nothing more than a welcome sketchpad, the srbox plugin, and the inline code, and the exit sketchpad.

  • @Paula Ah, I see. That's because the plugin is in dummy mode, in which case the srbox object is not created. There is currently no way to test the srbox in dummy mode in a script, I'm afraid! In other words: you'll have to get a physical SR Box to develop and test the experiment.

    (I'll update the documentation to indicate this, because that's indeed not obvious.)

  • @sebastiaan : Thank you VERY much for clarifying this!! I really appreciate your help!

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