Howdy, Stranger!

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

Supported by

Display text stimulus in random postions

Okay I was able to solve an issue from a previous post by following @Fab advice.

I located the error and took it out. But now a condition of my experiment is missing. I want to randomise the location of the text stimulus (e.g., x=302, -302; y=174, -174) within the parameters of a rectangle box (i.e., x=352, -352; y=224, -224) so that participants aren't just focusing on the center of the screen and zoning-out distractor letters in a flanker task.

I understand that I may have to adapt the following post to my requirements

but I have no idea where to start and how to implement the edits suggested in this post and similar ones. Do I edit the script in the sketchpad? I understand that inline_script does not work through OSweb so I hope it's not that.

I'm unsure how to edit it to achieve what I want. I've tried doing stuff with the random and uniform function but keep running into errors. Anyways here is the basic script at the moment.

set duration 0
draw rect color="#3e3e3e" fill=1 h=448 penwidth=1 show_if=always w=704 x=-352 y=-224 z_index=2
draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=50 html=yes show_if=always text="[Stimulus]" x=0 y=0 z_index=0

Here is the trial loop if it is of any use:

If anyone could point me in the right direction it would be much appreciated!




  • Hi @meganb_ire,

    If you want to randomize the x and y coordinates of an object on a sketchpad, you'll need two things:

    (1) some coding

    You'll need to program some code to generate random x and y values within certain ranges. This coding can be written in Python in an inline_script object or in Javascript using an inline_javascript object (if you aim to run your task in a browser rather than within OS, you'll need to opt for Javascript*, as Python coding is not supported in OSWeb). Furthermore, the code will need to be placed under the "prepare" tab of the scripting object, because the coordinates of objects on sketchpads are prepared before the sequence is executed. Hence, if you insert the code under the "run" tab, the sketchpad would be set before the code is executed and the output of your code would be taking effect on the next trial. (Note that if you want to be able to manipulate the content of objects while the trial is running, you should use a feedback slide instead of a sketchpad).

    To generate a random value within a certain range is easy in Python, you can use the randint function:

    import random
    var.rnd_x = random.randint(-342, 342))

    In Javascript, it's a little more difficult but can be done like this in an inline_javascript object:

    vars.rnd_x = Math.floor(Math.random() * 684) - 342

    * Note that Javascript in experiments intended to ruin in OS should use the ECMA 5.1 syntax, while the ECMA 6 syntax can be used for experiments run through the browser (most recent browsers support the ECMA 6 syntax). See:

    (2) editing the sketchpad's script

    Once you have generated variables containing the random x and y coordinates, you'll need to feed these into the script corresponding to the text object you want to appear in random locations. A centered object has coordinates of 0,0, which s what you currently have:

    draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=50 html=yes show_if=always text="[Stimulus]" x=0 y=0 z_index=0

    Let's say that through code you created variables called rnd_x and rnd_y. The above script should then be modified to:

    draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=50 html=yes show_if=always text="[Stimulus]" x=[rnd_x] y=[rnd_y] z_index=0

    Good luck!


    Buy Me A Coffee

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 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