Howdy, Stranger!

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

Supported by

[solved] error: coercing to Unicode: need string or buffer, int found

edited March 2014 in OpenSesame

Well, I already searched for this error and therefor I know where the problem may lie, but I can't find the mistake.

I have 16 fields, of wich 4 are getting filled over time, but only one is filled at a given time. So it's like 4 squares are popping up on the screen.

So i created 2 loops. one for the Question at the end and one for displaying my 4 filled blocks.

To draw the block at the rightpositon i use the following line :

draw rect 128 * [x] 128 * [y] 128 128 fill=1 penwidth=1 color=#bcbcbc show_if="always"
(teh spaces around the " * " are not actually in my sourcecode)

"x" and "y" are variables defined in the loop with these values:
x = [x_1];
y = [y_1];
for the first loop. in the secound it is "x_2" and "y_2" and so on until "x_4".

"x_1" and all the other are defined in the first loop. All with values from -2 to 1.

Here:
draw textline 64 * [frage_x] 64 * [frage_y] "[frage]" center=1 color=white font_family="mono" font_size=32 font_italic=no font_bold=no show_if="always" html="yes"

"frage_x" and "frage_y" are in the range from -3 to 3 and "frage" is either 1 or 2 or 3 or 4.

So apparently this error occurs with the values of "x" and "y". But how am I supposed to use negative values with these variables, because i need them for the negative area of the sketchpad.

Errorcode is:
Traceback (most recent call last):
  File "/usr/bin/opensesamerun", line 88, in <module>
    exp.run()
  File "/usr/lib/pymodules/python2.7/libopensesame/experiment.py", line 287, in run
    self.items[self.start].run()
  File "/usr/lib/pymodules/python2.7/libopensesame/sequence.py", line 55, in run
    self.experiment.items[item].run()
  File "/usr/lib/pymodules/python2.7/libopensesame/loop.py", line 146, in run
    _item.prepare()
  File "/usr/lib/pymodules/python2.7/libopensesame/sequence.py", line 107, in prepare
    self.experiment.items[_item].prepare()              
  File "/usr/lib/pymodules/python2.7/libopensesame/sketchpad.py", line 207, in prepare
    _item["x"], _item["y"], html=_item["html"]==u"yes")
  File "/usr/lib/pymodules/python2.7/openexp/_canvas/legacy.py", line 746, in text
    color=color, html=html)
  File "/usr/lib/pymodules/python2.7/libopensesame/html.py", line 192, in render
    if _x+dx > max_x + (max_x-x):
TypeError: coercing to Unicode: need string or buffer, int found

Comments

  • edited 6:03AM

    Hi,

    The error message is not very informative, but basically he problem here is that your trying to do arithmetic in OpenSesame script, which is not supported.

    Basically, you can refer to variables, like so ...

    draw textline [x] [y] "this works"
    

    ... but you cannot do any calculations with them, like so:

    draw textline 5+[x] 10*[y] "this doesn't work"
    

    If you want to do this, you'll have to use an inline_script before the sketchpad, where you do the calculations and save the result in a variable that you can use in the sketchpad.

    So for example an inline_script with the following script in the prepare phase ...

    exp.set('x128', 128*self.get('x'))
    exp.set('y128', 128*self.get('y'))
    

    ... and a sketchpad with:

    draw rect [x128] [y128] 128 128 fill=1 penwidth=1 color=#bcbcbc show_if="always"
    

    Does that make sense? OpenSesame script is just not a full fledged programming language like Python.

    Cheers,
    Sebastiaan

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