[solved] error: coercing to Unicode: need string or buffer, int found
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
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 ...
... but you cannot do any calculations with them, like so:
If you want to do this, you'll have to use an
inline_script
before thesketchpad
, where you do the calculations and save the result in a variable that you can use in thesketchpad
.So for example an
inline_script
with the following script in the prepare phase ...... and a
sketchpad
with:Does that make sense? OpenSesame script is just not a full fledged programming language like Python.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!