Howdy, Stranger!

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

Supported by

Creating a variable equal to sum of other variables

Hello!

I'm creating a contribution task where people have to react to contributions of others to reach a certain threshold. If they reach it, they go to a screen saying they win. If not, they go to another screen saying they lose.

I'm trying to create a variable that takes the value (total+contribution) to put a condition on the display of both screens. But I don't know how to create that in the loop element.

I would really appreciate any help. Thanks in advance!

Melie

Comments

  • Hi Melie,

    I don't quite get where these variables are coming from. Could you elaborate more?

    Generally though it is rather easy. Under some circumstances you can do the arithmetics directly in the Opensesame items (e.g. on the sketchpad, or in run_if fields). Something like {total} + {contribution} might do the trick (see here)

    Apart from that you can also use an inline_script , in which you can write Python code that is evaluated every time that the experiment passes by that particular inline_script . In it you can compute new variables rather easily:

    e.g. total = total + contribution`

    Which would update the variable total from then on (careful, the variable needs to be initialized earlier to make this work!)

    Sorry if this advice is too general, but without more info on what you want to achieve, I can't give you more detailed help.

    Eduard

    Buy Me A Coffee

  • Hello Eduard,

    Thanks for your answer. Here are a little more details about my problem.

    My participants will "play" against 5 other players, which are fake, I pre-entered their contributions.

    The variable {total} is the total contribution of the 5 fake players (again with values pre-entered, I do not use a sum for these ones).

    Then participants say how much they want to contribute in a text_form, creating the variable {contribution}.

    (Here is a piece of my variables table)

    And for the different screens, I did put conditions as follow:

    And it works with OpenSesame, but when run with OSWeb the condition is not taken into account. Whatever contribution the participant put, it always goes to the winning screen and never shows the losing one.

    I tried with a simplier condition (contribution < 5 for example) and it works with OSWeb. So the problem seems to come from the use of the sum. So I'm trying to bypass it. Hence, creating a variable (ex: {win}) that takes the value total+contribution before the screens are to been shown, in order to write the condition only with it.

    And I tried several things to create it, but nothing works (mostly because I'm not sure how to do it): I tried to directly put the formula in the variable table in the loop element but it doesn't work. And for the inline_script, I tried to put it at the end of the text_form, but the line automatically goes at the beginning and then it is not working (I'm probably doing it wrong...).

    I don't know if you would need more details?

    Melie

  • Hi Melie,

    First of all, you need to use feedback items not sketchpads for the win/lose presentation. Otherwise the information on the participant contribution is not available (see the prepare-run strategy). Not sure, but this might already help with the issue.

    If not you can insert an inline_javascript item after the text input and update the total value with the contribution or create a new variable that you can use in the run in field. See here for how to use javascript code in Opensesame: https://osdoc.cogsci.nl/4.0/manual/javascript/about/

    Eduard

    Buy Me A Coffee

  • Hello Eduard,

    Thank you for your help. My problem has been solved elsewhere. Apparently it went for the fact that my variable "contribution", been created through text_form, was actually taken as a text and not as a number (makes sense...). So I could deal with the problem by adding a line of code before the win/lose screens.

    But I will take a look at what you sent for the next time.

    Thank you for your time,

    Melie

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